@zivis/mcp 0.1.8 → 0.1.10
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/LICENSE +201 -0
- package/README.md +19 -0
- package/dist/api-client.d.ts +2 -24
- package/dist/api-client.js +32 -52
- package/dist/auth/index.d.ts +1 -22
- package/dist/auth/index.js +17 -38
- package/dist/auth/jwt.d.ts +0 -16
- package/dist/auth/jwt.js +0 -13
- package/dist/auth/keychain.d.ts +6 -32
- package/dist/auth/keychain.js +83 -114
- package/dist/auth/oauth.d.ts +3 -32
- package/dist/auth/oauth.js +67 -61
- package/dist/auth/sessions.d.ts +5 -25
- package/dist/auth/sessions.js +20 -39
- package/dist/auth/token-refresh.d.ts +2 -22
- package/dist/auth/token-refresh.js +33 -36
- package/dist/cli.d.ts +1 -18
- package/dist/cli.js +30 -908
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -7
- package/dist/lib/inspect-cache.d.ts +10 -0
- package/dist/lib/inspect-cache.js +75 -0
- package/dist/lib/next-steps.d.ts +27 -0
- package/dist/lib/next-steps.js +21 -0
- package/dist/matcher/ast-eval.d.ts +8 -0
- package/dist/matcher/ast-eval.js +95 -0
- package/dist/matcher/finding.d.ts +55 -0
- package/dist/matcher/finding.js +1 -0
- package/dist/matcher/index.d.ts +8 -0
- package/dist/matcher/index.js +202 -0
- package/dist/matcher/inference-candidates.d.ts +26 -0
- package/dist/matcher/inference-candidates.js +81 -0
- package/dist/matcher/walker.d.ts +7 -0
- package/dist/matcher/walker.js +71 -0
- package/dist/pattern-pack/index.d.ts +125 -0
- package/dist/pattern-pack/index.js +189 -0
- package/dist/pattern-packs/zivis-public-0.2.0/capsules/agents/privilege-separation.yaml +224 -0
- package/dist/pattern-packs/zivis-public-0.2.0/capsules/prompting/self-consistency-no-isolation.yaml +237 -0
- package/dist/pattern-packs/zivis-public-0.2.0/capsules/retrieval/context-injection-no-validator.yaml +348 -0
- package/dist/pattern-packs/zivis-public-0.2.0/capsules/security/late-org-filter.yaml +266 -0
- package/dist/pattern-packs/zivis-public-0.2.0/controls/external_validator_on_facts.yaml +37 -0
- package/dist/pattern-packs/zivis-public-0.2.0/controls/fact_validator_present.yaml +68 -0
- package/dist/pattern-packs/zivis-public-0.2.0/controls/human_approval_gate.yaml +44 -0
- package/dist/pattern-packs/zivis-public-0.2.0/controls/langgraph_state_machine_with_per_node_tools.yaml +35 -0
- package/dist/pattern-packs/zivis-public-0.2.0/controls/per_sample_retrieval_diversification.yaml +38 -0
- package/dist/pattern-packs/zivis-public-0.2.0/controls/prisma_extension_or_middleware_attaching_org_filter.yaml +31 -0
- package/dist/pattern-packs/zivis-public-0.2.0/controls/row_level_security_policy.yaml +37 -0
- package/dist/pattern-packs/zivis-public-0.2.0/controls/source_attribution_present.yaml +58 -0
- package/dist/pattern-packs/zivis-public-0.2.0/manifest.json +167 -0
- package/dist/pattern-packs/zivis-public-0.2.0/prompts/agents/privilege-separation/identify.md +54 -0
- package/dist/pattern-packs/zivis-public-0.2.0/prompts/prompting/self-consistency-no-isolation/identify.md +60 -0
- package/dist/pattern-packs/zivis-public-0.2.0/prompts/retrieval/context-injection-no-validator/identify.md +109 -0
- package/dist/pattern-packs/zivis-public-0.2.0/prompts/security/late-org-filter/identify.md +78 -0
- package/dist/project-binding.d.ts +2 -19
- package/dist/project-binding.js +38 -21
- package/dist/prompts/audit-dependencies.d.ts +2 -0
- package/dist/prompts/audit-dependencies.js +47 -0
- package/dist/prompts/getting-started.d.ts +2 -0
- package/dist/prompts/getting-started.js +37 -0
- package/dist/prompts/index.d.ts +2 -0
- package/dist/prompts/index.js +6 -0
- package/dist/resolve-application-id.d.ts +0 -4
- package/dist/resolve-application-id.js +0 -5
- package/dist/sanitize.d.ts +1 -21
- package/dist/sanitize.js +7 -41
- package/dist/server.d.ts +1 -13
- package/dist/server.js +142 -265
- package/dist/tools/artifacts.d.ts +76 -0
- package/dist/tools/artifacts.js +178 -0
- package/dist/tools/check-project.d.ts +5 -18
- package/dist/tools/check-project.js +122 -110
- package/dist/tools/check-repo-trust.d.ts +4 -19
- package/dist/tools/check-repo-trust.js +56 -47
- package/dist/tools/create-diagram.d.ts +0 -5
- package/dist/tools/create-diagram.js +0 -10
- package/dist/tools/create-document.d.ts +0 -5
- package/dist/tools/create-document.js +3 -9
- package/dist/tools/create-finding.d.ts +85 -0
- package/dist/tools/create-finding.js +136 -0
- package/dist/tools/delete-finding.d.ts +19 -0
- package/dist/tools/delete-finding.js +36 -0
- package/dist/tools/devx-run.d.ts +88 -0
- package/dist/tools/devx-run.js +175 -0
- package/dist/tools/discover-local-infra.d.ts +0 -10
- package/dist/tools/discover-local-infra.js +3 -73
- package/dist/tools/enterprise/get-org-zat.d.ts +0 -5
- package/dist/tools/enterprise/get-org-zat.js +0 -6
- package/dist/tools/explain-signal-for-diff.d.ts +34 -0
- package/dist/tools/explain-signal-for-diff.js +75 -0
- package/dist/tools/generate-diagram.d.ts +0 -6
- package/dist/tools/generate-diagram.js +21 -13
- package/dist/tools/get-application-overview.d.ts +0 -5
- package/dist/tools/get-application-overview.js +0 -6
- package/dist/tools/get-application.d.ts +0 -5
- package/dist/tools/get-application.js +0 -6
- package/dist/tools/get-diagram.d.ts +0 -5
- package/dist/tools/get-diagram.js +1 -11
- package/dist/tools/get-document.d.ts +0 -5
- package/dist/tools/get-document.js +0 -6
- package/dist/tools/get-oss-zat.d.ts +0 -5
- package/dist/tools/get-oss-zat.js +0 -7
- package/dist/tools/get-signal.d.ts +24 -0
- package/dist/tools/get-signal.js +75 -0
- package/dist/tools/get-started.d.ts +18 -0
- package/dist/tools/get-started.js +470 -0
- package/dist/tools/get-trust-keys.d.ts +0 -5
- package/dist/tools/get-trust-keys.js +0 -6
- package/dist/tools/import-openapi-endpoints.d.ts +0 -5
- package/dist/tools/import-openapi-endpoints.js +0 -6
- package/dist/tools/inspect-zat.d.ts +0 -5
- package/dist/tools/inspect-zat.js +0 -19
- package/dist/tools/inspect.d.ts +21 -0
- package/dist/tools/inspect.js +222 -0
- package/dist/tools/list-applications.d.ts +1 -6
- package/dist/tools/list-applications.js +0 -6
- package/dist/tools/list-diagrams.d.ts +0 -5
- package/dist/tools/list-diagrams.js +0 -6
- package/dist/tools/list-documents.d.ts +0 -5
- package/dist/tools/list-documents.js +0 -6
- package/dist/tools/list-endpoints.d.ts +1 -6
- package/dist/tools/list-endpoints.js +0 -6
- package/dist/tools/list-signals.d.ts +37 -0
- package/dist/tools/list-signals.js +83 -0
- package/dist/tools/manage-application.d.ts +64 -0
- package/dist/tools/manage-application.js +129 -0
- package/dist/tools/manage-diagram.d.ts +0 -5
- package/dist/tools/manage-diagram.js +0 -16
- package/dist/tools/manage-endpoint-lifecycle.d.ts +80 -0
- package/dist/tools/manage-endpoint-lifecycle.js +180 -0
- package/dist/tools/open-in-ide.d.ts +2 -14
- package/dist/tools/open-in-ide.js +0 -13
- package/dist/tools/review-change.d.ts +34 -0
- package/dist/tools/review-change.js +93 -0
- package/dist/tools/security-memory.d.ts +76 -0
- package/dist/tools/security-memory.js +202 -0
- package/dist/tools/security-review.d.ts +1 -21
- package/dist/tools/security-review.js +8 -108
- package/dist/tools/threat-get-capsule.d.ts +15 -0
- package/dist/tools/threat-get-capsule.js +53 -0
- package/dist/tools/threat-get-inference-prompt.d.ts +15 -0
- package/dist/tools/threat-get-inference-prompt.js +73 -0
- package/dist/tools/threat-list-relevant-capsules.d.ts +17 -0
- package/dist/tools/threat-list-relevant-capsules.js +158 -0
- package/dist/tools/threat-run-matcher.d.ts +17 -0
- package/dist/tools/threat-run-matcher.js +145 -0
- package/dist/tools/update-document.d.ts +0 -5
- package/dist/tools/update-document.js +3 -9
- package/dist/tools/update-endpoint.d.ts +1 -6
- package/dist/tools/update-endpoint.js +0 -7
- package/dist/tools/update-finding.d.ts +61 -0
- package/dist/tools/update-finding.js +80 -0
- package/dist/tools/update-mermaid-source.d.ts +0 -13
- package/dist/tools/update-mermaid-source.js +0 -14
- package/dist/tools/verify-trust-mark.d.ts +0 -5
- package/dist/tools/verify-trust-mark.js +0 -6
- package/dist/types.d.ts +14 -14
- package/dist/types.js +22 -28
- package/package.json +38 -15
- package/dist/api-client.js.map +0 -1
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/jwt.js.map +0 -1
- package/dist/auth/keychain.js.map +0 -1
- package/dist/auth/oauth.js.map +0 -1
- package/dist/auth/sessions.js.map +0 -1
- package/dist/auth/token-refresh.js.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/project-binding.js.map +0 -1
- package/dist/resolve-application-id.js.map +0 -1
- package/dist/sanitize.js.map +0 -1
- package/dist/server.js.map +0 -1
- package/dist/tools/check-project.js.map +0 -1
- package/dist/tools/check-repo-trust.js.map +0 -1
- package/dist/tools/create-diagram.js.map +0 -1
- package/dist/tools/create-document.js.map +0 -1
- package/dist/tools/discover-local-infra.js.map +0 -1
- package/dist/tools/enterprise/capture-evidence.d.ts +0 -54
- package/dist/tools/enterprise/capture-evidence.js +0 -72
- package/dist/tools/enterprise/capture-evidence.js.map +0 -1
- package/dist/tools/enterprise/create-report-ticket.d.ts +0 -34
- package/dist/tools/enterprise/create-report-ticket.js +0 -44
- package/dist/tools/enterprise/create-report-ticket.js.map +0 -1
- package/dist/tools/enterprise/end-pentest-session.d.ts +0 -33
- package/dist/tools/enterprise/end-pentest-session.js +0 -42
- package/dist/tools/enterprise/end-pentest-session.js.map +0 -1
- package/dist/tools/enterprise/generate-report.d.ts +0 -55
- package/dist/tools/enterprise/generate-report.js +0 -111
- package/dist/tools/enterprise/generate-report.js.map +0 -1
- package/dist/tools/enterprise/get-org-zat.js.map +0 -1
- package/dist/tools/enterprise/get-report-status.d.ts +0 -27
- package/dist/tools/enterprise/get-report-status.js +0 -38
- package/dist/tools/enterprise/get-report-status.js.map +0 -1
- package/dist/tools/enterprise/get-threat-model.d.ts +0 -29
- package/dist/tools/enterprise/get-threat-model.js +0 -83
- package/dist/tools/enterprise/get-threat-model.js.map +0 -1
- package/dist/tools/enterprise/list-agents.d.ts +0 -42
- package/dist/tools/enterprise/list-agents.js +0 -95
- package/dist/tools/enterprise/list-agents.js.map +0 -1
- package/dist/tools/enterprise/list-report-issues.d.ts +0 -36
- package/dist/tools/enterprise/list-report-issues.js +0 -50
- package/dist/tools/enterprise/list-report-issues.js.map +0 -1
- package/dist/tools/enterprise/list-threat-models.d.ts +0 -36
- package/dist/tools/enterprise/list-threat-models.js +0 -82
- package/dist/tools/enterprise/list-threat-models.js.map +0 -1
- package/dist/tools/enterprise/manage-actor.d.ts +0 -58
- package/dist/tools/enterprise/manage-actor.js +0 -99
- package/dist/tools/enterprise/manage-actor.js.map +0 -1
- package/dist/tools/enterprise/manage-attack-scenario.d.ts +0 -70
- package/dist/tools/enterprise/manage-attack-scenario.js +0 -89
- package/dist/tools/enterprise/manage-attack-scenario.js.map +0 -1
- package/dist/tools/enterprise/manage-component.d.ts +0 -58
- package/dist/tools/enterprise/manage-component.js +0 -90
- package/dist/tools/enterprise/manage-component.js.map +0 -1
- package/dist/tools/enterprise/manage-data-asset.d.ts +0 -53
- package/dist/tools/enterprise/manage-data-asset.js +0 -90
- package/dist/tools/enterprise/manage-data-asset.js.map +0 -1
- package/dist/tools/enterprise/manage-data-flow.d.ts +0 -57
- package/dist/tools/enterprise/manage-data-flow.js +0 -98
- package/dist/tools/enterprise/manage-data-flow.js.map +0 -1
- package/dist/tools/enterprise/manage-finding.d.ts +0 -69
- package/dist/tools/enterprise/manage-finding.js +0 -106
- package/dist/tools/enterprise/manage-finding.js.map +0 -1
- package/dist/tools/enterprise/manage-security-control.d.ts +0 -59
- package/dist/tools/enterprise/manage-security-control.js +0 -96
- package/dist/tools/enterprise/manage-security-control.js.map +0 -1
- package/dist/tools/enterprise/manage-test-case.d.ts +0 -88
- package/dist/tools/enterprise/manage-test-case.js +0 -119
- package/dist/tools/enterprise/manage-test-case.js.map +0 -1
- package/dist/tools/enterprise/promote-finding-to-issue.d.ts +0 -36
- package/dist/tools/enterprise/promote-finding-to-issue.js +0 -65
- package/dist/tools/enterprise/promote-finding-to-issue.js.map +0 -1
- package/dist/tools/enterprise/publish-report-version.d.ts +0 -34
- package/dist/tools/enterprise/publish-report-version.js +0 -75
- package/dist/tools/enterprise/publish-report-version.js.map +0 -1
- package/dist/tools/enterprise/publish-test-to-library.d.ts +0 -31
- package/dist/tools/enterprise/publish-test-to-library.js +0 -40
- package/dist/tools/enterprise/publish-test-to-library.js.map +0 -1
- package/dist/tools/enterprise/record-test-result.d.ts +0 -67
- package/dist/tools/enterprise/record-test-result.js +0 -75
- package/dist/tools/enterprise/record-test-result.js.map +0 -1
- package/dist/tools/enterprise/start-pentest-session.d.ts +0 -35
- package/dist/tools/enterprise/start-pentest-session.js +0 -50
- package/dist/tools/enterprise/start-pentest-session.js.map +0 -1
- package/dist/tools/enterprise/sync-report-section.d.ts +0 -41
- package/dist/tools/enterprise/sync-report-section.js +0 -79
- package/dist/tools/enterprise/sync-report-section.js.map +0 -1
- package/dist/tools/enterprise/update-report-issue.d.ts +0 -55
- package/dist/tools/enterprise/update-report-issue.js +0 -69
- package/dist/tools/enterprise/update-report-issue.js.map +0 -1
- package/dist/tools/generate-diagram.js.map +0 -1
- package/dist/tools/get-agent-test-results.d.ts +0 -41
- package/dist/tools/get-agent-test-results.js +0 -86
- package/dist/tools/get-agent-test-results.js.map +0 -1
- package/dist/tools/get-application-overview.js.map +0 -1
- package/dist/tools/get-application.js.map +0 -1
- package/dist/tools/get-artifact-content.d.ts +0 -29
- package/dist/tools/get-artifact-content.js +0 -86
- package/dist/tools/get-artifact-content.js.map +0 -1
- package/dist/tools/get-diagram.js.map +0 -1
- package/dist/tools/get-document.js.map +0 -1
- package/dist/tools/get-finding-details.d.ts +0 -28
- package/dist/tools/get-finding-details.js +0 -43
- package/dist/tools/get-finding-details.js.map +0 -1
- package/dist/tools/get-findings.d.ts +0 -57
- package/dist/tools/get-findings.js +0 -103
- package/dist/tools/get-findings.js.map +0 -1
- package/dist/tools/get-oss-zat.js.map +0 -1
- package/dist/tools/get-recon-scan.d.ts +0 -27
- package/dist/tools/get-recon-scan.js +0 -46
- package/dist/tools/get-recon-scan.js.map +0 -1
- package/dist/tools/get-scan-output.d.ts +0 -27
- package/dist/tools/get-scan-output.js +0 -64
- package/dist/tools/get-scan-output.js.map +0 -1
- package/dist/tools/get-scenario-details.d.ts +0 -27
- package/dist/tools/get-scenario-details.js +0 -46
- package/dist/tools/get-scenario-details.js.map +0 -1
- package/dist/tools/get-test-case-results.d.ts +0 -37
- package/dist/tools/get-test-case-results.js +0 -66
- package/dist/tools/get-test-case-results.js.map +0 -1
- package/dist/tools/get-test-details.d.ts +0 -29
- package/dist/tools/get-test-details.js +0 -49
- package/dist/tools/get-test-details.js.map +0 -1
- package/dist/tools/get-trust-keys.js.map +0 -1
- package/dist/tools/import-openapi-endpoints.js.map +0 -1
- package/dist/tools/inspect-zat.js.map +0 -1
- package/dist/tools/list-agent-test-cases.d.ts +0 -41
- package/dist/tools/list-agent-test-cases.js +0 -73
- package/dist/tools/list-agent-test-cases.js.map +0 -1
- package/dist/tools/list-applications.js.map +0 -1
- package/dist/tools/list-diagrams.js.map +0 -1
- package/dist/tools/list-documents.js.map +0 -1
- package/dist/tools/list-endpoints.js.map +0 -1
- package/dist/tools/list-recon-scans.d.ts +0 -36
- package/dist/tools/list-recon-scans.js +0 -74
- package/dist/tools/list-recon-scans.js.map +0 -1
- package/dist/tools/list-scan-artifacts.d.ts +0 -41
- package/dist/tools/list-scan-artifacts.js +0 -63
- package/dist/tools/list-scan-artifacts.js.map +0 -1
- package/dist/tools/list-scans.d.ts +0 -44
- package/dist/tools/list-scans.js +0 -91
- package/dist/tools/list-scans.js.map +0 -1
- package/dist/tools/list-test-library.d.ts +0 -44
- package/dist/tools/list-test-library.js +0 -83
- package/dist/tools/list-test-library.js.map +0 -1
- package/dist/tools/list-test-scenarios.d.ts +0 -31
- package/dist/tools/list-test-scenarios.js +0 -66
- package/dist/tools/list-test-scenarios.js.map +0 -1
- package/dist/tools/local-scan.d.ts +0 -40
- package/dist/tools/local-scan.js +0 -261
- package/dist/tools/local-scan.js.map +0 -1
- package/dist/tools/manage-diagram.js.map +0 -1
- package/dist/tools/open-in-ide.js.map +0 -1
- package/dist/tools/run-test-scenario.d.ts +0 -37
- package/dist/tools/run-test-scenario.js +0 -70
- package/dist/tools/run-test-scenario.js.map +0 -1
- package/dist/tools/scan-pr.d.ts +0 -27
- package/dist/tools/scan-pr.js +0 -51
- package/dist/tools/scan-pr.js.map +0 -1
- package/dist/tools/security-review.js.map +0 -1
- package/dist/tools/setup-red-team-target.d.ts +0 -79
- package/dist/tools/setup-red-team-target.js +0 -430
- package/dist/tools/setup-red-team-target.js.map +0 -1
- package/dist/tools/triage-finding.d.ts +0 -47
- package/dist/tools/triage-finding.js +0 -116
- package/dist/tools/triage-finding.js.map +0 -1
- package/dist/tools/update-document.js.map +0 -1
- package/dist/tools/update-endpoint.js.map +0 -1
- package/dist/tools/update-mermaid-source.js.map +0 -1
- package/dist/tools/verify-trust-mark.js.map +0 -1
- package/dist/types.js.map +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 ZIVIS, Inc.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @zivis/mcp
|
|
2
|
+
|
|
3
|
+
The ZIVIS Model Context Protocol (MCP) server. Exposes ZIVIS's threat modeling, security scanning, and AI red-team tools to AI assistants in your IDE (Cursor, Claude Code, VS Code Copilot, Cline, Windsurf).
|
|
4
|
+
|
|
5
|
+
You usually don't install or invoke this directly — it's the engine behind [`@zivis/cli`](https://www.npmjs.com/package/@zivis/cli). When you run `zivis mcp serve` (or your IDE calls it automatically), this package is what runs.
|
|
6
|
+
|
|
7
|
+
## What is ZIVIS?
|
|
8
|
+
|
|
9
|
+
ZIVIS is an architecture-inspection security platform — it looks at the components in your app, how they connect, and what trust boundaries exist between them. See <https://zivis.ai>.
|
|
10
|
+
|
|
11
|
+
## Use via the CLI
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx @zivis/cli init # interactive setup, configures your IDE's mcp.json
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## License
|
|
18
|
+
|
|
19
|
+
Apache 2.0 — see [`LICENSE`](./LICENSE).
|
package/dist/api-client.d.ts
CHANGED
|
@@ -1,37 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ZIVIS API Client
|
|
3
|
-
*
|
|
4
|
-
* HTTPS client that attaches the appropriate auth header
|
|
5
|
-
* based on the active auth method:
|
|
6
|
-
* - OAuth: Authorization: Bearer <token>
|
|
7
|
-
* - API Key: X-API-Key: <key>
|
|
8
|
-
*
|
|
9
|
-
* Handles 401 responses by attempting token refresh (OAuth)
|
|
10
|
-
* before returning an auth error.
|
|
11
|
-
*/
|
|
12
1
|
import type { ZivisConfig } from "./types.js";
|
|
13
2
|
export declare class ApiClient {
|
|
14
3
|
private config;
|
|
15
4
|
constructor(config?: ZivisConfig);
|
|
16
|
-
|
|
17
|
-
* Build auth headers from current credentials
|
|
18
|
-
*/
|
|
5
|
+
resolveEffectiveConfig(cwd?: string): ZivisConfig;
|
|
19
6
|
private buildAuthHeaders;
|
|
20
|
-
/**
|
|
21
|
-
* Make an authenticated request to the ZIVIS API.
|
|
22
|
-
*
|
|
23
|
-
* Automatically resolves credentials and attaches auth headers.
|
|
24
|
-
* On 401 with OAuth, attempts one token refresh and retries.
|
|
25
|
-
*/
|
|
26
7
|
request<T>(method: string, path: string, body?: unknown): Promise<T>;
|
|
27
8
|
private doRequest;
|
|
28
9
|
get<T>(path: string): Promise<T>;
|
|
29
|
-
/**
|
|
30
|
-
* Fetch a path and return the response as plain text (not JSON).
|
|
31
|
-
* Used for artifact content streaming where the response is not JSON.
|
|
32
|
-
*/
|
|
33
10
|
getText(path: string): Promise<string>;
|
|
34
11
|
patch<T>(path: string, body: unknown): Promise<T>;
|
|
12
|
+
put<T>(path: string, body: unknown): Promise<T>;
|
|
35
13
|
post<T>(path: string, body: unknown): Promise<T>;
|
|
36
14
|
del<T>(path: string): Promise<T>;
|
|
37
15
|
}
|
package/dist/api-client.js
CHANGED
|
@@ -1,24 +1,29 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ZIVIS API Client
|
|
3
|
-
*
|
|
4
|
-
* HTTPS client that attaches the appropriate auth header
|
|
5
|
-
* based on the active auth method:
|
|
6
|
-
* - OAuth: Authorization: Bearer <token>
|
|
7
|
-
* - API Key: X-API-Key: <key>
|
|
8
|
-
*
|
|
9
|
-
* Handles 401 responses by attempting token refresh (OAuth)
|
|
10
|
-
* before returning an auth error.
|
|
11
|
-
*/
|
|
12
1
|
import { resolveAuth } from "./auth/index.js";
|
|
2
|
+
import { detectProjectBinding, resolveConfigFromBinding, resolveMcpSessionForWorkspace, } from "./project-binding.js";
|
|
13
3
|
import { DEFAULT_CONFIG } from "./types.js";
|
|
14
4
|
export class ApiClient {
|
|
15
5
|
config;
|
|
16
6
|
constructor(config = DEFAULT_CONFIG) {
|
|
17
7
|
this.config = config;
|
|
18
8
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
resolveEffectiveConfig(cwd) {
|
|
10
|
+
const ws = this.config.workspacePath ?? cwd ?? process.cwd();
|
|
11
|
+
const detected = detectProjectBinding(ws);
|
|
12
|
+
if (!detected) {
|
|
13
|
+
return this.config;
|
|
14
|
+
}
|
|
15
|
+
const { binding } = detected;
|
|
16
|
+
const fromBinding = resolveConfigFromBinding(ws);
|
|
17
|
+
return {
|
|
18
|
+
...this.config,
|
|
19
|
+
session: resolveMcpSessionForWorkspace(this.config, ws, detected, fromBinding),
|
|
20
|
+
...(binding.apiBaseUrl ? { apiBaseUrl: binding.apiBaseUrl } : {}),
|
|
21
|
+
...(binding.oauthApiUrl ? { oauthApiUrl: binding.oauthApiUrl } : {}),
|
|
22
|
+
...(binding.oauthClientId ? { oauthClientId: binding.oauthClientId } : {}),
|
|
23
|
+
...(binding.keychainPrefix ? { keychainPrefix: binding.keychainPrefix } : {}),
|
|
24
|
+
...(binding.configDir ? { configDir: binding.configDir } : {}),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
22
27
|
buildAuthHeaders(creds) {
|
|
23
28
|
switch (creds.method) {
|
|
24
29
|
case "oauth":
|
|
@@ -29,42 +34,20 @@ export class ApiClient {
|
|
|
29
34
|
return {};
|
|
30
35
|
}
|
|
31
36
|
}
|
|
32
|
-
/**
|
|
33
|
-
* Make an authenticated request to the ZIVIS API.
|
|
34
|
-
*
|
|
35
|
-
* Automatically resolves credentials and attaches auth headers.
|
|
36
|
-
* On 401 with OAuth, attempts one token refresh and retries.
|
|
37
|
-
*/
|
|
38
37
|
async request(method, path, body) {
|
|
39
|
-
const
|
|
38
|
+
const effectiveConfig = this.resolveEffectiveConfig();
|
|
39
|
+
const creds = await resolveAuth(effectiveConfig, "apikey");
|
|
40
40
|
if (creds.method === "none") {
|
|
41
|
-
throw new ApiError("Not authenticated.
|
|
42
|
-
}
|
|
43
|
-
const result = await this.doRequest(method, path, body, creds);
|
|
44
|
-
// If 401 and using OAuth, try refreshing
|
|
45
|
-
if (result.status === 401 && creds.method === "oauth") {
|
|
46
|
-
const freshCreds = await resolveAuth(this.config);
|
|
47
|
-
if (freshCreds.method === "oauth" &&
|
|
48
|
-
freshCreds.accessToken !== creds.accessToken) {
|
|
49
|
-
// Token was refreshed, retry
|
|
50
|
-
const retryResult = await this.doRequest(method, path, body, freshCreds);
|
|
51
|
-
if (retryResult.status === 401) {
|
|
52
|
-
throw new ApiError("Session expired. Run: zivis auth login", 401, "SESSION_EXPIRED");
|
|
53
|
-
}
|
|
54
|
-
if (!retryResult.ok) {
|
|
55
|
-
throw new ApiError(retryResult.errorMessage || "API request failed", retryResult.status, "API_ERROR");
|
|
56
|
-
}
|
|
57
|
-
return retryResult.data;
|
|
58
|
-
}
|
|
59
|
-
throw new ApiError("Session expired. Run: zivis auth login", 401, "SESSION_EXPIRED");
|
|
41
|
+
throw new ApiError("Not authenticated. MCP uses API keys only — run: zivis auth bind (or zivis auth token sk_... --session <name>)", 401, "AUTH_REQUIRED");
|
|
60
42
|
}
|
|
43
|
+
const result = await this.doRequest(method, path, body, creds, effectiveConfig.apiBaseUrl);
|
|
61
44
|
if (!result.ok) {
|
|
62
45
|
throw new ApiError(result.errorMessage || `API request failed: ${method} ${path}`, result.status, "API_ERROR");
|
|
63
46
|
}
|
|
64
47
|
return result.data;
|
|
65
48
|
}
|
|
66
|
-
async doRequest(method, path, body, creds) {
|
|
67
|
-
const url = `${
|
|
49
|
+
async doRequest(method, path, body, creds, apiBaseUrl) {
|
|
50
|
+
const url = `${apiBaseUrl}${path}`;
|
|
68
51
|
const headers = {
|
|
69
52
|
"Content-Type": "application/json",
|
|
70
53
|
"User-Agent": "@zivis-ai/cli",
|
|
@@ -90,25 +73,20 @@ export class ApiClient {
|
|
|
90
73
|
return { ok: true, status: response.status, data };
|
|
91
74
|
}
|
|
92
75
|
catch (err) {
|
|
93
|
-
// Network error
|
|
94
76
|
const message = err instanceof Error ? err.message : "Network request failed";
|
|
95
77
|
throw new ApiError(`Failed to connect to ZIVIS API (${url}): ${message}`, 0, "NETWORK_ERROR");
|
|
96
78
|
}
|
|
97
79
|
}
|
|
98
|
-
// ── Convenience methods ──
|
|
99
80
|
async get(path) {
|
|
100
81
|
return this.request("GET", path);
|
|
101
82
|
}
|
|
102
|
-
/**
|
|
103
|
-
* Fetch a path and return the response as plain text (not JSON).
|
|
104
|
-
* Used for artifact content streaming where the response is not JSON.
|
|
105
|
-
*/
|
|
106
83
|
async getText(path) {
|
|
107
|
-
const
|
|
84
|
+
const effectiveConfig = this.resolveEffectiveConfig();
|
|
85
|
+
const creds = await resolveAuth(effectiveConfig, "apikey");
|
|
108
86
|
if (creds.method === "none") {
|
|
109
|
-
throw new ApiError("Not authenticated.
|
|
87
|
+
throw new ApiError("Not authenticated. MCP uses API keys only — run: zivis auth bind", 401, "AUTH_REQUIRED");
|
|
110
88
|
}
|
|
111
|
-
const url = `${
|
|
89
|
+
const url = `${effectiveConfig.apiBaseUrl}${path}`;
|
|
112
90
|
const headers = {
|
|
113
91
|
"User-Agent": "@zivis-ai/cli",
|
|
114
92
|
...this.buildAuthHeaders(creds),
|
|
@@ -125,6 +103,9 @@ export class ApiClient {
|
|
|
125
103
|
async patch(path, body) {
|
|
126
104
|
return this.request("PATCH", path, body);
|
|
127
105
|
}
|
|
106
|
+
async put(path, body) {
|
|
107
|
+
return this.request("PUT", path, body);
|
|
108
|
+
}
|
|
128
109
|
async post(path, body) {
|
|
129
110
|
return this.request("POST", path, body);
|
|
130
111
|
}
|
|
@@ -142,4 +123,3 @@ export class ApiError extends Error {
|
|
|
142
123
|
this.name = "ApiError";
|
|
143
124
|
}
|
|
144
125
|
}
|
|
145
|
-
//# sourceMappingURL=api-client.js.map
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,29 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auth Orchestrator
|
|
3
|
-
*
|
|
4
|
-
* Resolves credentials using the defined precedence:
|
|
5
|
-
* 1. OS Keychain — OAuth tokens (preferred, user-scoped, auto-refresh)
|
|
6
|
-
* 2. OS Keychain — API key (fallback, org-scoped)
|
|
7
|
-
* 3. ZIVIS_API_KEY env var (CI environments)
|
|
8
|
-
* 4. Not authenticated (tools return auth error with setup instructions)
|
|
9
|
-
*/
|
|
10
1
|
import type { AuthCredentials, AuthMethod, ZivisConfig } from "../types.js";
|
|
11
2
|
export { login } from "./oauth.js";
|
|
12
3
|
export { keychainClearAll, keychainClearSession, getStorageName, getSessionAccount } from "./keychain.js";
|
|
13
|
-
export { keychainStore, keychainRead } from "./keychain.js";
|
|
4
|
+
export { keychainStore, keychainRead, keychainDelete } from "./keychain.js";
|
|
14
5
|
export { loadTokens } from "./token-refresh.js";
|
|
15
6
|
export { loadSessionIndex, saveSessionEntry, removeSessionEntry, listSessions } from "./sessions.js";
|
|
16
|
-
/**
|
|
17
|
-
* Resolve current auth credentials following the precedence chain.
|
|
18
|
-
*
|
|
19
|
-
* IMPORTANT: When config.session is set (ZIVIS_SESSION env var), auth resolution
|
|
20
|
-
* is scoped to that session ONLY. It will NOT fall through to the default session
|
|
21
|
-
* or API key — this prevents accidental cross-tenant data access.
|
|
22
|
-
*
|
|
23
|
-
* @param forceMethod - Override the automatic method selection
|
|
24
|
-
*/
|
|
25
7
|
export declare function resolveAuth(config?: ZivisConfig, forceMethod?: AuthMethod): Promise<AuthCredentials>;
|
|
26
|
-
/**
|
|
27
|
-
* Get a human-readable description of the current auth state
|
|
28
|
-
*/
|
|
29
8
|
export declare function getAuthDescription(config?: ZivisConfig): Promise<string>;
|
package/dist/auth/index.js
CHANGED
|
@@ -1,64 +1,44 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auth Orchestrator
|
|
3
|
-
*
|
|
4
|
-
* Resolves credentials using the defined precedence:
|
|
5
|
-
* 1. OS Keychain — OAuth tokens (preferred, user-scoped, auto-refresh)
|
|
6
|
-
* 2. OS Keychain — API key (fallback, org-scoped)
|
|
7
|
-
* 3. ZIVIS_API_KEY env var (CI environments)
|
|
8
|
-
* 4. Not authenticated (tools return auth error with setup instructions)
|
|
9
|
-
*/
|
|
10
1
|
import { keychainRead } from "./keychain.js";
|
|
11
2
|
import { getValidAccessToken } from "./token-refresh.js";
|
|
12
|
-
import { DEFAULT_CONFIG } from "../types.js";
|
|
3
|
+
import { DEFAULT_CONFIG, credentialStorageFromConfig } from "../types.js";
|
|
13
4
|
export { login } from "./oauth.js";
|
|
14
5
|
export { keychainClearAll, keychainClearSession, getStorageName, getSessionAccount } from "./keychain.js";
|
|
15
|
-
export { keychainStore, keychainRead } from "./keychain.js";
|
|
6
|
+
export { keychainStore, keychainRead, keychainDelete } from "./keychain.js";
|
|
16
7
|
export { loadTokens } from "./token-refresh.js";
|
|
17
8
|
export { loadSessionIndex, saveSessionEntry, removeSessionEntry, listSessions } from "./sessions.js";
|
|
18
|
-
/**
|
|
19
|
-
* Resolve current auth credentials following the precedence chain.
|
|
20
|
-
*
|
|
21
|
-
* IMPORTANT: When config.session is set (ZIVIS_SESSION env var), auth resolution
|
|
22
|
-
* is scoped to that session ONLY. It will NOT fall through to the default session
|
|
23
|
-
* or API key — this prevents accidental cross-tenant data access.
|
|
24
|
-
*
|
|
25
|
-
* @param forceMethod - Override the automatic method selection
|
|
26
|
-
*/
|
|
27
9
|
export async function resolveAuth(config = DEFAULT_CONFIG, forceMethod) {
|
|
28
10
|
const session = config.session;
|
|
29
|
-
|
|
30
|
-
if (forceMethod !== "
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
33
|
-
|
|
11
|
+
const st = credentialStorageFromConfig(config);
|
|
12
|
+
if (forceMethod !== "oauth") {
|
|
13
|
+
const apiKeyAccount = session ? `apikey.${session}` : null;
|
|
14
|
+
if (apiKeyAccount) {
|
|
15
|
+
const sessionApiKey = await keychainRead(apiKeyAccount, st);
|
|
16
|
+
if (sessionApiKey) {
|
|
17
|
+
return { method: "apikey", apiKey: sessionApiKey };
|
|
18
|
+
}
|
|
34
19
|
}
|
|
35
20
|
}
|
|
36
|
-
// 2. ZIVIS_API_KEY env var — always checked, even for named sessions.
|
|
37
|
-
// This is an explicit user action (they set the env var in their MCP config),
|
|
38
|
-
// so it's safe to use regardless of session scope.
|
|
39
21
|
const envKey = process.env.ZIVIS_API_KEY;
|
|
40
22
|
if (envKey) {
|
|
41
23
|
return { method: "apikey", apiKey: envKey };
|
|
42
24
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
25
|
+
if (forceMethod !== "apikey") {
|
|
26
|
+
const accessToken = await getValidAccessToken(config);
|
|
27
|
+
if (accessToken) {
|
|
28
|
+
return { method: "oauth", accessToken };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
46
31
|
if (session) {
|
|
47
32
|
return { method: "none" };
|
|
48
33
|
}
|
|
49
|
-
// 3. API key from keychain (only for default/no-session)
|
|
50
34
|
if (forceMethod !== "oauth") {
|
|
51
|
-
const apiKey = await keychainRead("apikey");
|
|
35
|
+
const apiKey = await keychainRead("apikey", st);
|
|
52
36
|
if (apiKey) {
|
|
53
37
|
return { method: "apikey", apiKey };
|
|
54
38
|
}
|
|
55
39
|
}
|
|
56
|
-
// 4. Not authenticated
|
|
57
40
|
return { method: "none" };
|
|
58
41
|
}
|
|
59
|
-
/**
|
|
60
|
-
* Get a human-readable description of the current auth state
|
|
61
|
-
*/
|
|
62
42
|
export async function getAuthDescription(config = DEFAULT_CONFIG) {
|
|
63
43
|
const creds = await resolveAuth(config);
|
|
64
44
|
switch (creds.method) {
|
|
@@ -70,4 +50,3 @@ export async function getAuthDescription(config = DEFAULT_CONFIG) {
|
|
|
70
50
|
return "Not authenticated";
|
|
71
51
|
}
|
|
72
52
|
}
|
|
73
|
-
//# sourceMappingURL=index.js.map
|
package/dist/auth/jwt.d.ts
CHANGED
|
@@ -1,24 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JWT helpers for local safety checks.
|
|
3
|
-
*
|
|
4
|
-
* The API is the authoritative verifier of JWT signatures. These helpers
|
|
5
|
-
* decode the payload only to read claims locally (org_id, email, sub) so
|
|
6
|
-
* the CLI/MCP server can enforce project-binding guardrails before making
|
|
7
|
-
* any API calls.
|
|
8
|
-
*/
|
|
9
1
|
export interface JwtClaims {
|
|
10
|
-
/** WorkOS user sub (e.g., "user_01HXYZ...") */
|
|
11
2
|
sub?: string;
|
|
12
|
-
/** WorkOS org ID (e.g., "org_01HXYZ...") */
|
|
13
3
|
org_id?: string;
|
|
14
|
-
/** Email (present on id_token, sometimes on access_token) */
|
|
15
4
|
email?: string;
|
|
16
|
-
/** Expiry (unix seconds) */
|
|
17
5
|
exp?: number;
|
|
18
6
|
[key: string]: unknown;
|
|
19
7
|
}
|
|
20
|
-
/**
|
|
21
|
-
* Decode a JWT payload WITHOUT verifying the signature.
|
|
22
|
-
* Returns null if the token is malformed.
|
|
23
|
-
*/
|
|
24
8
|
export declare function decodeJwtPayload(token: string): JwtClaims | null;
|
package/dist/auth/jwt.js
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JWT helpers for local safety checks.
|
|
3
|
-
*
|
|
4
|
-
* The API is the authoritative verifier of JWT signatures. These helpers
|
|
5
|
-
* decode the payload only to read claims locally (org_id, email, sub) so
|
|
6
|
-
* the CLI/MCP server can enforce project-binding guardrails before making
|
|
7
|
-
* any API calls.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Decode a JWT payload WITHOUT verifying the signature.
|
|
11
|
-
* Returns null if the token is malformed.
|
|
12
|
-
*/
|
|
13
1
|
export function decodeJwtPayload(token) {
|
|
14
2
|
try {
|
|
15
3
|
const parts = token.split(".");
|
|
@@ -22,4 +10,3 @@ export function decodeJwtPayload(token) {
|
|
|
22
10
|
return null;
|
|
23
11
|
}
|
|
24
12
|
}
|
|
25
|
-
//# sourceMappingURL=jwt.js.map
|
package/dist/auth/keychain.d.ts
CHANGED
|
@@ -1,34 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
* OS Keychain credential storage
|
|
3
|
-
*
|
|
4
|
-
* Uses native OS CLI commands to store/retrieve credentials securely.
|
|
5
|
-
* No native npm dependencies (no keytar).
|
|
6
|
-
*
|
|
7
|
-
* - macOS: Keychain Services via `security` CLI
|
|
8
|
-
* - Linux: Secret Service API via `secret-tool` CLI
|
|
9
|
-
* - Windows: DPAPI via PowerShell
|
|
10
|
-
*
|
|
11
|
-
* Falls back to encrypted file if keychain CLI is unavailable.
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* Returns the keychain account key for a given session.
|
|
15
|
-
* - No session or undefined → "oauth" (backward compatible)
|
|
16
|
-
* - Named session → "oauth.{session}"
|
|
17
|
-
*/
|
|
1
|
+
import { type CredentialStorage } from "../types.js";
|
|
18
2
|
export declare function getSessionAccount(session?: string): string;
|
|
19
|
-
export declare function keychainStore(account: string, value: string): Promise<void>;
|
|
20
|
-
export declare function keychainRead(account: string): Promise<string | null>;
|
|
21
|
-
export declare function keychainDelete(account: string): Promise<void>;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*/
|
|
25
|
-
export declare function keychainClearSession(session?: string): Promise<void>;
|
|
26
|
-
/**
|
|
27
|
-
* Delete all stored credentials (default OAuth + API key).
|
|
28
|
-
* Does NOT clear named sessions — use keychainClearSession() for those.
|
|
29
|
-
*/
|
|
30
|
-
export declare function keychainClearAll(): Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* Returns the storage mechanism name for display purposes
|
|
33
|
-
*/
|
|
3
|
+
export declare function keychainStore(account: string, value: string, storage?: CredentialStorage): Promise<void>;
|
|
4
|
+
export declare function keychainRead(account: string, storage?: CredentialStorage): Promise<string | null>;
|
|
5
|
+
export declare function keychainDelete(account: string, storage?: CredentialStorage): Promise<void>;
|
|
6
|
+
export declare function keychainClearSession(session?: string, storage?: CredentialStorage): Promise<void>;
|
|
7
|
+
export declare function keychainClearAll(storage?: CredentialStorage): Promise<void>;
|
|
34
8
|
export declare function getStorageName(): string;
|