@dreamlake/dreamlake-cli 0.88.1 → 0.90.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/dist/api/access.d.ts +83 -0
- package/dist/api/access.js +77 -0
- package/dist/api/agent.d.ts +156 -0
- package/dist/api/agent.js +111 -0
- package/dist/api/browser.d.ts +90 -0
- package/dist/api/browser.js +102 -0
- package/dist/api/client.d.ts +54 -0
- package/dist/api/client.js +102 -0
- package/dist/api/common.d.ts +28 -0
- package/dist/api/common.js +16 -0
- package/dist/api/content.d.ts +195 -0
- package/dist/api/content.js +147 -0
- package/dist/api/execution.d.ts +84 -0
- package/dist/api/execution.js +73 -0
- package/dist/api/http.d.ts +19 -0
- package/dist/api/http.js +66 -0
- package/dist/api/index.d.ts +2362 -0
- package/dist/api/index.js +116 -0
- package/dist/api/infra.d.ts +2 -0
- package/dist/api/infra.js +2 -0
- package/dist/api/jobs.d.ts +2 -0
- package/dist/api/jobs.js +2 -0
- package/dist/api/layout.d.ts +2 -0
- package/dist/api/layout.js +2 -0
- package/dist/api/library-edit.d.ts +3 -0
- package/dist/api/library-edit.js +3 -0
- package/dist/api/library-manifest.d.ts +2 -0
- package/dist/api/library-manifest.js +2 -0
- package/dist/api/note-character-plan.d.ts +2 -0
- package/dist/api/note-character-plan.js +2 -0
- package/dist/api/note-editing.d.ts +2 -0
- package/dist/api/note-editing.js +2 -0
- package/dist/api/note-edits.d.ts +21 -0
- package/dist/api/note-edits.js +10 -0
- package/dist/api/note-events.d.ts +5 -0
- package/dist/api/note-events.js +11 -0
- package/dist/api/note-files.d.ts +102 -0
- package/dist/api/note-files.js +107 -0
- package/dist/api/note-html-read.d.ts +2 -0
- package/dist/api/note-html-read.js +2 -0
- package/dist/api/note-html.d.ts +2 -0
- package/dist/api/note-html.js +2 -0
- package/dist/api/note-linger.d.ts +83 -0
- package/dist/api/note-linger.js +270 -0
- package/dist/api/note-presence.d.ts +82 -0
- package/dist/api/note-presence.js +72 -0
- package/dist/api/note-toc.d.ts +2 -0
- package/dist/api/note-toc.js +2 -0
- package/dist/api/notes.d.ts +329 -0
- package/dist/api/notes.js +209 -0
- package/dist/api/open-resources.d.ts +27 -0
- package/dist/api/open-resources.js +102 -0
- package/dist/api/ownership.d.ts +12 -0
- package/dist/api/ownership.js +24 -0
- package/dist/api/platform.d.ts +83 -0
- package/dist/api/platform.js +56 -0
- package/dist/api/presigned-transfer.d.ts +2 -0
- package/dist/api/presigned-transfer.js +2 -0
- package/dist/api/registered-runs.d.ts +48 -0
- package/dist/api/registered-runs.js +33 -0
- package/dist/api/sessions.d.ts +299 -0
- package/dist/api/sessions.js +105 -0
- package/dist/api/storage.d.ts +46 -0
- package/dist/api/storage.js +34 -0
- package/dist/api/streams.d.ts +18 -0
- package/dist/api/streams.js +70 -0
- package/dist/api/vault.d.ts +93 -0
- package/dist/api/vault.js +79 -0
- package/dist/api/workspace.d.ts +180 -0
- package/dist/api/workspace.js +146 -0
- package/dist/cli/agent-identity.d.ts +4 -0
- package/dist/cli/agent-identity.js +21 -0
- package/dist/cli/agents/identity.d.ts +50 -0
- package/dist/cli/agents/identity.js +105 -0
- package/dist/cli/agents/index.d.ts +31 -0
- package/dist/cli/agents/index.js +580 -0
- package/dist/cli/agents/manage.d.ts +43 -0
- package/dist/cli/agents/manage.js +376 -0
- package/dist/cli/agents/spec.d.ts +104 -0
- package/dist/cli/agents/spec.js +280 -0
- package/dist/cli/agents/web.d.ts +7 -0
- package/dist/cli/agents/web.js +109 -0
- package/dist/cli/artifact/incremental.d.ts +21 -0
- package/dist/cli/artifact/incremental.js +80 -0
- package/dist/cli/artifact/index.d.ts +52 -0
- package/dist/cli/artifact/index.js +405 -0
- package/dist/cli/artifact/meta.d.ts +69 -0
- package/dist/cli/artifact/meta.js +189 -0
- package/dist/cli/auth/commands.d.ts +29 -0
- package/dist/cli/auth/commands.js +327 -0
- package/dist/cli/auth/constants.d.ts +13 -0
- package/dist/cli/auth/constants.js +18 -0
- package/dist/cli/auth/credentials.d.ts +37 -0
- package/dist/cli/auth/credentials.js +155 -0
- package/dist/cli/auth/device-flow.d.ts +32 -0
- package/dist/cli/auth/device-flow.js +154 -0
- package/dist/cli/auth/device-secret.d.ts +6 -0
- package/dist/cli/auth/device-secret.js +26 -0
- package/dist/cli/auth/machine.d.ts +15 -0
- package/dist/cli/auth/machine.js +126 -0
- package/dist/cli/auth/materialized.d.ts +32 -0
- package/dist/cli/auth/materialized.js +102 -0
- package/dist/cli/auth/migrate.d.ts +10 -0
- package/dist/cli/auth/migrate.js +75 -0
- package/dist/cli/client.d.ts +102 -0
- package/dist/cli/client.js +206 -0
- package/dist/cli/collection-list.d.ts +3 -0
- package/dist/cli/collection-list.js +25 -0
- package/dist/cli/compat/ctx.d.ts +26 -0
- package/dist/cli/compat/ctx.js +76 -0
- package/dist/cli/compat/dreamdb-wasm-embedded.d.ts +2 -0
- package/dist/cli/compat/dreamdb-wasm-embedded.js +8 -0
- package/dist/cli/compat/dreamdb-wasm.d.ts +1 -0
- package/dist/cli/compat/dreamdb-wasm.js +26 -0
- package/dist/cli/compat/dreamdb.d.ts +112 -0
- package/dist/cli/compat/dreamdb.js +219 -0
- package/dist/cli/compat/flags.d.ts +2 -0
- package/dist/cli/compat/flags.js +13 -0
- package/dist/cli/compat/http.d.ts +23 -0
- package/dist/cli/compat/http.js +137 -0
- package/dist/cli/compat/presignedTransfer.d.ts +139 -0
- package/dist/cli/compat/presignedTransfer.js +580 -0
- package/dist/cli/compat/s3-backend.d.ts +73 -0
- package/dist/cli/compat/s3-backend.js +132 -0
- package/dist/cli/config.d.ts +22 -0
- package/dist/cli/config.js +96 -0
- package/dist/cli/connection/dto.d.ts +159 -0
- package/dist/cli/connection/dto.js +497 -0
- package/dist/cli/connection/index.d.ts +50 -0
- package/dist/cli/connection/index.js +413 -0
- package/dist/cli/connection/oauth.d.ts +23 -0
- package/dist/cli/connection/oauth.js +290 -0
- package/dist/cli/connection/write.d.ts +47 -0
- package/dist/cli/connection/write.js +573 -0
- package/dist/cli/create/index.d.ts +19 -0
- package/dist/cli/create/index.js +209 -0
- package/dist/cli/declare/index.d.ts +29 -0
- package/dist/cli/declare/index.js +304 -0
- package/dist/cli/delete/index.d.ts +18 -0
- package/dist/cli/delete/index.js +232 -0
- package/dist/cli/download/index.d.ts +9 -0
- package/dist/cli/download/index.js +128 -0
- package/dist/cli/env/compose.d.ts +88 -0
- package/dist/cli/env/compose.js +402 -0
- package/dist/cli/env/index.d.ts +176 -0
- package/dist/cli/env/index.js +1011 -0
- package/dist/cli/experiments/index.d.ts +11 -0
- package/dist/cli/experiments/index.js +168 -0
- package/dist/cli/glob.d.ts +1 -0
- package/dist/cli/glob.js +45 -0
- package/dist/cli/graphql-helpers.d.ts +23 -0
- package/dist/cli/graphql-helpers.js +42 -0
- package/dist/cli/graphql.d.ts +10 -0
- package/dist/cli/graphql.js +47 -0
- package/dist/cli/help-examples.generated.d.ts +1 -0
- package/dist/cli/help-examples.generated.js +192 -0
- package/dist/cli/helpers.d.ts +8 -0
- package/dist/cli/helpers.js +106 -0
- package/dist/cli/hosts/api.d.ts +29 -0
- package/dist/cli/hosts/api.js +54 -0
- package/dist/cli/hosts/bootstrap-source.d.ts +1 -0
- package/dist/cli/hosts/bootstrap-source.js +2 -0
- package/dist/cli/hosts/catalog.d.ts +26 -0
- package/dist/cli/hosts/catalog.js +55 -0
- package/dist/cli/hosts/config.d.ts +45 -0
- package/dist/cli/hosts/config.js +179 -0
- package/dist/cli/hosts/credentials.d.ts +19 -0
- package/dist/cli/hosts/credentials.js +173 -0
- package/dist/cli/hosts/enroll.d.ts +17 -0
- package/dist/cli/hosts/enroll.js +109 -0
- package/dist/cli/hosts/enrollments.d.ts +25 -0
- package/dist/cli/hosts/enrollments.js +54 -0
- package/dist/cli/hosts/index.d.ts +6 -0
- package/dist/cli/hosts/index.js +279 -0
- package/dist/cli/hosts/inventory.d.ts +40 -0
- package/dist/cli/hosts/inventory.js +91 -0
- package/dist/cli/hosts/lifecycle.d.ts +15 -0
- package/dist/cli/hosts/lifecycle.js +108 -0
- package/dist/cli/hosts/metrics-source.d.ts +12 -0
- package/dist/cli/hosts/metrics-source.js +89 -0
- package/dist/cli/hosts/observations.d.ts +39 -0
- package/dist/cli/hosts/observations.js +102 -0
- package/dist/cli/hosts/remote.d.ts +5 -0
- package/dist/cli/hosts/remote.js +66 -0
- package/dist/cli/hosts/ssh.d.ts +63 -0
- package/dist/cli/hosts/ssh.js +276 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +288 -0
- package/dist/cli/infra/api.d.ts +95 -0
- package/dist/cli/infra/api.js +291 -0
- package/dist/cli/infra/index.d.ts +5 -0
- package/dist/cli/infra/index.js +102 -0
- package/dist/cli/infra/move.d.ts +15 -0
- package/dist/cli/infra/move.js +123 -0
- package/dist/cli/infra/transfer.d.ts +15 -0
- package/dist/cli/infra/transfer.js +280 -0
- package/dist/cli/jobs/api.d.ts +69 -0
- package/dist/cli/jobs/api.js +121 -0
- package/dist/cli/jobs/index.d.ts +5 -0
- package/dist/cli/jobs/index.js +140 -0
- package/dist/cli/lakeshore/index.d.ts +98 -0
- package/dist/cli/lakeshore/index.js +502 -0
- package/dist/cli/launch/index.d.ts +43 -0
- package/dist/cli/launch/index.js +270 -0
- package/dist/cli/layout/index.d.ts +2 -0
- package/dist/cli/layout/index.js +44 -0
- package/dist/cli/layout/transport.d.ts +12 -0
- package/dist/cli/layout/transport.js +70 -0
- package/dist/cli/library/add.d.ts +60 -0
- package/dist/cli/library/add.js +348 -0
- package/dist/cli/library/cache.d.ts +26 -0
- package/dist/cli/library/cache.js +88 -0
- package/dist/cli/library/config.d.ts +75 -0
- package/dist/cli/library/config.js +198 -0
- package/dist/cli/library/digest.d.ts +5 -0
- package/dist/cli/library/digest.js +19 -0
- package/dist/cli/library/discover.d.ts +87 -0
- package/dist/cli/library/discover.js +534 -0
- package/dist/cli/library/freshness.d.ts +35 -0
- package/dist/cli/library/freshness.js +109 -0
- package/dist/cli/library/generation.d.ts +35 -0
- package/dist/cli/library/generation.js +211 -0
- package/dist/cli/library/index.d.ts +2 -0
- package/dist/cli/library/index.js +36 -0
- package/dist/cli/library/info.d.ts +69 -0
- package/dist/cli/library/info.js +311 -0
- package/dist/cli/library/list.d.ts +33 -0
- package/dist/cli/library/list.js +86 -0
- package/dist/cli/library/manifest.d.ts +81 -0
- package/dist/cli/library/manifest.js +200 -0
- package/dist/cli/library/manifestCache.d.ts +45 -0
- package/dist/cli/library/manifestCache.js +169 -0
- package/dist/cli/library/pull.d.ts +30 -0
- package/dist/cli/library/pull.js +438 -0
- package/dist/cli/library/push.d.ts +72 -0
- package/dist/cli/library/push.js +642 -0
- package/dist/cli/library/rm.d.ts +31 -0
- package/dist/cli/library/rm.js +200 -0
- package/dist/cli/library/search.d.ts +18 -0
- package/dist/cli/library/search.js +181 -0
- package/dist/cli/library/stat.d.ts +15 -0
- package/dist/cli/library/stat.js +127 -0
- package/dist/cli/library/tools.d.ts +104 -0
- package/dist/cli/library/tools.js +163 -0
- package/dist/cli/library/wire.d.ts +47 -0
- package/dist/cli/library/wire.js +120 -0
- package/dist/cli/list/index.d.ts +26 -0
- package/dist/cli/list/index.js +256 -0
- package/dist/cli/notes/api-transport.d.ts +5 -0
- package/dist/cli/notes/api-transport.js +20 -0
- package/dist/cli/notes/character-plan.d.ts +22 -0
- package/dist/cli/notes/character-plan.js +232 -0
- package/dist/cli/notes/document.d.ts +73 -0
- package/dist/cli/notes/document.js +306 -0
- package/dist/cli/notes/edit-commands.d.ts +106 -0
- package/dist/cli/notes/edit-commands.js +623 -0
- package/dist/cli/notes/editing.d.ts +81 -0
- package/dist/cli/notes/editing.js +305 -0
- package/dist/cli/notes/events.d.ts +36 -0
- package/dist/cli/notes/events.js +54 -0
- package/dist/cli/notes/files-commands.d.ts +97 -0
- package/dist/cli/notes/files-commands.js +548 -0
- package/dist/cli/notes/html-read.d.ts +9 -0
- package/dist/cli/notes/html-read.js +90 -0
- package/dist/cli/notes/html.d.ts +73 -0
- package/dist/cli/notes/html.js +381 -0
- package/dist/cli/notes/index.d.ts +123 -0
- package/dist/cli/notes/index.js +1300 -0
- package/dist/cli/notes/linger.d.ts +4 -0
- package/dist/cli/notes/linger.js +96 -0
- package/dist/cli/notes/media-commands.d.ts +5 -0
- package/dist/cli/notes/media-commands.js +51 -0
- package/dist/cli/notes/move-command.d.ts +83 -0
- package/dist/cli/notes/move-command.js +259 -0
- package/dist/cli/notes/rm-command.d.ts +22 -0
- package/dist/cli/notes/rm-command.js +110 -0
- package/dist/cli/notes/select-command.d.ts +12 -0
- package/dist/cli/notes/select-command.js +63 -0
- package/dist/cli/notes/suggest-diff.d.ts +56 -0
- package/dist/cli/notes/suggest-diff.js +311 -0
- package/dist/cli/notes/toc.d.ts +38 -0
- package/dist/cli/notes/toc.js +144 -0
- package/dist/cli/notes/transfer-command.d.ts +6 -0
- package/dist/cli/notes/transfer-command.js +9 -0
- package/dist/cli/notes/version-commands.d.ts +19 -0
- package/dist/cli/notes/version-commands.js +178 -0
- package/dist/cli/nymph/index.d.ts +74 -0
- package/dist/cli/nymph/index.js +349 -0
- package/dist/cli/org/index.d.ts +34 -0
- package/dist/cli/org/index.js +341 -0
- package/dist/cli/ownership/index.d.ts +12 -0
- package/dist/cli/ownership/index.js +122 -0
- package/dist/cli/ownership/metadata-transfer.d.ts +20 -0
- package/dist/cli/ownership/metadata-transfer.js +159 -0
- package/dist/cli/page/index.d.ts +58 -0
- package/dist/cli/page/index.js +387 -0
- package/dist/cli/pipeline/index.d.ts +69 -0
- package/dist/cli/pipeline/index.js +604 -0
- package/dist/cli/progress.d.ts +60 -0
- package/dist/cli/progress.js +276 -0
- package/dist/cli/project/attachments.d.ts +10 -0
- package/dist/cli/project/attachments.js +39 -0
- package/dist/cli/project/grants.d.ts +10 -0
- package/dist/cli/project/grants.js +39 -0
- package/dist/cli/project/index.d.ts +8 -0
- package/dist/cli/project/index.js +92 -0
- package/dist/cli/project/move.d.ts +57 -0
- package/dist/cli/project/move.js +242 -0
- package/dist/cli/project/output.d.ts +2 -0
- package/dist/cli/project/output.js +29 -0
- package/dist/cli/project/stream.d.ts +55 -0
- package/dist/cli/project/stream.js +207 -0
- package/dist/cli/project/transfer-preview.d.ts +8 -0
- package/dist/cli/project/transfer-preview.js +10 -0
- package/dist/cli/prompt.d.ts +1 -0
- package/dist/cli/prompt.js +17 -0
- package/dist/cli/provider/dreamdir.d.ts +52 -0
- package/dist/cli/provider/dreamdir.js +138 -0
- package/dist/cli/provider/index.d.ts +4 -0
- package/dist/cli/provider/index.js +419 -0
- package/dist/cli/provider/jump-worker.d.ts +9 -0
- package/dist/cli/provider/jump-worker.js +141 -0
- package/dist/cli/provider/lifecycle.d.ts +149 -0
- package/dist/cli/provider/lifecycle.js +1390 -0
- package/dist/cli/provider/machine.d.ts +17 -0
- package/dist/cli/provider/machine.js +116 -0
- package/dist/cli/provider/ssh.d.ts +105 -0
- package/dist/cli/provider/ssh.js +305 -0
- package/dist/cli/provider/terraform.d.ts +140 -0
- package/dist/cli/provider/terraform.js +288 -0
- package/dist/cli/providers/index.d.ts +18 -0
- package/dist/cli/providers/index.js +422 -0
- package/dist/cli/python.d.ts +61 -0
- package/dist/cli/python.js +255 -0
- package/dist/cli/queues/index.d.ts +33 -0
- package/dist/cli/queues/index.js +248 -0
- package/dist/cli/queues/slurm.d.ts +10 -0
- package/dist/cli/queues/slurm.js +134 -0
- package/dist/cli/resources.d.ts +72 -0
- package/dist/cli/resources.js +137 -0
- package/dist/cli/run/index.d.ts +15 -0
- package/dist/cli/run/index.js +163 -0
- package/dist/cli/run/input.d.ts +34 -0
- package/dist/cli/run/input.js +135 -0
- package/dist/cli/run/recovery.d.ts +2 -0
- package/dist/cli/run/recovery.js +18 -0
- package/dist/cli/run/setup.d.ts +3 -0
- package/dist/cli/run/setup.js +62 -0
- package/dist/cli/runconfig/index.d.ts +12 -0
- package/dist/cli/runconfig/index.js +130 -0
- package/dist/cli/runnable/index.d.ts +35 -0
- package/dist/cli/runnable/index.js +575 -0
- package/dist/cli/runnable/path.d.ts +115 -0
- package/dist/cli/runnable/path.js +288 -0
- package/dist/cli/runnable/run.d.ts +91 -0
- package/dist/cli/runnable/run.js +239 -0
- package/dist/cli/runnable/upload.d.ts +43 -0
- package/dist/cli/runnable/upload.js +342 -0
- package/dist/cli/runnable/worker.d.ts +1 -0
- package/dist/cli/runnable/worker.js +44 -0
- package/dist/cli/schemas/workflow-spec.schema.json +335 -0
- package/dist/cli/self-update/index.d.ts +5 -0
- package/dist/cli/self-update/index.js +107 -0
- package/dist/cli/self-update/install.d.ts +60 -0
- package/dist/cli/self-update/install.js +428 -0
- package/dist/cli/self-update/paths.d.ts +40 -0
- package/dist/cli/self-update/paths.js +87 -0
- package/dist/cli/self-update/releases.d.ts +41 -0
- package/dist/cli/self-update/releases.js +153 -0
- package/dist/cli/self-update/settings.d.ts +16 -0
- package/dist/cli/self-update/settings.js +68 -0
- package/dist/cli/self-update/update.d.ts +18 -0
- package/dist/cli/self-update/update.js +241 -0
- package/dist/cli/service-accounts/index.d.ts +3 -0
- package/dist/cli/service-accounts/index.js +149 -0
- package/dist/cli/session-affiliation.d.ts +26 -0
- package/dist/cli/session-affiliation.js +135 -0
- package/dist/cli/sessions/affiliation.d.ts +8 -0
- package/dist/cli/sessions/affiliation.js +66 -0
- package/dist/cli/sessions/api.d.ts +55 -0
- package/dist/cli/sessions/api.js +88 -0
- package/dist/cli/sessions/control.d.ts +6 -0
- package/dist/cli/sessions/control.js +159 -0
- package/dist/cli/sessions/conversation.d.ts +15 -0
- package/dist/cli/sessions/conversation.js +118 -0
- package/dist/cli/sessions/index.d.ts +2 -0
- package/dist/cli/sessions/index.js +209 -0
- package/dist/cli/sessions/managed.d.ts +39 -0
- package/dist/cli/sessions/managed.js +63 -0
- package/dist/cli/sessions/redaction.d.ts +2 -0
- package/dist/cli/sessions/redaction.js +11 -0
- package/dist/cli/sessions/runner/exec.d.ts +108 -0
- package/dist/cli/sessions/runner/exec.js +335 -0
- package/dist/cli/sessions/runner/journal.d.ts +26 -0
- package/dist/cli/sessions/runner/journal.js +49 -0
- package/dist/cli/sessions/runner/native.d.ts +48 -0
- package/dist/cli/sessions/runner/native.js +170 -0
- package/dist/cli/sessions/runner/pod.d.ts +30 -0
- package/dist/cli/sessions/runner/pod.js +129 -0
- package/dist/cli/sessions/runner/serve.d.ts +85 -0
- package/dist/cli/sessions/runner/serve.js +558 -0
- package/dist/cli/sessions/sync.d.ts +47 -0
- package/dist/cli/sessions/sync.js +80 -0
- package/dist/cli/sessions/transport.d.ts +14 -0
- package/dist/cli/sessions/transport.js +116 -0
- package/dist/cli/share.d.ts +15 -0
- package/dist/cli/share.js +139 -0
- package/dist/cli/skill/catalog.d.ts +141 -0
- package/dist/cli/skill/catalog.js +442 -0
- package/dist/cli/skill/files.d.ts +89 -0
- package/dist/cli/skill/files.js +264 -0
- package/dist/cli/skill/index.d.ts +268 -0
- package/dist/cli/skill/index.js +1216 -0
- package/dist/cli/skill/manifest.d.ts +30 -0
- package/dist/cli/skill/manifest.js +101 -0
- package/dist/cli/skill/prefs.d.ts +9 -0
- package/dist/cli/skill/prefs.js +32 -0
- package/dist/cli/skill/reminders.d.ts +15 -0
- package/dist/cli/skill/reminders.js +105 -0
- package/dist/cli/skill/tar.d.ts +17 -0
- package/dist/cli/skill/tar.js +195 -0
- package/dist/cli/snapshot/index.d.ts +24 -0
- package/dist/cli/snapshot/index.js +146 -0
- package/dist/cli/source/access.d.ts +45 -0
- package/dist/cli/source/access.js +563 -0
- package/dist/cli/source/control.d.ts +103 -0
- package/dist/cli/source/control.js +546 -0
- package/dist/cli/source/delete.d.ts +89 -0
- package/dist/cli/source/delete.js +463 -0
- package/dist/cli/source/index.d.ts +288 -0
- package/dist/cli/source/index.js +1348 -0
- package/dist/cli/source/share.d.ts +65 -0
- package/dist/cli/source/share.js +530 -0
- package/dist/cli/source/upload.d.ts +62 -0
- package/dist/cli/source/upload.js +258 -0
- package/dist/cli/source/write.d.ts +77 -0
- package/dist/cli/source/write.js +335 -0
- package/dist/cli/spawn.d.ts +28 -0
- package/dist/cli/spawn.js +81 -0
- package/dist/cli/target.d.ts +22 -0
- package/dist/cli/target.js +85 -0
- package/dist/cli/tasks/index.d.ts +38 -0
- package/dist/cli/tasks/index.js +365 -0
- package/dist/cli/team/index.d.ts +37 -0
- package/dist/cli/team/index.js +407 -0
- package/dist/cli/telemetry.d.ts +23 -0
- package/dist/cli/telemetry.js +262 -0
- package/dist/cli/telemetryJournal.d.ts +26 -0
- package/dist/cli/telemetryJournal.js +104 -0
- package/dist/cli/update/index.d.ts +21 -0
- package/dist/cli/update/index.js +284 -0
- package/dist/cli/upload/index.d.ts +11 -0
- package/dist/cli/upload/index.js +261 -0
- package/dist/cli/upload/kinds.d.ts +10 -0
- package/dist/cli/upload/kinds.js +85 -0
- package/dist/cli/upload/multipart.d.ts +21 -0
- package/dist/cli/upload/multipart.js +248 -0
- package/dist/cli/vault/affected-preview.d.ts +15 -0
- package/dist/cli/vault/affected-preview.js +38 -0
- package/dist/cli/vault/cloud.d.ts +55 -0
- package/dist/cli/vault/cloud.js +287 -0
- package/dist/cli/vault/format.d.ts +18 -0
- package/dist/cli/vault/format.js +104 -0
- package/dist/cli/vault/hostCredentials.d.ts +21 -0
- package/dist/cli/vault/hostCredentials.js +71 -0
- package/dist/cli/vault/hostSupersessions.d.ts +18 -0
- package/dist/cli/vault/hostSupersessions.js +68 -0
- package/dist/cli/vault/import.d.ts +3 -0
- package/dist/cli/vault/import.js +79 -0
- package/dist/cli/vault/index.d.ts +14 -0
- package/dist/cli/vault/index.js +225 -0
- package/dist/cli/vault/keys.d.ts +5 -0
- package/dist/cli/vault/keys.js +165 -0
- package/dist/cli/vault/kms.d.ts +6 -0
- package/dist/cli/vault/kms.js +169 -0
- package/dist/cli/vault/list.d.ts +13 -0
- package/dist/cli/vault/list.js +60 -0
- package/dist/cli/vault/listView.d.ts +21 -0
- package/dist/cli/vault/listView.js +123 -0
- package/dist/cli/vault/managementMetadata.d.ts +2 -0
- package/dist/cli/vault/managementMetadata.js +23 -0
- package/dist/cli/vault/mutations.d.ts +8 -0
- package/dist/cli/vault/mutations.js +151 -0
- package/dist/cli/vault/otp.d.ts +6 -0
- package/dist/cli/vault/otp.js +62 -0
- package/dist/cli/vault/otpIntent.d.ts +23 -0
- package/dist/cli/vault/otpIntent.js +76 -0
- package/dist/cli/vault/passImport.d.ts +25 -0
- package/dist/cli/vault/passImport.js +129 -0
- package/dist/cli/vault/passOtp.d.ts +51 -0
- package/dist/cli/vault/passOtp.js +101 -0
- package/dist/cli/vault/passStore.d.ts +26 -0
- package/dist/cli/vault/passStore.js +134 -0
- package/dist/cli/vault/passwordCommand.d.ts +39 -0
- package/dist/cli/vault/passwordCommand.js +101 -0
- package/dist/cli/vault/passwordProbe.d.ts +27 -0
- package/dist/cli/vault/passwordProbe.js +282 -0
- package/dist/cli/vault/passwordRotation.d.ts +9 -0
- package/dist/cli/vault/passwordRotation.js +273 -0
- package/dist/cli/vault/rotationApi.d.ts +13 -0
- package/dist/cli/vault/rotationApi.js +58 -0
- package/dist/cli/vault/rotationCommand.d.ts +2 -0
- package/dist/cli/vault/rotationCommand.js +75 -0
- package/dist/cli/vault/rotationEngine.d.ts +19 -0
- package/dist/cli/vault/rotationEngine.js +65 -0
- package/dist/cli/vault/rotationHelperSource.d.ts +2 -0
- package/dist/cli/vault/rotationHelperSource.js +3 -0
- package/dist/cli/vault/rotationInput.d.ts +11 -0
- package/dist/cli/vault/rotationInput.js +48 -0
- package/dist/cli/vault/rotationJournal.d.ts +16 -0
- package/dist/cli/vault/rotationJournal.js +183 -0
- package/dist/cli/vault/rotationKeys.d.ts +4 -0
- package/dist/cli/vault/rotationKeys.js +48 -0
- package/dist/cli/vault/rotationPrepare.d.ts +17 -0
- package/dist/cli/vault/rotationPrepare.js +108 -0
- package/dist/cli/vault/rotationRemote.d.ts +33 -0
- package/dist/cli/vault/rotationRemote.js +156 -0
- package/dist/cli/vault/rotationState.d.ts +42 -0
- package/dist/cli/vault/rotationState.js +115 -0
- package/dist/cli/vault/rotationTransport.d.ts +18 -0
- package/dist/cli/vault/rotationTransport.js +71 -0
- package/dist/cli/vault/sshSource.d.ts +18 -0
- package/dist/cli/vault/sshSource.js +196 -0
- package/dist/cli/vault/sshSync.d.ts +17 -0
- package/dist/cli/vault/sshSync.js +224 -0
- package/dist/cli/vault/sshTransfer.d.ts +22 -0
- package/dist/cli/vault/sshTransfer.js +140 -0
- package/dist/cli/vault/terraformState.d.ts +66 -0
- package/dist/cli/vault/terraformState.js +252 -0
- package/dist/cli/vault/terraformStateCommand.d.ts +2 -0
- package/dist/cli/vault/terraformStateCommand.js +61 -0
- package/dist/cli/vault/tree.d.ts +43 -0
- package/dist/cli/vault/tree.js +292 -0
- package/dist/cli/version.d.ts +1 -0
- package/dist/cli/version.js +9 -0
- package/dist/cli/workflow/index.d.ts +76 -0
- package/dist/cli/workflow/index.js +826 -0
- package/dist/cli/workflow/validate.d.ts +19 -0
- package/dist/cli/workflow/validate.js +353 -0
- package/dist/package.json +1 -0
- package/package.json +28 -10
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// Device authorization flow (RFC 8628) — port of dreamlake-py's
|
|
2
|
+
// auth/device_flow.py.
|
|
3
|
+
//
|
|
4
|
+
// 1. start → POST {VUER_AUTH}/api/device/start → user_code + verification URI
|
|
5
|
+
// 2. poll → POST {VUER_AUTH}/api/device/poll → access_token (when approved)
|
|
6
|
+
// 3. exchange → POST {DL}/auth/exchange (Bearer) → permanent dreamlake token
|
|
7
|
+
import { vuerAuthUrl, CLIENT_ID, DEFAULT_SCOPE } from "./constants.js";
|
|
8
|
+
import { hashDeviceSecret } from "./device-secret.js";
|
|
9
|
+
export class DeviceFlowError extends Error {
|
|
10
|
+
}
|
|
11
|
+
export class DeviceCodeExpiredError extends DeviceFlowError {
|
|
12
|
+
}
|
|
13
|
+
export class AuthorizationDeniedError extends DeviceFlowError {
|
|
14
|
+
}
|
|
15
|
+
export class TokenExchangeError extends DeviceFlowError {
|
|
16
|
+
}
|
|
17
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
18
|
+
export class DeviceFlowClient {
|
|
19
|
+
deviceSecret;
|
|
20
|
+
dreamlakeServerUrl;
|
|
21
|
+
authUrl;
|
|
22
|
+
constructor(deviceSecret, dreamlakeServerUrl, authUrl) {
|
|
23
|
+
this.deviceSecret = deviceSecret;
|
|
24
|
+
this.dreamlakeServerUrl = dreamlakeServerUrl;
|
|
25
|
+
this.dreamlakeServerUrl = dreamlakeServerUrl.replace(/\/+$/, "");
|
|
26
|
+
this.authUrl = vuerAuthUrl(authUrl);
|
|
27
|
+
}
|
|
28
|
+
/** Initiate device authorization flow with vuer-auth. */
|
|
29
|
+
async startDeviceFlow(scope = DEFAULT_SCOPE) {
|
|
30
|
+
const res = await fetch(`${this.authUrl}/api/device/start`, {
|
|
31
|
+
method: "POST",
|
|
32
|
+
headers: { "Content-Type": "application/json" },
|
|
33
|
+
body: JSON.stringify({
|
|
34
|
+
client_id: CLIENT_ID,
|
|
35
|
+
scope,
|
|
36
|
+
device_secret_hash: hashDeviceSecret(this.deviceSecret),
|
|
37
|
+
}),
|
|
38
|
+
redirect: "error",
|
|
39
|
+
signal: AbortSignal.timeout(10000),
|
|
40
|
+
});
|
|
41
|
+
if (!res.ok) {
|
|
42
|
+
throw new DeviceFlowError(`Device authorization start failed (HTTP ${res.status})`);
|
|
43
|
+
}
|
|
44
|
+
const data = (await res.json());
|
|
45
|
+
const userCode = String(data.user_code ?? "");
|
|
46
|
+
const verificationUri = String(data.verification_uri ?? "");
|
|
47
|
+
const verificationUriComplete = String(data.verification_uri_complete ?? `${verificationUri}?code=${userCode.replace(/-/g, "")}`);
|
|
48
|
+
// Browser navigation is restricted to the configured issuer. Neither the
|
|
49
|
+
// response nor its query may smuggle access/refresh/device secrets into URLs.
|
|
50
|
+
const issuer = new URL(this.authUrl);
|
|
51
|
+
for (const value of [verificationUri, verificationUriComplete]) {
|
|
52
|
+
let url;
|
|
53
|
+
try {
|
|
54
|
+
url = new URL(value);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
throw new DeviceFlowError("Invalid device verification URL");
|
|
58
|
+
}
|
|
59
|
+
if (url.protocol !== "https:" || url.origin !== issuer.origin || url.username || url.password || url.hash ||
|
|
60
|
+
[...url.searchParams.keys()].some(key => !["code", "user_code"].includes(key)) ||
|
|
61
|
+
[...url.searchParams.values()].some(value => value.replace(/-/g, "") !== userCode.replace(/-/g, "")))
|
|
62
|
+
throw new DeviceFlowError("Untrusted device verification URL");
|
|
63
|
+
}
|
|
64
|
+
if (!/^[A-Za-z0-9-]{4,32}$/.test(userCode) || !Number.isFinite(Number(data.expires_in ?? 600)) || Number(data.expires_in ?? 600) <= 0 || Number(data.expires_in ?? 600) > 1800)
|
|
65
|
+
throw new DeviceFlowError("Invalid device authorization response");
|
|
66
|
+
return {
|
|
67
|
+
userCode,
|
|
68
|
+
deviceCode: String(data.device_code ?? ""),
|
|
69
|
+
verificationUri,
|
|
70
|
+
verificationUriComplete,
|
|
71
|
+
expiresIn: Number(data.expires_in ?? 600),
|
|
72
|
+
interval: Number(data.interval ?? 5),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Poll vuer-auth for authorization completion. Resolves with the
|
|
77
|
+
* vuer-auth access token (JWT). `onTick(elapsedSeconds)` is called
|
|
78
|
+
* before each poll for progress display.
|
|
79
|
+
*/
|
|
80
|
+
async pollForToken(maxAttempts = 120, onTick) {
|
|
81
|
+
const deviceSecretHash = hashDeviceSecret(this.deviceSecret);
|
|
82
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
83
|
+
if (onTick)
|
|
84
|
+
onTick(attempt * 5);
|
|
85
|
+
try {
|
|
86
|
+
const res = await fetch(`${this.authUrl}/api/device/poll`, {
|
|
87
|
+
method: "POST",
|
|
88
|
+
headers: { "Content-Type": "application/json" },
|
|
89
|
+
body: JSON.stringify({
|
|
90
|
+
client_id: CLIENT_ID,
|
|
91
|
+
device_secret_hash: deviceSecretHash,
|
|
92
|
+
}),
|
|
93
|
+
redirect: "error",
|
|
94
|
+
signal: AbortSignal.timeout(10000),
|
|
95
|
+
});
|
|
96
|
+
if (res.status === 200) {
|
|
97
|
+
const body = (await res.json());
|
|
98
|
+
const token = body.access_token;
|
|
99
|
+
if (typeof token !== "string" || !token) {
|
|
100
|
+
throw new TokenExchangeError(`device poll succeeded but no access_token in response (keys: ${Object.keys(body).join(", ")})`);
|
|
101
|
+
}
|
|
102
|
+
return token;
|
|
103
|
+
}
|
|
104
|
+
const error = (await res.json().catch(() => ({})))
|
|
105
|
+
.error;
|
|
106
|
+
if (error === "authorization_pending") {
|
|
107
|
+
await sleep(5000);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (error === "expired_token") {
|
|
111
|
+
throw new DeviceCodeExpiredError("Device code expired. Please run 'dreamlake login' again.");
|
|
112
|
+
}
|
|
113
|
+
if (error === "access_denied") {
|
|
114
|
+
throw new AuthorizationDeniedError("User denied authorization request.");
|
|
115
|
+
}
|
|
116
|
+
if (error === "slow_down") {
|
|
117
|
+
await sleep(10000);
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
throw new TokenExchangeError("Device authorization failed");
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
if (err instanceof DeviceFlowError)
|
|
124
|
+
throw err;
|
|
125
|
+
// Network blip — retry.
|
|
126
|
+
await sleep(5000);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
throw new DeviceFlowError("Authorization timed out after 10 minutes. Please run 'dreamlake login' again.");
|
|
130
|
+
}
|
|
131
|
+
/** Exchange a vuer-auth token for a permanent dreamlake token. */
|
|
132
|
+
async exchangeToken(vuerAuthToken) {
|
|
133
|
+
let res;
|
|
134
|
+
try {
|
|
135
|
+
res = await fetch(`${this.dreamlakeServerUrl}/auth/exchange`, {
|
|
136
|
+
method: "POST",
|
|
137
|
+
headers: { Authorization: `Bearer ${vuerAuthToken}` },
|
|
138
|
+
redirect: "error",
|
|
139
|
+
signal: AbortSignal.timeout(10000),
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
throw new TokenExchangeError("Token exchange unavailable");
|
|
144
|
+
}
|
|
145
|
+
if (!res.ok) {
|
|
146
|
+
throw new TokenExchangeError(`Token exchange failed (HTTP ${res.status})`);
|
|
147
|
+
}
|
|
148
|
+
const data = (await res.json());
|
|
149
|
+
if (!data.dreamlake_token) {
|
|
150
|
+
throw new TokenExchangeError("Server response missing dreamlake_token field");
|
|
151
|
+
}
|
|
152
|
+
return data.dreamlake_token;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Generate a cryptographically secure 64-char hex device secret (256 bits). */
|
|
2
|
+
export declare function generateDeviceSecret(): string;
|
|
3
|
+
/** SHA256 hash of the device secret, as a hex string. */
|
|
4
|
+
export declare function hashDeviceSecret(secret: string): string;
|
|
5
|
+
/** Load the persisted device secret, generating and saving one if absent. */
|
|
6
|
+
export declare function getOrCreateDeviceSecret(dir?: string): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Device secret generation + persistence.
|
|
2
|
+
//
|
|
3
|
+
// The secret is a stable per-machine identifier used by the
|
|
4
|
+
// device-authorization flow. It lives at dreamlake-py's location — the
|
|
5
|
+
// `device_secret` key of ~/.dreamlake/config.json — so both tools present
|
|
6
|
+
// one machine identity. (Older releases kept a separate
|
|
7
|
+
// ~/.config/dreamlake/device_secret file; auth/migrate.ts folds it in.)
|
|
8
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
9
|
+
import { readConfig, updateConfig } from "./materialized.js";
|
|
10
|
+
/** Generate a cryptographically secure 64-char hex device secret (256 bits). */
|
|
11
|
+
export function generateDeviceSecret() {
|
|
12
|
+
return randomBytes(32).toString("hex");
|
|
13
|
+
}
|
|
14
|
+
/** SHA256 hash of the device secret, as a hex string. */
|
|
15
|
+
export function hashDeviceSecret(secret) {
|
|
16
|
+
return createHash("sha256").update(secret, "utf8").digest("hex");
|
|
17
|
+
}
|
|
18
|
+
/** Load the persisted device secret, generating and saving one if absent. */
|
|
19
|
+
export function getOrCreateDeviceSecret(dir) {
|
|
20
|
+
const existing = readConfig(dir).device_secret;
|
|
21
|
+
if (typeof existing === "string" && existing.length > 0)
|
|
22
|
+
return existing;
|
|
23
|
+
const secret = generateDeviceSecret();
|
|
24
|
+
updateConfig({ device_secret: secret }, dir);
|
|
25
|
+
return secret;
|
|
26
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
export type IdentityMode = "user" | "machine";
|
|
3
|
+
export interface MachineConfig {
|
|
4
|
+
version: 1;
|
|
5
|
+
remote: string;
|
|
6
|
+
audience: string;
|
|
7
|
+
enrollmentId: string;
|
|
8
|
+
keyFile: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function machineConfigPath(): string;
|
|
11
|
+
export declare function identityMode(): IdentityMode;
|
|
12
|
+
export declare function loadMachineConfig(): MachineConfig;
|
|
13
|
+
export declare function machineHeaders(c: MachineConfig, requestPath: string): Record<string, string>;
|
|
14
|
+
export declare function machineRead(requestPath: string): Promise<Record<string, unknown>>;
|
|
15
|
+
export declare function registerMachineCommand(program: Command): void;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/** Machine proof of possession is independent of the human JWT store.
|
|
2
|
+
* Re-read the key for every request so Nymph rotation takes effect immediately. */
|
|
3
|
+
import { createHash, createPrivateKey, createPublicKey, randomBytes, sign } from "node:crypto";
|
|
4
|
+
import { closeSync, constants, fstatSync, openSync, readFileSync, existsSync } from "node:fs";
|
|
5
|
+
import { homedir } from "node:os";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
export function machineConfigPath() {
|
|
8
|
+
const value = process.env.DREAMLAKE_MACHINE_CONFIG ?? path.join(homedir(), ".config/dreamlake/machine.json");
|
|
9
|
+
if (!path.isAbsolute(value))
|
|
10
|
+
throw new Error("DREAMLAKE_MACHINE_CONFIG must be an absolute path");
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
export function identityMode() {
|
|
14
|
+
const mode = process.env.DREAMLAKE_IDENTITY;
|
|
15
|
+
if (mode !== undefined && mode !== "user" && mode !== "machine")
|
|
16
|
+
throw new Error("DREAMLAKE_IDENTITY must be user or machine");
|
|
17
|
+
return mode ?? (existsSync(machineConfigPath()) ? "machine" : "user");
|
|
18
|
+
}
|
|
19
|
+
function privateFile(filename) {
|
|
20
|
+
let fd;
|
|
21
|
+
try {
|
|
22
|
+
fd = openSync(filename, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
23
|
+
const st = fstatSync(fd);
|
|
24
|
+
if (!st.isFile() || st.size > 16384 || (process.platform !== "win32" &&
|
|
25
|
+
((st.mode & 0o077) !== 0 || ![0, process.getuid?.()].includes(st.uid))))
|
|
26
|
+
throw new Error();
|
|
27
|
+
return readFileSync(fd, "utf8");
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
throw new Error("Machine configuration/key unavailable; require an owned regular file with mode 0600");
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
if (fd !== undefined)
|
|
34
|
+
closeSync(fd);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export function loadMachineConfig() {
|
|
38
|
+
let c;
|
|
39
|
+
try {
|
|
40
|
+
c = JSON.parse(privateFile(machineConfigPath()));
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
throw new Error("Machine configuration unavailable; inspect provisioning, ownership and mode 0600");
|
|
44
|
+
}
|
|
45
|
+
let remote;
|
|
46
|
+
try {
|
|
47
|
+
remote = new URL(c.remote);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
throw new Error("Invalid machine API origin");
|
|
51
|
+
}
|
|
52
|
+
if (remote.protocol !== "https:" || remote.username || remote.password || remote.pathname !== "/" || remote.search || remote.hash ||
|
|
53
|
+
c.version !== 1 || typeof c.audience !== "string" || !c.audience || c.audience.length > 256 ||
|
|
54
|
+
!/^[a-f0-9]{24}$/.test(c.enrollmentId) || typeof c.keyFile !== "string" || !path.isAbsolute(c.keyFile))
|
|
55
|
+
throw new Error("Invalid machine configuration");
|
|
56
|
+
return { ...c, remote: remote.origin };
|
|
57
|
+
}
|
|
58
|
+
export function machineHeaders(c, requestPath) {
|
|
59
|
+
if (!/^\/machine\/(?:self|(?:hosts|projects)\/[a-f0-9]{24})$/.test(requestPath))
|
|
60
|
+
throw new Error("Unsupported machine read");
|
|
61
|
+
const encoded = privateFile(c.keyFile).trim();
|
|
62
|
+
if (!/^[A-Za-z0-9_-]{43}$/.test(encoded) || Buffer.from(encoded, "base64url").toString("base64url") !== encoded)
|
|
63
|
+
throw new Error("Invalid machine key format");
|
|
64
|
+
const seed = Buffer.from(encoded, "base64url");
|
|
65
|
+
const key = createPrivateKey({ key: Buffer.concat([Buffer.from("302e020100300506032b657004220420", "hex"), seed]), format: "der", type: "pkcs8" });
|
|
66
|
+
seed.fill(0);
|
|
67
|
+
const publicKey = createPublicKey(key).export({ format: "der", type: "spki" }).subarray(12);
|
|
68
|
+
const timestamp = String(Date.now()), nonce = randomBytes(24).toString("base64url");
|
|
69
|
+
const payload = JSON.stringify(["dreamlake-machine-v1", c.audience, "GET", requestPath, createHash("sha256").update("").digest("hex"), c.enrollmentId, timestamp, nonce]);
|
|
70
|
+
return { "x-dreamlake-enrollment": c.enrollmentId, "x-dreamlake-timestamp": timestamp,
|
|
71
|
+
"x-dreamlake-nonce": nonce, "x-dreamlake-key-id": createHash("sha256").update(publicKey).digest("base64url").slice(0, 16),
|
|
72
|
+
"x-dreamlake-signature": sign(null, Buffer.from(payload), key).toString("base64url") };
|
|
73
|
+
}
|
|
74
|
+
export async function machineRead(requestPath) {
|
|
75
|
+
const c = loadMachineConfig();
|
|
76
|
+
let response;
|
|
77
|
+
try {
|
|
78
|
+
response = await fetch(c.remote + requestPath, { headers: machineHeaders(c, requestPath), redirect: "error", signal: AbortSignal.timeout(30_000) });
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
throw new Error("Machine read unavailable; inspect enrollment, clock, connectivity and key rotation");
|
|
82
|
+
}
|
|
83
|
+
if (!response.ok)
|
|
84
|
+
throw new Error(`Machine read failed (HTTP ${response.status}); inspect grants and revocation`);
|
|
85
|
+
let data;
|
|
86
|
+
try {
|
|
87
|
+
data = await response.json();
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
throw new Error("Invalid machine response");
|
|
91
|
+
}
|
|
92
|
+
const kind = requestPath === "/machine/self" ? "principal" : requestPath.includes("/hosts/") ? "host" : "project";
|
|
93
|
+
const fields = kind === "principal" ? ["kind", "namespaceId", "serviceAccountId", "enrollmentId", "machineId", "hostId"] : ["id", "name", "namespaceId", "createdAt", "updatedAt"];
|
|
94
|
+
if (!data?.[kind] || typeof data[kind] !== "object" || Array.isArray(data[kind]))
|
|
95
|
+
throw new Error("Invalid machine response");
|
|
96
|
+
const output = Object.fromEntries(fields.filter(f => typeof data[kind][f] === "string").map(f => [f, data[kind][f]]));
|
|
97
|
+
if (kind === "principal" ? !/^[a-f0-9]{24}$/.test(String(output.serviceAccountId)) || output.enrollmentId !== c.enrollmentId || output.kind !== "service-account" : output.id !== requestPath.split("/").at(-1))
|
|
98
|
+
throw new Error("Incomplete machine response");
|
|
99
|
+
return { [kind]: output };
|
|
100
|
+
}
|
|
101
|
+
export function registerMachineCommand(program) {
|
|
102
|
+
const group = program.command("machine").description("inspect the provisioned service identity and explicitly granted resources");
|
|
103
|
+
const execute = async (url, opts) => {
|
|
104
|
+
try {
|
|
105
|
+
console.log(JSON.stringify(await machineRead(url), null, 2));
|
|
106
|
+
}
|
|
107
|
+
catch (e) {
|
|
108
|
+
const error = e instanceof Error ? e.message : "Machine read failed";
|
|
109
|
+
if (opts.json)
|
|
110
|
+
console.log(JSON.stringify({ status: "error", error }));
|
|
111
|
+
else
|
|
112
|
+
console.error(error);
|
|
113
|
+
process.exitCode = 1;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
group.command("self").option("--json").action(opts => execute("/machine/self", opts));
|
|
117
|
+
for (const kind of ["host", "project"])
|
|
118
|
+
group.command(`${kind} <id>`).option("--json").action((id, opts) => {
|
|
119
|
+
if (!/^[a-f0-9]{24}$/.test(id)) {
|
|
120
|
+
console.error("Use a 24-character resource ID");
|
|
121
|
+
process.exitCode = 1;
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
return execute(`/machine/${kind}s/${id}`, opts);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** The token slot `dreamlake login` (py) writes and `_session.py` reads. */
|
|
2
|
+
export declare const TOKEN_SLOT = "dreamlake-token";
|
|
3
|
+
/** `~/.dreamlake` — shared with dreamlake-py. Fixed, no XDG (py has none). */
|
|
4
|
+
export declare function dreamlakeDir(): string;
|
|
5
|
+
export declare function tokensPath(dir?: string): string;
|
|
6
|
+
export declare function configPath(dir?: string): string;
|
|
7
|
+
/** Token from tokens.json, or null. */
|
|
8
|
+
export declare function readToken(dir?: string): string | null;
|
|
9
|
+
export interface MaterializedConfig {
|
|
10
|
+
remote_url?: string;
|
|
11
|
+
/** Cached namespace slug for the materialized (remote, token) pair. */
|
|
12
|
+
namespace?: string;
|
|
13
|
+
device_secret?: string;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}
|
|
16
|
+
export declare function readConfig(dir?: string): MaterializedConfig;
|
|
17
|
+
/** Merge keys into config.json (a `undefined` value deletes the key). */
|
|
18
|
+
export declare function updateConfig(patch: Partial<MaterializedConfig>, dir?: string): void;
|
|
19
|
+
export interface ProjectedEnv {
|
|
20
|
+
token: string;
|
|
21
|
+
server: string;
|
|
22
|
+
namespace?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Make `env` the effective connection: token into the tokens.json slot,
|
|
26
|
+
* server/namespace into config.json. Always writes the full set —
|
|
27
|
+
* a projection that changed the token but kept the old remote_url would
|
|
28
|
+
* aim one environment's token at another's server.
|
|
29
|
+
*/
|
|
30
|
+
export declare function projectEnv(env: ProjectedEnv, dir?: string): void;
|
|
31
|
+
/** Remove the connection (logout with no env left). Keeps device_secret. */
|
|
32
|
+
export declare function clearProjection(dir?: string): void;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// The SDK-shared credential store — the CLI's single source of truth.
|
|
2
|
+
//
|
|
3
|
+
// dreamlake-py resolves its connection from two files under ~/.dreamlake:
|
|
4
|
+
//
|
|
5
|
+
// tokens.json { "dreamlake-token": "<jwt>" } (the token slot)
|
|
6
|
+
// config.json { "remote_url", "namespace", (connection +
|
|
7
|
+
// "device_secret", ... } machine identity)
|
|
8
|
+
//
|
|
9
|
+
// This CLI reads the SAME files on every command, so the CLI and the SDK
|
|
10
|
+
// can never disagree about which server/token is in effect. The multi-env
|
|
11
|
+
// cache (credentials.ts) sits only on the WRITE path: `login` and
|
|
12
|
+
// `env use` project the chosen environment's (token, server, namespace)
|
|
13
|
+
// here as one atomic pair-write. Nothing ever reads the cache to answer
|
|
14
|
+
// "what am I connected to".
|
|
15
|
+
//
|
|
16
|
+
// namespace is a CLI-side extra the SDK ignores (it takes namespace from
|
|
17
|
+
// /auth/me); it lives in config.json so a projection replaces the whole
|
|
18
|
+
// connection consistently. `bss_url` used to sit here too — nothing read
|
|
19
|
+
// it, on either side: dreamlake-py's Config only ever exposed remote_url.
|
|
20
|
+
//
|
|
21
|
+
// NOTE for dreamlake-py: its storage chain prefers the OS keyring when the
|
|
22
|
+
// `keyring` package is installed, which would bypass tokens.json. The two
|
|
23
|
+
// repos standardize on the file store — see docs. Do not "fix" that by
|
|
24
|
+
// writing the keyring from here.
|
|
25
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, writeFileSync, } from "node:fs";
|
|
26
|
+
import { homedir } from "node:os";
|
|
27
|
+
import path from "node:path";
|
|
28
|
+
/** The token slot `dreamlake login` (py) writes and `_session.py` reads. */
|
|
29
|
+
export const TOKEN_SLOT = "dreamlake-token";
|
|
30
|
+
/** `~/.dreamlake` — shared with dreamlake-py. Fixed, no XDG (py has none). */
|
|
31
|
+
export function dreamlakeDir() {
|
|
32
|
+
return path.join(homedir(), ".dreamlake");
|
|
33
|
+
}
|
|
34
|
+
export function tokensPath(dir) {
|
|
35
|
+
return path.join(dir ?? dreamlakeDir(), "tokens.json");
|
|
36
|
+
}
|
|
37
|
+
export function configPath(dir) {
|
|
38
|
+
return path.join(dir ?? dreamlakeDir(), "config.json");
|
|
39
|
+
}
|
|
40
|
+
function readJson(p) {
|
|
41
|
+
if (!existsSync(p))
|
|
42
|
+
return {};
|
|
43
|
+
try {
|
|
44
|
+
const parsed = JSON.parse(readFileSync(p, "utf8"));
|
|
45
|
+
return parsed && typeof parsed === "object" ? parsed : {};
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return {};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** Atomic replace: write sibling temp file, chmod 600, rename over. */
|
|
52
|
+
function writeJson(p, data) {
|
|
53
|
+
const dir = path.dirname(p);
|
|
54
|
+
if (!existsSync(dir))
|
|
55
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
56
|
+
const tmp = path.join(dir, `.${path.basename(p)}.tmp-${process.pid}`);
|
|
57
|
+
writeFileSync(tmp, JSON.stringify(data, null, 2) + "\n", { mode: 0o600 });
|
|
58
|
+
chmodSync(tmp, 0o600);
|
|
59
|
+
renameSync(tmp, p);
|
|
60
|
+
}
|
|
61
|
+
// ─── reads (the resolvers in config.ts sit on top of these) ──────────
|
|
62
|
+
/** Token from tokens.json, or null. */
|
|
63
|
+
export function readToken(dir) {
|
|
64
|
+
const v = readJson(tokensPath(dir))[TOKEN_SLOT];
|
|
65
|
+
return typeof v === "string" && v.length > 0 ? v : null;
|
|
66
|
+
}
|
|
67
|
+
export function readConfig(dir) {
|
|
68
|
+
return readJson(configPath(dir));
|
|
69
|
+
}
|
|
70
|
+
/** Merge keys into config.json (a `undefined` value deletes the key). */
|
|
71
|
+
export function updateConfig(patch, dir) {
|
|
72
|
+
const cfg = readConfig(dir);
|
|
73
|
+
for (const [k, v] of Object.entries(patch)) {
|
|
74
|
+
if (v === undefined)
|
|
75
|
+
delete cfg[k];
|
|
76
|
+
else
|
|
77
|
+
cfg[k] = v;
|
|
78
|
+
}
|
|
79
|
+
writeJson(configPath(dir), cfg);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Make `env` the effective connection: token into the tokens.json slot,
|
|
83
|
+
* server/namespace into config.json. Always writes the full set —
|
|
84
|
+
* a projection that changed the token but kept the old remote_url would
|
|
85
|
+
* aim one environment's token at another's server.
|
|
86
|
+
*/
|
|
87
|
+
export function projectEnv(env, dir) {
|
|
88
|
+
const tokens = readJson(tokensPath(dir));
|
|
89
|
+
tokens[TOKEN_SLOT] = env.token;
|
|
90
|
+
writeJson(tokensPath(dir), tokens);
|
|
91
|
+
updateConfig({
|
|
92
|
+
remote_url: env.server.replace(/\/+$/, ""),
|
|
93
|
+
namespace: env.namespace || undefined,
|
|
94
|
+
}, dir);
|
|
95
|
+
}
|
|
96
|
+
/** Remove the connection (logout with no env left). Keeps device_secret. */
|
|
97
|
+
export function clearProjection(dir) {
|
|
98
|
+
const tokens = readJson(tokensPath(dir));
|
|
99
|
+
delete tokens[TOKEN_SLOT];
|
|
100
|
+
writeJson(tokensPath(dir), tokens);
|
|
101
|
+
updateConfig({ remote_url: undefined, namespace: undefined }, dir);
|
|
102
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** The pre-consolidation config dir (XDG-aware, like the old configDir()). */
|
|
2
|
+
export declare function legacyConfigDir(): string;
|
|
3
|
+
/**
|
|
4
|
+
* Migrate legacy state into `newDir` (default ~/.dreamlake). Safe to call
|
|
5
|
+
* on every startup. Returns the list of items migrated (for the notice).
|
|
6
|
+
*/
|
|
7
|
+
export declare function migrateLegacyConfig(opts?: {
|
|
8
|
+
legacyDir?: string;
|
|
9
|
+
newDir?: string;
|
|
10
|
+
}): string[];
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// One-time consolidation of the legacy config directory.
|
|
2
|
+
//
|
|
3
|
+
// Older releases kept CLI state at $XDG_CONFIG_HOME/dreamlake (default
|
|
4
|
+
// ~/.config/dreamlake): auth.yml, settings.yml, and a device_secret file.
|
|
5
|
+
// Everything now lives in ~/.dreamlake next to the SDK's files:
|
|
6
|
+
//
|
|
7
|
+
// auth.yml → ~/.dreamlake/auth.yml (multi-env cache)
|
|
8
|
+
// settings.yml → ~/.dreamlake/settings.yml (release channel)
|
|
9
|
+
// device_secret → `device_secret` key in ~/.dreamlake/config.json
|
|
10
|
+
// (dreamlake-py's location — one machine identity
|
|
11
|
+
// for both tools)
|
|
12
|
+
//
|
|
13
|
+
// Runs at CLI entry, is idempotent, and never overwrites a file that
|
|
14
|
+
// already exists at the destination.
|
|
15
|
+
import { existsSync, chmodSync, copyFileSync, readdirSync, readFileSync, rmdirSync, rmSync, } from "node:fs";
|
|
16
|
+
import { homedir } from "node:os";
|
|
17
|
+
import path from "node:path";
|
|
18
|
+
import { dreamlakeDir, readConfig, updateConfig } from "./materialized.js";
|
|
19
|
+
/** The pre-consolidation config dir (XDG-aware, like the old configDir()). */
|
|
20
|
+
export function legacyConfigDir() {
|
|
21
|
+
const xdg = process.env.XDG_CONFIG_HOME;
|
|
22
|
+
const base = xdg && path.isAbsolute(xdg) ? xdg : path.join(homedir(), ".config");
|
|
23
|
+
return path.join(base, "dreamlake");
|
|
24
|
+
}
|
|
25
|
+
/** Move one file if the destination doesn't exist yet. Returns true if moved. */
|
|
26
|
+
function moveFile(from, to, mode) {
|
|
27
|
+
if (!existsSync(from))
|
|
28
|
+
return false;
|
|
29
|
+
if (!existsSync(to)) {
|
|
30
|
+
copyFileSync(from, to);
|
|
31
|
+
if (mode !== undefined)
|
|
32
|
+
chmodSync(to, mode);
|
|
33
|
+
}
|
|
34
|
+
rmSync(from);
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Migrate legacy state into `newDir` (default ~/.dreamlake). Safe to call
|
|
39
|
+
* on every startup. Returns the list of items migrated (for the notice).
|
|
40
|
+
*/
|
|
41
|
+
export function migrateLegacyConfig(opts = {}) {
|
|
42
|
+
const legacy = opts.legacyDir ?? legacyConfigDir();
|
|
43
|
+
if (!existsSync(legacy))
|
|
44
|
+
return [];
|
|
45
|
+
const dest = opts.newDir ?? dreamlakeDir();
|
|
46
|
+
const moved = [];
|
|
47
|
+
if (moveFile(path.join(legacy, "auth.yml"), path.join(dest, "auth.yml"), 0o600)) {
|
|
48
|
+
moved.push("auth.yml");
|
|
49
|
+
}
|
|
50
|
+
if (moveFile(path.join(legacy, "settings.yml"), path.join(dest, "settings.yml"))) {
|
|
51
|
+
moved.push("settings.yml");
|
|
52
|
+
}
|
|
53
|
+
const secretFile = path.join(legacy, "device_secret");
|
|
54
|
+
if (existsSync(secretFile)) {
|
|
55
|
+
const secret = readFileSync(secretFile, "utf8").trim();
|
|
56
|
+
// config.json's existing identity wins — it's the one dreamlake-py has
|
|
57
|
+
// been presenting; the file was this CLI's private copy.
|
|
58
|
+
if (secret && !readConfig(dest).device_secret) {
|
|
59
|
+
updateConfig({ device_secret: secret }, dest);
|
|
60
|
+
}
|
|
61
|
+
rmSync(secretFile);
|
|
62
|
+
moved.push("device_secret");
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
if (readdirSync(legacy).length === 0)
|
|
66
|
+
rmdirSync(legacy);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// leave a non-empty or unreadable dir alone
|
|
70
|
+
}
|
|
71
|
+
if (moved.length > 0) {
|
|
72
|
+
process.stderr.write(`(migrated ${moved.join(", ")} from ${legacy} to ${dest})\n`);
|
|
73
|
+
}
|
|
74
|
+
return moved;
|
|
75
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export declare class HttpError extends Error {
|
|
2
|
+
status: number;
|
|
3
|
+
body: string;
|
|
4
|
+
/**
|
|
5
|
+
* The typed fields of a Source v1 error envelope, absent on every other
|
|
6
|
+
* shape.
|
|
7
|
+
*
|
|
8
|
+
* Kept as fields rather than folded into the message because they are what a
|
|
9
|
+
* caller BRANCHES on. `code` is the stable identity of a failure — the
|
|
10
|
+
* message is a human sentence the server is free to reword — and `retryable`
|
|
11
|
+
* is the server's own answer to "would repeating this identical request
|
|
12
|
+
* help", which no client can derive from a status alone: a 503 from a rate
|
|
13
|
+
* limiter and a 503 from a misconfigured binding look the same on the wire.
|
|
14
|
+
*
|
|
15
|
+
* `undefined` means "this response was not a v1 envelope", never "the server
|
|
16
|
+
* said no". A caller that must fail closed has to treat undefined as
|
|
17
|
+
* unknown rather than as false.
|
|
18
|
+
*/
|
|
19
|
+
code?: string;
|
|
20
|
+
retryable?: boolean;
|
|
21
|
+
requestId?: string;
|
|
22
|
+
constructor(status: number, body: string);
|
|
23
|
+
/**
|
|
24
|
+
* Pull a human message, and any typed fields, out of an error body.
|
|
25
|
+
*
|
|
26
|
+
* Three shapes reach here and they are not variations of one another:
|
|
27
|
+
*
|
|
28
|
+
* Source v1 {"error": {"code", "message", "retryable", "requestId"}}
|
|
29
|
+
* legacy flat {"error": "..."} or {"message": "..."}
|
|
30
|
+
* not JSON an HTML 404 page, a proxy's plain-text 502
|
|
31
|
+
*
|
|
32
|
+
* The v1 branch is tested FIRST and by type, not by presence. Both envelopes
|
|
33
|
+
* key on `error`, so the old `if (parsed.error) return parsed.error` matched
|
|
34
|
+
* the v1 object too and interpolated it — a real defect, measured before this
|
|
35
|
+
* was written: a 503 carrying a code, a message and a requestId rendered as
|
|
36
|
+
* `(503) [object Object]`, and the three fields a caller could have acted on
|
|
37
|
+
* were gone. Ordering alone does not prevent that; the `typeof` check is what
|
|
38
|
+
* does, because it is the only thing that distinguishes the two.
|
|
39
|
+
*/
|
|
40
|
+
private static parse;
|
|
41
|
+
}
|
|
42
|
+
export interface RequestOpts {
|
|
43
|
+
method?: "GET" | "POST" | "PATCH" | "DELETE" | "PUT";
|
|
44
|
+
/** JSON body — serialized and sent with Content-Type: application/json. */
|
|
45
|
+
json?: unknown;
|
|
46
|
+
/**
|
|
47
|
+
* Raw body, sent exactly as given.
|
|
48
|
+
*
|
|
49
|
+
* For uploads. Mutually exclusive with `json`, and deliberately typed as
|
|
50
|
+
* bytes rather than `unknown`: anything that went through a string on the
|
|
51
|
+
* way out would corrupt every file that is not valid UTF-8, and would do it
|
|
52
|
+
* without an error.
|
|
53
|
+
*/
|
|
54
|
+
body?: Uint8Array | Blob | FormData | ReadableStream<Uint8Array> | import("node:stream").Readable;
|
|
55
|
+
/** Query params — undefined/null values are skipped. */
|
|
56
|
+
query?: Record<string, string | number | boolean | undefined | null>;
|
|
57
|
+
/** Bearer token. Omit for unauthenticated endpoints (e.g. some BSS routes). */
|
|
58
|
+
token?: string | null;
|
|
59
|
+
/** Extra headers. */
|
|
60
|
+
headers?: Record<string, string>;
|
|
61
|
+
/** Observe response headers before body parsing, including uncertain error bodies. */
|
|
62
|
+
onHeaders?: (headers: Headers) => void;
|
|
63
|
+
/** Per-request timeout in ms (default 30000). */
|
|
64
|
+
timeoutMs?: number;
|
|
65
|
+
/** Cancel an in-flight request, for foreground sessions shutting down. */
|
|
66
|
+
signal?: AbortSignal;
|
|
67
|
+
/** Fetch redirect policy. Use "error" when a JSON body carries credentials. */
|
|
68
|
+
redirect?: RequestInit["redirect"];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Issue a request and parse a JSON response. Throws HttpError on non-2xx.
|
|
72
|
+
* Returns the parsed JSON (or `undefined` for empty bodies).
|
|
73
|
+
*/
|
|
74
|
+
export declare function requestJson<T = unknown>(base: string, path: string, opts?: RequestOpts): Promise<T>;
|
|
75
|
+
/**
|
|
76
|
+
* GET a raw Response (for streaming downloads). Throws HttpError on non-2xx.
|
|
77
|
+
*
|
|
78
|
+
* `timeoutMs` bounds the whole exchange, body included — which is the wrong
|
|
79
|
+
* shape for a large download, where a healthy transfer legitimately runs
|
|
80
|
+
* longer than any fixed deadline. Callers streaming big files should pass
|
|
81
|
+
* their own `signal` driven by an idle watchdog instead.
|
|
82
|
+
*
|
|
83
|
+
* `followRedirects: false` is for requests carrying a secret in a header.
|
|
84
|
+
* Measured on Node 26: a custom header on a request that is redirected to a
|
|
85
|
+
* DIFFERENT origin is forwarded verbatim. `Authorization` gets stripped
|
|
86
|
+
* cross-origin, nothing else does — so a capability's `allowedHeaders`, which
|
|
87
|
+
* are bearer secrets, would be handed to whatever host the redirect names.
|
|
88
|
+
*/
|
|
89
|
+
export declare function requestRaw(url: string, opts?: {
|
|
90
|
+
/**
|
|
91
|
+
* The verb, when the caller was given one. A signature covers the method,
|
|
92
|
+
* so a capability that names it must be issued with it rather than with a
|
|
93
|
+
* hard-coded GET.
|
|
94
|
+
*/
|
|
95
|
+
method?: "GET" | "HEAD";
|
|
96
|
+
token?: string | null;
|
|
97
|
+
timeoutMs?: number;
|
|
98
|
+
headers?: Record<string, string>;
|
|
99
|
+
signal?: AbortSignal;
|
|
100
|
+
/** Default true. Set false when a header on this request is a secret. */
|
|
101
|
+
followRedirects?: boolean;
|
|
102
|
+
}): Promise<Response>;
|