toolcraft 0.0.26 → 0.0.33
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/cli.compile-check.js +7 -1
- package/dist/cli.d.ts +9 -1
- package/dist/cli.js +134 -62
- package/dist/design.d.ts +1 -0
- package/dist/design.js +1 -0
- package/dist/error-codes.d.ts +1 -0
- package/dist/error-codes.js +6 -0
- package/dist/error-report.js +99 -29
- package/dist/human-in-loop/approvals-commands.js +2 -1
- package/dist/human-in-loop/runner.js +2 -2
- package/dist/index.d.ts +6 -2
- package/dist/json-schema-converter.js +12 -1
- package/dist/mcp-proxy.js +26 -9
- package/dist/mcp.js +55 -4
- package/dist/renderer.js +1 -1
- package/dist/schema-scope.js +22 -1
- package/dist/sdk.js +51 -3
- package/dist/source-snippet.js +1 -1
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-code.js +5 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/codex.js +10 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/cursor.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/cursor.js +15 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/goose.js +1 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/index.d.ts +1 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/index.js +1 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/opencode.js +5 -0
- package/node_modules/@poe-code/agent-defs/dist/index.d.ts +2 -2
- package/node_modules/@poe-code/agent-defs/dist/index.js +1 -1
- package/node_modules/@poe-code/agent-defs/dist/registry.js +8 -1
- package/node_modules/@poe-code/agent-defs/dist/specifier.js +7 -3
- package/node_modules/@poe-code/agent-defs/dist/types.d.ts +5 -0
- package/node_modules/@poe-code/agent-human-in-loop/dist/providers/osascript.js +7 -1
- package/node_modules/@poe-code/agent-mcp-config/dist/configs.js +6 -0
- package/node_modules/@poe-code/config-mutations/dist/error-codes.d.ts +1 -0
- package/node_modules/@poe-code/config-mutations/dist/error-codes.js +6 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/apply-mutation.js +25 -15
- package/node_modules/@poe-code/config-mutations/dist/formats/json.js +1 -1
- package/node_modules/@poe-code/config-mutations/dist/formats/toml.js +1 -1
- package/node_modules/@poe-code/config-mutations/dist/formats/yaml.js +1 -1
- package/node_modules/@poe-code/config-mutations/dist/fs-utils.js +2 -4
- package/node_modules/@poe-code/config-mutations/dist/template/render.js +1 -1
- package/node_modules/@poe-code/config-mutations/package.json +1 -1
- package/node_modules/@poe-code/process-runner/dist/host/host-execution-env.js +18 -5
- package/node_modules/@poe-code/process-runner/dist/host/host-runner.js +38 -4
- package/node_modules/@poe-code/process-runner/dist/workspace-transfer.js +8 -2
- package/node_modules/@poe-code/task-list/dist/backends/gh-issues-sync.js +18 -7
- package/node_modules/@poe-code/task-list/dist/backends/markdown-dir.js +13 -6
- package/node_modules/@poe-code/task-list/dist/backends/utils.js +15 -10
- package/node_modules/@poe-code/task-list/dist/backends/yaml-file.js +39 -22
- package/node_modules/@poe-code/task-list/dist/move.js +4 -1
- package/node_modules/@poe-code/task-list/dist/open.js +42 -20
- package/node_modules/@poe-code/task-list/dist/state-machine.js +8 -5
- package/node_modules/auth-store/dist/create-secret-store.js +6 -1
- package/node_modules/auth-store/dist/encrypted-file-store.d.ts +1 -1
- package/node_modules/auth-store/dist/encrypted-file-store.js +32 -28
- package/node_modules/auth-store/dist/error-codes.d.ts +1 -0
- package/node_modules/auth-store/dist/error-codes.js +5 -0
- package/node_modules/auth-store/dist/keychain-store.js +23 -8
- package/node_modules/mcp-oauth/dist/client/auth-store-session-store.js +17 -5
- package/node_modules/mcp-oauth/dist/client/authorization-state.js +21 -8
- package/node_modules/mcp-oauth/dist/client/default-oauth-client-provider.js +128 -55
- package/node_modules/mcp-oauth/dist/client/token-endpoint.js +27 -17
- package/node_modules/mcp-oauth/dist/server/jwks-token-verifier.js +43 -22
- package/node_modules/toolcraft-design/README.md +148 -0
- package/node_modules/toolcraft-design/dist/components/catalog.d.ts +26 -0
- package/node_modules/toolcraft-design/dist/components/catalog.js +94 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/index.d.ts +2 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/index.js +1 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/components/footer.js +1 -2
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/components/output-pane.js +16 -19
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/components/stats-pane.js +1 -15
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/demo.js +2 -2
- package/node_modules/toolcraft-design/dist/explorer/theme.js +29 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/index.d.ts +7 -1
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/index.js +4 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/internal/theme-detect.d.ts +1 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/internal/theme-detect.js +28 -6
- package/node_modules/toolcraft-design/dist/internal/theme-state.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/internal/theme-state.js +35 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/theme.d.ts +1 -1
- package/node_modules/toolcraft-design/dist/prompts/theme.js +15 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/parser/frontmatter.js +50 -0
- package/node_modules/toolcraft-design/dist/tokens/brand.d.ts +5 -0
- package/node_modules/toolcraft-design/dist/tokens/brand.js +5 -0
- package/node_modules/toolcraft-design/dist/tokens/colors.d.ts +37 -0
- package/node_modules/toolcraft-design/dist/tokens/colors.js +85 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/tokens/index.d.ts +2 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/tokens/index.js +1 -0
- package/node_modules/toolcraft-design/package.json +42 -0
- package/package.json +10 -6
- package/node_modules/@poe-code/design-system/dist/explorer/theme.js +0 -97
- package/node_modules/@poe-code/design-system/dist/prompts/theme.js +0 -12
- package/node_modules/@poe-code/design-system/dist/tokens/colors.d.ts +0 -35
- package/node_modules/@poe-code/design-system/dist/tokens/colors.js +0 -34
- package/node_modules/@poe-code/design-system/package.json +0 -29
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/acp/components.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/acp/components.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/acp/index.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/acp/index.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/acp/writer.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/acp/writer.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/browser.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/browser.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/color.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/color.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/command-errors.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/command-errors.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/detail-card.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/detail-card.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/help-formatter-plain.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/help-formatter-plain.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/help-formatter.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/help-formatter.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/logger.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/logger.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/symbols.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/symbols.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/table.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/table.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/template.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/template.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/text.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/text.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/ansi.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/ansi.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/buffer.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/buffer.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/components/border.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/components/border.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/components/footer.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/components/output-pane.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/components/stats-pane.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/dashboard.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/dashboard.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/demo.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/demo.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/index.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/index.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/keymap.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/keymap.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/layout.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/layout.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/should-use-dashboard.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/should-use-dashboard.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/snapshot.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/snapshot.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/store.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/store.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/terminal-width.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/terminal-width.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/terminal.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/terminal.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/types.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/types.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/actions.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/actions.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/demo.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/events.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/events.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/filter.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/filter.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/index.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/index.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/jobs.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/jobs.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/keymap.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/keymap.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/layout.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/layout.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/reducer.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/reducer.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/detail.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/detail.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/footer.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/footer.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/header.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/header.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/index.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/index.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/list.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/list.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/modal.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/modal.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/test-fixtures.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/test-fixtures.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/text.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/text.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/runtime.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/runtime.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/runtime.test-helpers.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/runtime.test-helpers.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/state.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/state.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/theme.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/internal/color-support.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/internal/color-support.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/internal/output-format.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/internal/output-format.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/internal/strip-ansi.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/internal/strip-ansi.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/index.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/index.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/cancel.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/cancel.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/intro.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/intro.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/log.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/log.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/note.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/note.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/outro.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/outro.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/spinner.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/spinner.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/static/index.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/static/index.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/static/menu.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/static/menu.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/static/spinner.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/static/spinner.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/ast.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/ast.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/demo-content.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/demo-content.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/index.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/index.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/parser/block.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/parser/block.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/parser/frontmatter.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/parser/inline.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/parser/inline.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/parser.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/parser.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/renderer.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/renderer.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/testing/theme-render-fixture.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/testing/theme-render-fixture.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/tokens/spacing.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/tokens/spacing.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/tokens/typography.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/tokens/typography.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/tokens/widths.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/tokens/widths.js +0 -0
|
@@ -50,7 +50,8 @@ function parseQualifiedId(qualifiedId) {
|
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
function descriptionFromTaskRecord(taskRecord) {
|
|
53
|
-
|
|
53
|
+
const description = getOwnEntry(taskRecord, "description");
|
|
54
|
+
return typeof description === "string" ? description : "";
|
|
54
55
|
}
|
|
55
56
|
function metadataFromTaskRecord(taskRecord) {
|
|
56
57
|
const metadata = Object.create(null);
|
|
@@ -66,8 +67,8 @@ function createTask(list, id, taskRecord, sourcePath) {
|
|
|
66
67
|
list,
|
|
67
68
|
id,
|
|
68
69
|
qualifiedId: `${list}/${id}`,
|
|
69
|
-
name: taskRecord
|
|
70
|
-
state: taskRecord
|
|
70
|
+
name: getOwnEntry(taskRecord, "name"),
|
|
71
|
+
state: getOwnEntry(taskRecord, "state"),
|
|
71
72
|
description: descriptionFromTaskRecord(taskRecord),
|
|
72
73
|
metadata: metadataFromTaskRecord(taskRecord),
|
|
73
74
|
...(sourcePath !== undefined && { sourcePath: path.resolve(sourcePath) })
|
|
@@ -163,18 +164,19 @@ function assertValidStoreRecord(store, filePath) {
|
|
|
163
164
|
if (!isRecord(store)) {
|
|
164
165
|
throw malformedStore(filePath, "store");
|
|
165
166
|
}
|
|
166
|
-
if (store
|
|
167
|
+
if (getOwnEntry(store, "$schema") !== STORE_SCHEMA_ID) {
|
|
167
168
|
throw malformedStore(filePath, "$schema");
|
|
168
169
|
}
|
|
169
|
-
if (store
|
|
170
|
+
if (getOwnEntry(store, "kind") !== STORE_KIND) {
|
|
170
171
|
throw malformedStore(filePath, "kind");
|
|
171
172
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
const version = getOwnEntry(store, "version");
|
|
174
|
+
if (typeof version !== "number" ||
|
|
175
|
+
!Number.isInteger(version) ||
|
|
176
|
+
version !== STORE_VERSION) {
|
|
175
177
|
throw malformedStore(filePath, "version");
|
|
176
178
|
}
|
|
177
|
-
if (!isRecord(store
|
|
179
|
+
if (!isRecord(getOwnEntry(store, "lists"))) {
|
|
178
180
|
throw malformedStore(filePath, "lists");
|
|
179
181
|
}
|
|
180
182
|
}
|
|
@@ -182,31 +184,45 @@ function assertValidTaskRecord(taskRecord, list, id, validStates) {
|
|
|
182
184
|
if (!isRecord(taskRecord)) {
|
|
183
185
|
throw malformedTask(list, id, "task");
|
|
184
186
|
}
|
|
185
|
-
if ("$schema"
|
|
187
|
+
if (hasOwnTaskField(taskRecord, "$schema") && getOwnEntry(taskRecord, "$schema") !== TASK_SCHEMA_ID) {
|
|
186
188
|
throw malformedTask(list, id, "$schema");
|
|
187
189
|
}
|
|
188
|
-
if ("kind"
|
|
190
|
+
if (hasOwnTaskField(taskRecord, "kind") && getOwnEntry(taskRecord, "kind") !== TASK_KIND) {
|
|
189
191
|
throw malformedTask(list, id, "kind");
|
|
190
192
|
}
|
|
191
|
-
if ("version"
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
if (hasOwnTaskField(taskRecord, "version")) {
|
|
194
|
+
const version = getOwnEntry(taskRecord, "version");
|
|
195
|
+
if (typeof version !== "number" ||
|
|
196
|
+
!Number.isInteger(version) ||
|
|
197
|
+
version !== TASK_VERSION) {
|
|
195
198
|
throw malformedTask(list, id, "version");
|
|
196
199
|
}
|
|
197
200
|
}
|
|
198
|
-
|
|
201
|
+
const name = getOwnEntry(taskRecord, "name");
|
|
202
|
+
if (!hasOwnTaskField(taskRecord, "name") ||
|
|
203
|
+
typeof name !== "string" ||
|
|
204
|
+
name.length === 0) {
|
|
199
205
|
throw malformedTask(list, id, "name");
|
|
200
206
|
}
|
|
201
|
-
|
|
207
|
+
const state = getOwnEntry(taskRecord, "state");
|
|
208
|
+
if (!hasOwnTaskField(taskRecord, "state") ||
|
|
209
|
+
typeof state !== "string" ||
|
|
210
|
+
!validStates.has(state)) {
|
|
202
211
|
throw malformedTask(list, id, "state");
|
|
203
212
|
}
|
|
204
|
-
if (
|
|
213
|
+
if (hasOwnTaskField(taskRecord, "description") &&
|
|
214
|
+
typeof getOwnEntry(taskRecord, "description") !== "string") {
|
|
205
215
|
throw malformedTask(list, id, "description");
|
|
206
216
|
}
|
|
207
217
|
}
|
|
218
|
+
function hasOwnTaskField(taskRecord, key) {
|
|
219
|
+
return Object.prototype.hasOwnProperty.call(taskRecord, key);
|
|
220
|
+
}
|
|
221
|
+
function getOwnEntry(record, key) {
|
|
222
|
+
return Object.prototype.hasOwnProperty.call(record, key) ? record[key] : undefined;
|
|
223
|
+
}
|
|
208
224
|
function validateStoreEntries(store, filePath, validStates) {
|
|
209
|
-
const lists = store
|
|
225
|
+
const lists = getOwnEntry(store, "lists");
|
|
210
226
|
if (!isRecord(lists)) {
|
|
211
227
|
throw malformedStore(filePath, "lists");
|
|
212
228
|
}
|
|
@@ -247,10 +263,11 @@ async function readStore(fs, filePath, validStates) {
|
|
|
247
263
|
};
|
|
248
264
|
}
|
|
249
265
|
function getListsRecord(store) {
|
|
250
|
-
|
|
266
|
+
const lists = getOwnEntry(store, "lists");
|
|
267
|
+
return isRecord(lists) ? lists : {};
|
|
251
268
|
}
|
|
252
269
|
function getListRecord(store, list) {
|
|
253
|
-
const listRecord = getListsRecord(store)
|
|
270
|
+
const listRecord = getOwnEntry(getListsRecord(store), list);
|
|
254
271
|
return isRecord(listRecord) ? listRecord : undefined;
|
|
255
272
|
}
|
|
256
273
|
function getTaskRecord(store, list, id) {
|
|
@@ -546,7 +563,7 @@ export async function yamlFileBackend(deps) {
|
|
|
546
563
|
const result = [];
|
|
547
564
|
const listNames = sortStrings(Object.keys(getListsRecord(store)));
|
|
548
565
|
for (const listName of listNames) {
|
|
549
|
-
const listRecord = getListsRecord(store)
|
|
566
|
+
const listRecord = getOwnEntry(getListsRecord(store), listName);
|
|
550
567
|
if (!isRecord(listRecord))
|
|
551
568
|
continue;
|
|
552
569
|
const entries = Object.entries(listRecord)
|
|
@@ -115,7 +115,7 @@ async function applyState(tasks, created, events) {
|
|
|
115
115
|
return task;
|
|
116
116
|
}
|
|
117
117
|
function readOnlySourceOptions(options) {
|
|
118
|
-
if (!("create"
|
|
118
|
+
if (!hasOwnProperty(options, "create")) {
|
|
119
119
|
return options;
|
|
120
120
|
}
|
|
121
121
|
return { ...options, create: false };
|
|
@@ -213,3 +213,6 @@ function createTokenBucket(rate) {
|
|
|
213
213
|
function errorMessage(error) {
|
|
214
214
|
return error instanceof Error ? error.message : String(error);
|
|
215
215
|
}
|
|
216
|
+
function hasOwnProperty(value, key) {
|
|
217
|
+
return Object.prototype.hasOwnProperty.call(value, key);
|
|
218
|
+
}
|
|
@@ -13,48 +13,70 @@ function createDefaultFs() {
|
|
|
13
13
|
return fsPromises;
|
|
14
14
|
}
|
|
15
15
|
export async function openTaskList(options) {
|
|
16
|
-
|
|
16
|
+
const type = getOwnProperty(options, "type");
|
|
17
|
+
switch (type) {
|
|
17
18
|
case "markdown-dir":
|
|
18
19
|
case "yaml-file":
|
|
19
20
|
return openFileBackend(options);
|
|
20
21
|
case "gh-issues":
|
|
21
22
|
return openGhIssuesBackend(options);
|
|
22
23
|
default:
|
|
23
|
-
throw new Error(`Unknown task list backend type "${
|
|
24
|
+
throw new Error(`Unknown task list backend type "${String(type)}".`);
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
async function openFileBackend(options) {
|
|
27
|
-
const
|
|
28
|
-
const
|
|
28
|
+
const type = getOwnProperty(options, "type");
|
|
29
|
+
const factory = backendFactories[type];
|
|
30
|
+
const stateMachine = resolveStateMachine(getOwnProperty(options, "stateMachine"));
|
|
29
31
|
validateMachine(stateMachine);
|
|
30
|
-
const markdownOptions =
|
|
32
|
+
const markdownOptions = type === "markdown-dir" ? options : undefined;
|
|
33
|
+
const defaults = getOwnProperty(options, "defaults");
|
|
31
34
|
const deps = {
|
|
32
|
-
path: options
|
|
35
|
+
path: getOwnProperty(options, "path"),
|
|
33
36
|
defaults: {
|
|
34
|
-
metadata:
|
|
37
|
+
metadata: readDefaultMetadata(defaults)
|
|
35
38
|
},
|
|
36
|
-
singleList: markdownOptions
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
singleList: markdownOptions === undefined
|
|
40
|
+
? undefined
|
|
41
|
+
: getOwnProperty(markdownOptions, "singleList"),
|
|
42
|
+
frontmatterMode: markdownOptions === undefined
|
|
43
|
+
? "strict"
|
|
44
|
+
: (getOwnProperty(markdownOptions, "frontmatterMode") ?? "strict"),
|
|
45
|
+
create: getOwnProperty(options, "create") ?? false,
|
|
46
|
+
fs: getOwnProperty(options, "fs") ?? createDefaultFs(),
|
|
40
47
|
stateMachine
|
|
41
48
|
};
|
|
42
49
|
return factory(deps);
|
|
43
50
|
}
|
|
44
51
|
async function openGhIssuesBackend(options) {
|
|
45
|
-
const
|
|
52
|
+
const auth = getOwnProperty(options, "auth");
|
|
53
|
+
const explicitToken = auth && hasOwnProperty(auth, "token") ? auth.token : undefined;
|
|
46
54
|
const endpoint = resolveEndpoint();
|
|
55
|
+
const defaults = getOwnProperty(options, "defaults");
|
|
47
56
|
return ghIssuesBackend({
|
|
48
|
-
repo: options
|
|
49
|
-
project: options
|
|
50
|
-
filter: options
|
|
51
|
-
state: options
|
|
52
|
-
stateMachine: options
|
|
57
|
+
repo: getOwnProperty(options, "repo"),
|
|
58
|
+
project: getOwnProperty(options, "project"),
|
|
59
|
+
filter: getOwnProperty(options, "filter"),
|
|
60
|
+
state: getOwnProperty(options, "state"),
|
|
61
|
+
stateMachine: getOwnProperty(options, "stateMachine"),
|
|
53
62
|
defaults: {
|
|
54
|
-
metadata:
|
|
63
|
+
metadata: readDefaultMetadata(defaults)
|
|
55
64
|
},
|
|
56
|
-
token,
|
|
65
|
+
token: await resolveAuth({ explicitToken }),
|
|
57
66
|
endpoint,
|
|
58
|
-
fetch: options
|
|
67
|
+
fetch: getOwnProperty(options, "fetch")
|
|
59
68
|
});
|
|
60
69
|
}
|
|
70
|
+
function readDefaultMetadata(defaults) {
|
|
71
|
+
const metadata = defaults === undefined ? undefined : getOwnProperty(defaults, "metadata");
|
|
72
|
+
return isRecord(metadata) ? { ...metadata } : {};
|
|
73
|
+
}
|
|
74
|
+
function getOwnProperty(value, name) {
|
|
75
|
+
return hasOwnProperty(value, name) ? value[name] : undefined;
|
|
76
|
+
}
|
|
77
|
+
function hasOwnProperty(value, name) {
|
|
78
|
+
return Object.prototype.hasOwnProperty.call(value, name);
|
|
79
|
+
}
|
|
80
|
+
function isRecord(value) {
|
|
81
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
82
|
+
}
|
|
@@ -14,27 +14,27 @@ export function validateMachine(machine) {
|
|
|
14
14
|
if (!isRecord(machine)) {
|
|
15
15
|
throw new TypeError("State machine must be an object.");
|
|
16
16
|
}
|
|
17
|
-
if (!isStateList(machine.states)) {
|
|
17
|
+
if (!hasOwnRecordField(machine, "states") || !isStateList(machine.states)) {
|
|
18
18
|
throw new TypeError("State machine states must be a string array.");
|
|
19
19
|
}
|
|
20
20
|
const states = new Set(machine.states);
|
|
21
|
-
if (typeof machine.initial !== "string") {
|
|
21
|
+
if (!hasOwnRecordField(machine, "initial") || typeof machine.initial !== "string") {
|
|
22
22
|
throw new TypeError("State machine initial must be a string.");
|
|
23
23
|
}
|
|
24
24
|
if (!states.has(machine.initial)) {
|
|
25
25
|
throw new Error(`Initial state "${machine.initial}" is not declared.`);
|
|
26
26
|
}
|
|
27
|
-
if (!isRecord(machine.events)) {
|
|
27
|
+
if (!hasOwnRecordField(machine, "events") || !isRecord(machine.events)) {
|
|
28
28
|
throw new TypeError("State machine events must be an object.");
|
|
29
29
|
}
|
|
30
30
|
for (const [eventName, event] of Object.entries(machine.events)) {
|
|
31
31
|
if (!isRecord(event)) {
|
|
32
32
|
throw new TypeError(`Event "${eventName}" must be an object.`);
|
|
33
33
|
}
|
|
34
|
-
if (event.from !== "*" && !isStateList(event.from)) {
|
|
34
|
+
if (!hasOwnRecordField(event, "from") || (event.from !== "*" && !isStateList(event.from))) {
|
|
35
35
|
throw new TypeError(`Event "${eventName}" has an invalid "from" definition.`);
|
|
36
36
|
}
|
|
37
|
-
if (typeof event.to !== "string") {
|
|
37
|
+
if (!hasOwnRecordField(event, "to") || typeof event.to !== "string") {
|
|
38
38
|
throw new TypeError(`Event "${eventName}" target state must be a string.`);
|
|
39
39
|
}
|
|
40
40
|
if (!states.has(event.to)) {
|
|
@@ -49,6 +49,9 @@ export function validateMachine(machine) {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
+
function hasOwnRecordField(record, key) {
|
|
53
|
+
return Object.prototype.hasOwnProperty.call(record, key);
|
|
54
|
+
}
|
|
52
55
|
export function eventsFromState(machine, fromState) {
|
|
53
56
|
const events = [];
|
|
54
57
|
for (const [eventName, event] of Object.entries(machine.events)) {
|
|
@@ -27,7 +27,7 @@ export function createSecretStore(input) {
|
|
|
27
27
|
}
|
|
28
28
|
function resolveBackend(input) {
|
|
29
29
|
const envVar = input.backendEnvVar ?? DEFAULT_BACKEND_ENV_VAR;
|
|
30
|
-
const configuredBackend = input.backend ?? input.env
|
|
30
|
+
const configuredBackend = input.backend ?? getOwnEnvValue(input.env, envVar) ?? getOwnEnvValue(process.env, envVar);
|
|
31
31
|
if (configuredBackend === "keychain") {
|
|
32
32
|
return "keychain";
|
|
33
33
|
}
|
|
@@ -36,3 +36,8 @@ function resolveBackend(input) {
|
|
|
36
36
|
}
|
|
37
37
|
throw new Error(`Unsupported auth store backend: ${configuredBackend}`);
|
|
38
38
|
}
|
|
39
|
+
function getOwnEnvValue(env, key) {
|
|
40
|
+
return env !== undefined && Object.prototype.hasOwnProperty.call(env, key)
|
|
41
|
+
? env[key]
|
|
42
|
+
: undefined;
|
|
43
|
+
}
|
|
@@ -42,6 +42,6 @@ export declare class EncryptedFileStore implements SecretStore {
|
|
|
42
42
|
get(): Promise<string | null>;
|
|
43
43
|
set(value: string): Promise<void>;
|
|
44
44
|
delete(): Promise<void>;
|
|
45
|
-
private
|
|
45
|
+
private assertCredentialPathHasNoSymbolicLinks;
|
|
46
46
|
private getEncryptionKey;
|
|
47
47
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { createCipheriv, createDecipheriv, randomBytes, scrypt } from "node:crypto";
|
|
1
|
+
import { createCipheriv, createDecipheriv, randomBytes, randomUUID, scrypt } from "node:crypto";
|
|
2
2
|
import { promises as fs } from "node:fs";
|
|
3
3
|
import { homedir, hostname, userInfo } from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
5
|
+
import { hasOwnErrorCode } from "./error-codes.js";
|
|
5
6
|
const derivedKeyCache = new Map();
|
|
6
7
|
const ENCRYPTION_ALGORITHM = "aes-256-gcm";
|
|
7
8
|
const ENCRYPTION_VERSION = 1;
|
|
@@ -9,7 +10,6 @@ const ENCRYPTION_KEY_BYTES = 32;
|
|
|
9
10
|
const ENCRYPTION_IV_BYTES = 12;
|
|
10
11
|
const ENCRYPTION_AUTH_TAG_BYTES = 16;
|
|
11
12
|
const ENCRYPTION_FILE_MODE = 0o600;
|
|
12
|
-
let temporaryFileSequence = 0;
|
|
13
13
|
export class EncryptedFileStore {
|
|
14
14
|
fs;
|
|
15
15
|
filePath;
|
|
@@ -35,7 +35,7 @@ export class EncryptedFileStore {
|
|
|
35
35
|
this.getRandomBytes = input.getRandomBytes ?? randomBytes;
|
|
36
36
|
}
|
|
37
37
|
async get() {
|
|
38
|
-
await this.
|
|
38
|
+
await this.assertCredentialPathHasNoSymbolicLinks(this.filePath);
|
|
39
39
|
let rawDocument;
|
|
40
40
|
try {
|
|
41
41
|
rawDocument = await this.fs.readFile(this.filePath, "utf8");
|
|
@@ -69,7 +69,7 @@ export class EncryptedFileStore {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
async set(value) {
|
|
72
|
-
await this.
|
|
72
|
+
await this.assertCredentialPathHasNoSymbolicLinks(this.filePath);
|
|
73
73
|
const key = await this.getEncryptionKey();
|
|
74
74
|
const iv = this.getRandomBytes(ENCRYPTION_IV_BYTES);
|
|
75
75
|
const cipher = createCipheriv(ENCRYPTION_ALGORITHM, key, iv);
|
|
@@ -85,26 +85,29 @@ export class EncryptedFileStore {
|
|
|
85
85
|
ciphertext: ciphertext.toString("base64")
|
|
86
86
|
};
|
|
87
87
|
await this.fs.mkdir(path.dirname(this.filePath), { recursive: true });
|
|
88
|
-
await this.
|
|
89
|
-
const temporaryPath = `${this.filePath}.${process.pid}.${
|
|
88
|
+
await this.assertCredentialPathHasNoSymbolicLinks(this.filePath);
|
|
89
|
+
const temporaryPath = `${this.filePath}.${process.pid}.${randomUUID()}.tmp`;
|
|
90
|
+
let temporaryCreated = false;
|
|
90
91
|
try {
|
|
92
|
+
await this.assertCredentialPathHasNoSymbolicLinks(temporaryPath);
|
|
91
93
|
await this.fs.writeFile(temporaryPath, JSON.stringify(document), {
|
|
92
94
|
encoding: "utf8",
|
|
93
95
|
flag: "wx",
|
|
94
96
|
mode: ENCRYPTION_FILE_MODE
|
|
95
97
|
});
|
|
98
|
+
temporaryCreated = true;
|
|
96
99
|
await this.fs.chmod(temporaryPath, ENCRYPTION_FILE_MODE);
|
|
97
100
|
await this.fs.rename(temporaryPath, this.filePath);
|
|
98
101
|
}
|
|
99
102
|
catch (error) {
|
|
100
|
-
if (!isAlreadyExistsError(error)) {
|
|
103
|
+
if (temporaryCreated || !isAlreadyExistsError(error)) {
|
|
101
104
|
await removeIfPresent(this.fs, temporaryPath).catch(() => undefined);
|
|
102
105
|
}
|
|
103
106
|
throw error;
|
|
104
107
|
}
|
|
105
108
|
}
|
|
106
109
|
async delete() {
|
|
107
|
-
await this.
|
|
110
|
+
await this.assertCredentialPathHasNoSymbolicLinks(this.filePath);
|
|
108
111
|
try {
|
|
109
112
|
await this.fs.unlink(this.filePath);
|
|
110
113
|
}
|
|
@@ -114,8 +117,8 @@ export class EncryptedFileStore {
|
|
|
114
117
|
}
|
|
115
118
|
}
|
|
116
119
|
}
|
|
117
|
-
async
|
|
118
|
-
const resolvedPath = path.resolve(
|
|
120
|
+
async assertCredentialPathHasNoSymbolicLinks(targetPath) {
|
|
121
|
+
const resolvedPath = path.resolve(targetPath);
|
|
119
122
|
const protectedPaths = getProtectedCredentialPaths(resolvedPath, this.symbolicLinkCheckStartPath);
|
|
120
123
|
for (const currentPath of protectedPaths) {
|
|
121
124
|
try {
|
|
@@ -179,12 +182,6 @@ async function removeIfPresent(fileSystem, filePath) {
|
|
|
179
182
|
}
|
|
180
183
|
}
|
|
181
184
|
}
|
|
182
|
-
function isAlreadyExistsError(error) {
|
|
183
|
-
return (typeof error === "object" &&
|
|
184
|
-
error !== null &&
|
|
185
|
-
"code" in error &&
|
|
186
|
-
error.code === "EEXIST");
|
|
187
|
-
}
|
|
188
185
|
function defaultMachineIdentity() {
|
|
189
186
|
return {
|
|
190
187
|
hostname: hostname(),
|
|
@@ -222,19 +219,23 @@ function parseEncryptedDocument(raw) {
|
|
|
222
219
|
if (!isRecord(parsed)) {
|
|
223
220
|
return null;
|
|
224
221
|
}
|
|
225
|
-
|
|
222
|
+
const version = getOwnEntry(parsed, "version");
|
|
223
|
+
const iv = getOwnEntry(parsed, "iv");
|
|
224
|
+
const authTag = getOwnEntry(parsed, "authTag");
|
|
225
|
+
const ciphertext = getOwnEntry(parsed, "ciphertext");
|
|
226
|
+
if (version !== ENCRYPTION_VERSION) {
|
|
226
227
|
return null;
|
|
227
228
|
}
|
|
228
|
-
if (typeof
|
|
229
|
-
typeof
|
|
230
|
-
typeof
|
|
229
|
+
if (typeof iv !== "string" ||
|
|
230
|
+
typeof authTag !== "string" ||
|
|
231
|
+
typeof ciphertext !== "string") {
|
|
231
232
|
return null;
|
|
232
233
|
}
|
|
233
234
|
return {
|
|
234
|
-
version
|
|
235
|
-
iv
|
|
236
|
-
authTag
|
|
237
|
-
ciphertext
|
|
235
|
+
version,
|
|
236
|
+
iv,
|
|
237
|
+
authTag,
|
|
238
|
+
ciphertext
|
|
238
239
|
};
|
|
239
240
|
}
|
|
240
241
|
catch {
|
|
@@ -244,9 +245,12 @@ function parseEncryptedDocument(raw) {
|
|
|
244
245
|
function isRecord(value) {
|
|
245
246
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
246
247
|
}
|
|
248
|
+
function getOwnEntry(record, key) {
|
|
249
|
+
return Object.prototype.hasOwnProperty.call(record, key) ? record[key] : undefined;
|
|
250
|
+
}
|
|
247
251
|
function isNotFoundError(error) {
|
|
248
|
-
return
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
+
return hasOwnErrorCode(error, "ENOENT");
|
|
253
|
+
}
|
|
254
|
+
function isAlreadyExistsError(error) {
|
|
255
|
+
return hasOwnErrorCode(error, "EEXIST");
|
|
252
256
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function hasOwnErrorCode(error: unknown, code: string): boolean;
|
|
@@ -12,8 +12,8 @@ export class KeychainStore {
|
|
|
12
12
|
}
|
|
13
13
|
async get() {
|
|
14
14
|
const result = await this.executeSecurityCommand(["find-generic-password", "-s", this.service, "-a", this.account, "-w"], "read secret from macOS Keychain");
|
|
15
|
-
if (result
|
|
16
|
-
return stripTrailingLineBreak(result
|
|
15
|
+
if (getCommandExitCode(result) === 0) {
|
|
16
|
+
return stripTrailingLineBreak(getCommandOutput(result, "stdout"));
|
|
17
17
|
}
|
|
18
18
|
if (isKeychainEntryNotFound(result)) {
|
|
19
19
|
return null;
|
|
@@ -33,13 +33,13 @@ export class KeychainStore {
|
|
|
33
33
|
"-U",
|
|
34
34
|
"-w"
|
|
35
35
|
], "store secret in macOS Keychain", { stdin: value });
|
|
36
|
-
if (result
|
|
36
|
+
if (getCommandExitCode(result) !== 0) {
|
|
37
37
|
throw createSecurityCliFailure("store secret in macOS Keychain", result);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
async delete() {
|
|
41
41
|
const result = await this.executeSecurityCommand(["delete-generic-password", "-s", this.service, "-a", this.account], "delete secret from macOS Keychain");
|
|
42
|
-
if (result
|
|
42
|
+
if (getCommandExitCode(result) === 0 || isKeychainEntryNotFound(result)) {
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
throw createSecurityCliFailure("delete secret from macOS Keychain", result);
|
|
@@ -121,12 +121,27 @@ function stripTrailingLineBreak(value) {
|
|
|
121
121
|
return value;
|
|
122
122
|
}
|
|
123
123
|
function isKeychainEntryNotFound(result) {
|
|
124
|
-
return result
|
|
124
|
+
return getCommandExitCode(result) === KEYCHAIN_ITEM_NOT_FOUND_EXIT_CODE;
|
|
125
125
|
}
|
|
126
126
|
function createSecurityCliFailure(operation, result) {
|
|
127
|
-
const
|
|
127
|
+
const exitCode = getCommandExitCode(result);
|
|
128
|
+
const details = getCommandOutput(result, "stderr").trim()
|
|
129
|
+
|| getCommandOutput(result, "stdout").trim();
|
|
128
130
|
if (details) {
|
|
129
|
-
return new Error(`Failed to ${operation}: security exited with code ${
|
|
131
|
+
return new Error(`Failed to ${operation}: security exited with code ${exitCode}: ${details}`);
|
|
130
132
|
}
|
|
131
|
-
return new Error(`Failed to ${operation}: security exited with code ${
|
|
133
|
+
return new Error(`Failed to ${operation}: security exited with code ${exitCode}`);
|
|
134
|
+
}
|
|
135
|
+
function getCommandExitCode(result) {
|
|
136
|
+
const value = getOwnEntry(result, "exitCode");
|
|
137
|
+
return typeof value === "number" && Number.isInteger(value) ? value : 1;
|
|
138
|
+
}
|
|
139
|
+
function getCommandOutput(result, key) {
|
|
140
|
+
const value = getOwnEntry(result, key);
|
|
141
|
+
return typeof value === "string" ? value : "";
|
|
142
|
+
}
|
|
143
|
+
function getOwnEntry(record, key) {
|
|
144
|
+
return Object.prototype.hasOwnProperty.call(record, key)
|
|
145
|
+
? record[key]
|
|
146
|
+
: undefined;
|
|
132
147
|
}
|
|
@@ -41,11 +41,13 @@ export function createAuthStoreClientStore(options) {
|
|
|
41
41
|
return null;
|
|
42
42
|
}
|
|
43
43
|
const parsed = JSON.parse(value);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
&&
|
|
48
|
-
|
|
44
|
+
const clientId = isObjectRecord(parsed) ? getOwnString(parsed, "clientId") : undefined;
|
|
45
|
+
if (clientId !== undefined) {
|
|
46
|
+
const client = { clientId };
|
|
47
|
+
if (isObjectRecord(parsed) && Object.prototype.hasOwnProperty.call(parsed, "clientSecret")) {
|
|
48
|
+
client.clientSecret = getOwnEntry(parsed, "clientSecret");
|
|
49
|
+
}
|
|
50
|
+
return client;
|
|
49
51
|
}
|
|
50
52
|
throw new Error("Stored OAuth client must be a JSON object with clientId");
|
|
51
53
|
},
|
|
@@ -98,3 +100,13 @@ function createIssuerSecretStore(issuer, options) {
|
|
|
98
100
|
accountPrefix: "issuer",
|
|
99
101
|
});
|
|
100
102
|
}
|
|
103
|
+
function isObjectRecord(value) {
|
|
104
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
105
|
+
}
|
|
106
|
+
function getOwnEntry(record, key) {
|
|
107
|
+
return Object.prototype.hasOwnProperty.call(record, key) ? record[key] : undefined;
|
|
108
|
+
}
|
|
109
|
+
function getOwnString(record, key) {
|
|
110
|
+
const value = getOwnEntry(record, key);
|
|
111
|
+
return typeof value === "string" ? value : undefined;
|
|
112
|
+
}
|
|
@@ -15,20 +15,33 @@ export function parseAuthorizationState(value) {
|
|
|
15
15
|
try {
|
|
16
16
|
const decoded = Buffer.from(value, "base64url").toString("utf8");
|
|
17
17
|
const parsed = JSON.parse(decoded);
|
|
18
|
-
if (parsed
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
if (!isObjectRecord(parsed)) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const version = getOwnEntry(parsed, "v");
|
|
22
|
+
const nonce = getOwnEntry(parsed, "n");
|
|
23
|
+
const issuer = getOwnEntry(parsed, "i");
|
|
24
|
+
const requireIssuer = getOwnEntry(parsed, "r");
|
|
25
|
+
if (version !== 1
|
|
26
|
+
|| typeof nonce !== "string"
|
|
27
|
+
|| nonce.length === 0
|
|
28
|
+
|| typeof issuer !== "string"
|
|
29
|
+
|| issuer.length === 0
|
|
30
|
+
|| typeof requireIssuer !== "boolean") {
|
|
24
31
|
return null;
|
|
25
32
|
}
|
|
26
33
|
return {
|
|
27
|
-
issuer
|
|
28
|
-
requireIssuer
|
|
34
|
+
issuer,
|
|
35
|
+
requireIssuer,
|
|
29
36
|
};
|
|
30
37
|
}
|
|
31
38
|
catch {
|
|
32
39
|
return null;
|
|
33
40
|
}
|
|
34
41
|
}
|
|
42
|
+
function isObjectRecord(value) {
|
|
43
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
44
|
+
}
|
|
45
|
+
function getOwnEntry(record, key) {
|
|
46
|
+
return Object.prototype.hasOwnProperty.call(record, key) ? record[key] : undefined;
|
|
47
|
+
}
|