@zivis/mcp 0.1.0-alpha.26 → 0.1.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-client.d.ts +24 -1
- package/dist/api-client.js +52 -29
- package/dist/api-client.js.map +1 -0
- package/dist/auth/index.d.ts +22 -1
- package/dist/auth/index.js +38 -17
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/jwt.d.ts +16 -0
- package/dist/auth/jwt.js +13 -0
- package/dist/auth/jwt.js.map +1 -0
- package/dist/auth/keychain.d.ts +32 -6
- package/dist/auth/keychain.js +114 -83
- package/dist/auth/keychain.js.map +1 -0
- package/dist/auth/oauth.d.ts +37 -2
- package/dist/auth/oauth.js +48 -38
- package/dist/auth/oauth.js.map +1 -0
- package/dist/auth/sessions.d.ts +25 -5
- package/dist/auth/sessions.js +39 -20
- package/dist/auth/sessions.js.map +1 -0
- package/dist/auth/token-refresh.d.ts +22 -2
- package/dist/auth/token-refresh.js +35 -32
- package/dist/auth/token-refresh.js.map +1 -0
- package/dist/cli.d.ts +18 -1
- package/dist/cli.js +908 -30
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/project-binding.d.ts +19 -2
- package/dist/project-binding.js +21 -38
- package/dist/project-binding.js.map +1 -0
- package/dist/resolve-application-id.d.ts +4 -0
- package/dist/resolve-application-id.js +5 -0
- package/dist/resolve-application-id.js.map +1 -0
- package/dist/sanitize.d.ts +21 -0
- package/dist/sanitize.js +41 -0
- package/dist/sanitize.js.map +1 -0
- package/dist/server.d.ts +13 -1
- package/dist/server.js +247 -122
- package/dist/server.js.map +1 -0
- package/dist/tools/check-project.d.ts +18 -5
- package/dist/tools/check-project.js +110 -122
- package/dist/tools/check-project.js.map +1 -0
- package/dist/tools/check-repo-trust.d.ts +19 -4
- package/dist/tools/check-repo-trust.js +47 -56
- package/dist/tools/check-repo-trust.js.map +1 -0
- package/dist/tools/create-diagram.d.ts +5 -0
- package/dist/tools/create-diagram.js +10 -0
- package/dist/tools/create-diagram.js.map +1 -0
- package/dist/tools/create-document.d.ts +5 -0
- package/dist/tools/create-document.js +6 -0
- package/dist/tools/create-document.js.map +1 -0
- package/dist/tools/discover-local-infra.d.ts +10 -0
- package/dist/tools/discover-local-infra.js +73 -3
- package/dist/tools/discover-local-infra.js.map +1 -0
- package/dist/tools/enterprise/capture-evidence.d.ts +54 -0
- package/dist/tools/enterprise/capture-evidence.js +72 -0
- package/dist/tools/enterprise/capture-evidence.js.map +1 -0
- package/dist/tools/enterprise/create-report-ticket.d.ts +34 -0
- package/dist/tools/enterprise/create-report-ticket.js +44 -0
- package/dist/tools/enterprise/create-report-ticket.js.map +1 -0
- package/dist/tools/enterprise/end-pentest-session.d.ts +33 -0
- package/dist/tools/enterprise/end-pentest-session.js +42 -0
- package/dist/tools/enterprise/end-pentest-session.js.map +1 -0
- package/dist/tools/enterprise/generate-report.d.ts +55 -0
- package/dist/tools/enterprise/generate-report.js +111 -0
- package/dist/tools/enterprise/generate-report.js.map +1 -0
- package/dist/tools/enterprise/get-org-zat.d.ts +5 -0
- package/dist/tools/enterprise/get-org-zat.js +6 -0
- package/dist/tools/enterprise/get-org-zat.js.map +1 -0
- package/dist/tools/enterprise/get-report-status.d.ts +27 -0
- package/dist/tools/enterprise/get-report-status.js +38 -0
- package/dist/tools/enterprise/get-report-status.js.map +1 -0
- package/dist/tools/enterprise/get-threat-model.d.ts +6 -1
- package/dist/tools/enterprise/get-threat-model.js +17 -52
- package/dist/tools/enterprise/get-threat-model.js.map +1 -0
- package/dist/tools/enterprise/list-agents.d.ts +42 -0
- package/dist/tools/enterprise/list-agents.js +95 -0
- package/dist/tools/enterprise/list-agents.js.map +1 -0
- package/dist/tools/enterprise/list-report-issues.d.ts +36 -0
- package/dist/tools/enterprise/list-report-issues.js +50 -0
- package/dist/tools/enterprise/list-report-issues.js.map +1 -0
- package/dist/tools/enterprise/list-threat-models.d.ts +5 -0
- package/dist/tools/enterprise/list-threat-models.js +8 -0
- package/dist/tools/enterprise/list-threat-models.js.map +1 -0
- package/dist/tools/enterprise/manage-actor.d.ts +6 -1
- package/dist/tools/enterprise/manage-actor.js +7 -14
- package/dist/tools/enterprise/manage-actor.js.map +1 -0
- package/dist/tools/enterprise/manage-attack-scenario.d.ts +6 -1
- package/dist/tools/enterprise/manage-attack-scenario.js +7 -13
- package/dist/tools/enterprise/manage-attack-scenario.js.map +1 -0
- package/dist/tools/enterprise/manage-component.d.ts +6 -1
- package/dist/tools/enterprise/manage-component.js +7 -20
- package/dist/tools/enterprise/manage-component.js.map +1 -0
- package/dist/tools/enterprise/manage-data-asset.d.ts +7 -2
- package/dist/tools/enterprise/manage-data-asset.js +7 -17
- package/dist/tools/enterprise/manage-data-asset.js.map +1 -0
- package/dist/tools/enterprise/manage-data-flow.d.ts +7 -2
- package/dist/tools/enterprise/manage-data-flow.js +7 -19
- package/dist/tools/enterprise/manage-data-flow.js.map +1 -0
- package/dist/tools/enterprise/manage-finding.d.ts +69 -0
- package/dist/tools/enterprise/manage-finding.js +106 -0
- package/dist/tools/enterprise/manage-finding.js.map +1 -0
- package/dist/tools/enterprise/manage-security-control.d.ts +6 -1
- package/dist/tools/enterprise/manage-security-control.js +7 -18
- package/dist/tools/enterprise/manage-security-control.js.map +1 -0
- package/dist/tools/enterprise/manage-test-case.d.ts +7 -2
- package/dist/tools/enterprise/manage-test-case.js +6 -8
- package/dist/tools/enterprise/manage-test-case.js.map +1 -0
- package/dist/tools/enterprise/promote-finding-to-issue.d.ts +36 -0
- package/dist/tools/enterprise/promote-finding-to-issue.js +65 -0
- package/dist/tools/enterprise/promote-finding-to-issue.js.map +1 -0
- package/dist/tools/enterprise/publish-report-version.d.ts +34 -0
- package/dist/tools/enterprise/publish-report-version.js +75 -0
- package/dist/tools/enterprise/publish-report-version.js.map +1 -0
- package/dist/tools/enterprise/publish-test-to-library.d.ts +31 -0
- package/dist/tools/enterprise/publish-test-to-library.js +40 -0
- package/dist/tools/enterprise/publish-test-to-library.js.map +1 -0
- package/dist/tools/enterprise/record-test-result.d.ts +67 -0
- package/dist/tools/enterprise/record-test-result.js +75 -0
- package/dist/tools/enterprise/record-test-result.js.map +1 -0
- package/dist/tools/enterprise/start-pentest-session.d.ts +35 -0
- package/dist/tools/enterprise/start-pentest-session.js +50 -0
- package/dist/tools/enterprise/start-pentest-session.js.map +1 -0
- package/dist/tools/enterprise/sync-report-section.d.ts +41 -0
- package/dist/tools/enterprise/sync-report-section.js +79 -0
- package/dist/tools/enterprise/sync-report-section.js.map +1 -0
- package/dist/tools/enterprise/update-report-issue.d.ts +55 -0
- package/dist/tools/enterprise/update-report-issue.js +69 -0
- package/dist/tools/enterprise/update-report-issue.js.map +1 -0
- package/dist/tools/generate-diagram.d.ts +6 -0
- package/dist/tools/generate-diagram.js +9 -0
- package/dist/tools/generate-diagram.js.map +1 -0
- package/dist/tools/get-agent-test-results.d.ts +41 -0
- package/dist/tools/get-agent-test-results.js +86 -0
- package/dist/tools/get-agent-test-results.js.map +1 -0
- package/dist/tools/get-application-overview.d.ts +5 -0
- package/dist/tools/get-application-overview.js +6 -0
- package/dist/tools/get-application-overview.js.map +1 -0
- package/dist/tools/get-application.d.ts +5 -0
- package/dist/tools/get-application.js +6 -0
- package/dist/tools/get-application.js.map +1 -0
- package/dist/tools/get-artifact-content.d.ts +29 -0
- package/dist/tools/get-artifact-content.js +86 -0
- package/dist/tools/get-artifact-content.js.map +1 -0
- package/dist/tools/get-diagram.d.ts +5 -0
- package/dist/tools/get-diagram.js +11 -1
- package/dist/tools/get-diagram.js.map +1 -0
- package/dist/tools/get-document.d.ts +5 -0
- package/dist/tools/get-document.js +6 -0
- package/dist/tools/get-document.js.map +1 -0
- package/dist/tools/get-finding-details.d.ts +28 -0
- package/dist/tools/get-finding-details.js +43 -0
- package/dist/tools/get-finding-details.js.map +1 -0
- package/dist/tools/get-findings.d.ts +57 -0
- package/dist/tools/get-findings.js +103 -0
- package/dist/tools/get-findings.js.map +1 -0
- package/dist/tools/get-oss-zat.d.ts +5 -0
- package/dist/tools/get-oss-zat.js +7 -0
- package/dist/tools/get-oss-zat.js.map +1 -0
- package/dist/tools/get-recon-scan.d.ts +27 -0
- package/dist/tools/get-recon-scan.js +46 -0
- package/dist/tools/get-recon-scan.js.map +1 -0
- package/dist/tools/get-scan-output.d.ts +27 -0
- package/dist/tools/get-scan-output.js +64 -0
- package/dist/tools/get-scan-output.js.map +1 -0
- package/dist/tools/get-scenario-details.d.ts +27 -0
- package/dist/tools/get-scenario-details.js +46 -0
- package/dist/tools/get-scenario-details.js.map +1 -0
- package/dist/tools/get-test-case-results.d.ts +37 -0
- package/dist/tools/get-test-case-results.js +66 -0
- package/dist/tools/get-test-case-results.js.map +1 -0
- package/dist/tools/get-test-details.d.ts +29 -0
- package/dist/tools/get-test-details.js +49 -0
- package/dist/tools/get-test-details.js.map +1 -0
- package/dist/tools/get-trust-keys.d.ts +5 -0
- package/dist/tools/get-trust-keys.js +6 -0
- package/dist/tools/get-trust-keys.js.map +1 -0
- package/dist/tools/import-openapi-endpoints.d.ts +5 -0
- package/dist/tools/import-openapi-endpoints.js +6 -0
- package/dist/tools/import-openapi-endpoints.js.map +1 -0
- package/dist/tools/inspect-zat.d.ts +5 -0
- package/dist/tools/inspect-zat.js +19 -0
- package/dist/tools/inspect-zat.js.map +1 -0
- package/dist/tools/list-agent-test-cases.d.ts +41 -0
- package/dist/tools/list-agent-test-cases.js +73 -0
- package/dist/tools/list-agent-test-cases.js.map +1 -0
- package/dist/tools/list-applications.d.ts +6 -1
- package/dist/tools/list-applications.js +6 -0
- package/dist/tools/list-applications.js.map +1 -0
- package/dist/tools/list-diagrams.d.ts +5 -0
- package/dist/tools/list-diagrams.js +6 -0
- package/dist/tools/list-diagrams.js.map +1 -0
- package/dist/tools/list-documents.d.ts +5 -0
- package/dist/tools/list-documents.js +6 -0
- package/dist/tools/list-documents.js.map +1 -0
- package/dist/tools/list-endpoints.d.ts +5 -0
- package/dist/tools/list-endpoints.js +6 -0
- package/dist/tools/list-endpoints.js.map +1 -0
- package/dist/tools/list-recon-scans.d.ts +36 -0
- package/dist/tools/list-recon-scans.js +74 -0
- package/dist/tools/list-recon-scans.js.map +1 -0
- package/dist/tools/list-scan-artifacts.d.ts +41 -0
- package/dist/tools/list-scan-artifacts.js +63 -0
- package/dist/tools/list-scan-artifacts.js.map +1 -0
- package/dist/tools/list-scans.d.ts +44 -0
- package/dist/tools/list-scans.js +91 -0
- package/dist/tools/list-scans.js.map +1 -0
- package/dist/tools/list-test-library.d.ts +44 -0
- package/dist/tools/list-test-library.js +83 -0
- package/dist/tools/list-test-library.js.map +1 -0
- package/dist/tools/list-test-scenarios.d.ts +31 -0
- package/dist/tools/list-test-scenarios.js +66 -0
- package/dist/tools/list-test-scenarios.js.map +1 -0
- package/dist/tools/local-scan.d.ts +40 -0
- package/dist/tools/local-scan.js +261 -0
- package/dist/tools/local-scan.js.map +1 -0
- package/dist/tools/manage-diagram.d.ts +5 -0
- package/dist/tools/manage-diagram.js +16 -0
- package/dist/tools/manage-diagram.js.map +1 -0
- package/dist/tools/open-in-ide.d.ts +13 -1
- package/dist/tools/open-in-ide.js +13 -0
- package/dist/tools/open-in-ide.js.map +1 -0
- package/dist/tools/run-test-scenario.d.ts +37 -0
- package/dist/tools/run-test-scenario.js +70 -0
- package/dist/tools/run-test-scenario.js.map +1 -0
- package/dist/tools/scan-pr.d.ts +27 -0
- package/dist/tools/scan-pr.js +51 -0
- package/dist/tools/scan-pr.js.map +1 -0
- package/dist/tools/security-review.d.ts +16 -0
- package/dist/tools/security-review.js +77 -63
- package/dist/tools/security-review.js.map +1 -0
- package/dist/tools/setup-red-team-target.d.ts +79 -0
- package/dist/tools/setup-red-team-target.js +430 -0
- package/dist/tools/setup-red-team-target.js.map +1 -0
- package/dist/tools/triage-finding.d.ts +47 -0
- package/dist/tools/triage-finding.js +116 -0
- package/dist/tools/triage-finding.js.map +1 -0
- package/dist/tools/update-document.d.ts +5 -0
- package/dist/tools/update-document.js +6 -0
- package/dist/tools/update-document.js.map +1 -0
- package/dist/tools/update-endpoint.d.ts +5 -0
- package/dist/tools/update-endpoint.js +7 -0
- package/dist/tools/update-endpoint.js.map +1 -0
- package/dist/tools/update-mermaid-source.d.ts +13 -0
- package/dist/tools/update-mermaid-source.js +14 -0
- package/dist/tools/update-mermaid-source.js.map +1 -0
- package/dist/tools/verify-trust-mark.d.ts +5 -0
- package/dist/tools/verify-trust-mark.js +6 -0
- package/dist/tools/verify-trust-mark.js.map +1 -0
- package/dist/types.d.ts +14 -14
- package/dist/types.js +28 -22
- package/dist/types.js.map +1 -0
- package/package.json +4 -24
- package/LICENSE +0 -201
- package/README.md +0 -19
- package/dist/lib/inspect-cache.d.ts +0 -10
- package/dist/lib/inspect-cache.js +0 -75
- package/dist/lib/next-steps.d.ts +0 -27
- package/dist/lib/next-steps.js +0 -21
- package/dist/matcher/ast-eval.d.ts +0 -8
- package/dist/matcher/ast-eval.js +0 -95
- package/dist/matcher/finding.d.ts +0 -55
- package/dist/matcher/finding.js +0 -1
- package/dist/matcher/index.d.ts +0 -8
- package/dist/matcher/index.js +0 -202
- package/dist/matcher/inference-candidates.d.ts +0 -26
- package/dist/matcher/inference-candidates.js +0 -81
- package/dist/matcher/walker.d.ts +0 -7
- package/dist/matcher/walker.js +0 -71
- package/dist/pattern-pack/index.d.ts +0 -125
- package/dist/pattern-pack/index.js +0 -189
- package/dist/pattern-packs/zivis-public-0.2.0/capsules/agents/privilege-separation.yaml +0 -224
- package/dist/pattern-packs/zivis-public-0.2.0/capsules/prompting/self-consistency-no-isolation.yaml +0 -237
- package/dist/pattern-packs/zivis-public-0.2.0/capsules/retrieval/context-injection-no-validator.yaml +0 -348
- package/dist/pattern-packs/zivis-public-0.2.0/capsules/security/late-org-filter.yaml +0 -266
- package/dist/pattern-packs/zivis-public-0.2.0/controls/external_validator_on_facts.yaml +0 -37
- package/dist/pattern-packs/zivis-public-0.2.0/controls/fact_validator_present.yaml +0 -68
- package/dist/pattern-packs/zivis-public-0.2.0/controls/human_approval_gate.yaml +0 -44
- package/dist/pattern-packs/zivis-public-0.2.0/controls/langgraph_state_machine_with_per_node_tools.yaml +0 -35
- package/dist/pattern-packs/zivis-public-0.2.0/controls/per_sample_retrieval_diversification.yaml +0 -38
- package/dist/pattern-packs/zivis-public-0.2.0/controls/prisma_extension_or_middleware_attaching_org_filter.yaml +0 -31
- package/dist/pattern-packs/zivis-public-0.2.0/controls/row_level_security_policy.yaml +0 -37
- package/dist/pattern-packs/zivis-public-0.2.0/controls/source_attribution_present.yaml +0 -58
- package/dist/pattern-packs/zivis-public-0.2.0/manifest.json +0 -167
- package/dist/pattern-packs/zivis-public-0.2.0/prompts/agents/privilege-separation/identify.md +0 -54
- package/dist/pattern-packs/zivis-public-0.2.0/prompts/prompting/self-consistency-no-isolation/identify.md +0 -60
- package/dist/pattern-packs/zivis-public-0.2.0/prompts/retrieval/context-injection-no-validator/identify.md +0 -109
- package/dist/pattern-packs/zivis-public-0.2.0/prompts/security/late-org-filter/identify.md +0 -78
- package/dist/prompts/audit-dependencies.d.ts +0 -2
- package/dist/prompts/audit-dependencies.js +0 -47
- package/dist/prompts/getting-started.d.ts +0 -2
- package/dist/prompts/getting-started.js +0 -37
- package/dist/prompts/index.d.ts +0 -2
- package/dist/prompts/index.js +0 -6
- package/dist/tools/enterprise/get-threat-model-artifact.d.ts +0 -24
- package/dist/tools/enterprise/get-threat-model-artifact.js +0 -68
- package/dist/tools/enterprise/list-attack-scenarios.d.ts +0 -24
- package/dist/tools/enterprise/list-attack-scenarios.js +0 -63
- package/dist/tools/enterprise/list-attack-step-library-tests.d.ts +0 -24
- package/dist/tools/enterprise/list-attack-step-library-tests.js +0 -55
- package/dist/tools/enterprise/list-threat-model-artifacts.d.ts +0 -55
- package/dist/tools/enterprise/list-threat-model-artifacts.js +0 -108
- package/dist/tools/enterprise/list-threat-model-review-items.d.ts +0 -30
- package/dist/tools/enterprise/list-threat-model-review-items.js +0 -54
- package/dist/tools/enterprise/list-threat-model-versions.d.ts +0 -24
- package/dist/tools/enterprise/list-threat-model-versions.js +0 -54
- package/dist/tools/enterprise/manage-threat-model-analysis.d.ts +0 -44
- package/dist/tools/enterprise/manage-threat-model-analysis.js +0 -83
- package/dist/tools/enterprise/manage-threat-model-review.d.ts +0 -38
- package/dist/tools/enterprise/manage-threat-model-review.js +0 -72
- package/dist/tools/get-started.d.ts +0 -18
- package/dist/tools/get-started.js +0 -470
- package/dist/tools/inspect.d.ts +0 -21
- package/dist/tools/inspect.js +0 -222
- package/dist/tools/manage-application.d.ts +0 -64
- package/dist/tools/manage-application.js +0 -129
- package/dist/tools/manage-endpoint-lifecycle.d.ts +0 -80
- package/dist/tools/manage-endpoint-lifecycle.js +0 -180
- package/dist/tools/threat-get-capsule.d.ts +0 -15
- package/dist/tools/threat-get-capsule.js +0 -53
- package/dist/tools/threat-get-inference-prompt.d.ts +0 -15
- package/dist/tools/threat-get-inference-prompt.js +0 -73
- package/dist/tools/threat-guide.d.ts +0 -28
- package/dist/tools/threat-guide.js +0 -175
- package/dist/tools/threat-list-relevant-capsules.d.ts +0 -17
- package/dist/tools/threat-list-relevant-capsules.js +0 -158
- package/dist/tools/threat-run-matcher.d.ts +0 -17
- package/dist/tools/threat-run-matcher.js +0 -145
package/dist/api-client.d.ts
CHANGED
|
@@ -1,12 +1,35 @@
|
|
|
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
|
+
*/
|
|
1
12
|
import type { ZivisConfig } from "./types.js";
|
|
2
13
|
export declare class ApiClient {
|
|
3
14
|
private config;
|
|
4
15
|
constructor(config?: ZivisConfig);
|
|
5
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Build auth headers from current credentials
|
|
18
|
+
*/
|
|
6
19
|
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
|
+
*/
|
|
7
26
|
request<T>(method: string, path: string, body?: unknown): Promise<T>;
|
|
8
27
|
private doRequest;
|
|
9
28
|
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
|
+
*/
|
|
10
33
|
getText(path: string): Promise<string>;
|
|
11
34
|
patch<T>(path: string, body: unknown): Promise<T>;
|
|
12
35
|
post<T>(path: string, body: unknown): Promise<T>;
|
package/dist/api-client.js
CHANGED
|
@@ -1,29 +1,24 @@
|
|
|
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
|
+
*/
|
|
1
12
|
import { resolveAuth } from "./auth/index.js";
|
|
2
|
-
import { detectProjectBinding, resolveConfigFromBinding, resolveMcpSessionForWorkspace, } from "./project-binding.js";
|
|
3
13
|
import { DEFAULT_CONFIG } from "./types.js";
|
|
4
14
|
export class ApiClient {
|
|
5
15
|
config;
|
|
6
16
|
constructor(config = DEFAULT_CONFIG) {
|
|
7
17
|
this.config = config;
|
|
8
18
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
}
|
|
19
|
+
/**
|
|
20
|
+
* Build auth headers from current credentials
|
|
21
|
+
*/
|
|
27
22
|
buildAuthHeaders(creds) {
|
|
28
23
|
switch (creds.method) {
|
|
29
24
|
case "oauth":
|
|
@@ -34,20 +29,42 @@ export class ApiClient {
|
|
|
34
29
|
return {};
|
|
35
30
|
}
|
|
36
31
|
}
|
|
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
|
+
*/
|
|
37
38
|
async request(method, path, body) {
|
|
38
|
-
const
|
|
39
|
-
const creds = await resolveAuth(effectiveConfig, "apikey");
|
|
39
|
+
const creds = await resolveAuth(this.config);
|
|
40
40
|
if (creds.method === "none") {
|
|
41
|
-
throw new ApiError("Not authenticated.
|
|
41
|
+
throw new ApiError("Not authenticated. Run: zivis auth login", 401, "AUTH_REQUIRED");
|
|
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");
|
|
42
60
|
}
|
|
43
|
-
const result = await this.doRequest(method, path, body, creds, effectiveConfig.apiBaseUrl);
|
|
44
61
|
if (!result.ok) {
|
|
45
62
|
throw new ApiError(result.errorMessage || `API request failed: ${method} ${path}`, result.status, "API_ERROR");
|
|
46
63
|
}
|
|
47
64
|
return result.data;
|
|
48
65
|
}
|
|
49
|
-
async doRequest(method, path, body, creds
|
|
50
|
-
const url = `${apiBaseUrl}${path}`;
|
|
66
|
+
async doRequest(method, path, body, creds) {
|
|
67
|
+
const url = `${this.config.apiBaseUrl}${path}`;
|
|
51
68
|
const headers = {
|
|
52
69
|
"Content-Type": "application/json",
|
|
53
70
|
"User-Agent": "@zivis-ai/cli",
|
|
@@ -73,20 +90,25 @@ export class ApiClient {
|
|
|
73
90
|
return { ok: true, status: response.status, data };
|
|
74
91
|
}
|
|
75
92
|
catch (err) {
|
|
93
|
+
// Network error
|
|
76
94
|
const message = err instanceof Error ? err.message : "Network request failed";
|
|
77
95
|
throw new ApiError(`Failed to connect to ZIVIS API (${url}): ${message}`, 0, "NETWORK_ERROR");
|
|
78
96
|
}
|
|
79
97
|
}
|
|
98
|
+
// ── Convenience methods ──
|
|
80
99
|
async get(path) {
|
|
81
100
|
return this.request("GET", path);
|
|
82
101
|
}
|
|
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
|
+
*/
|
|
83
106
|
async getText(path) {
|
|
84
|
-
const
|
|
85
|
-
const creds = await resolveAuth(effectiveConfig, "apikey");
|
|
107
|
+
const creds = await resolveAuth(this.config);
|
|
86
108
|
if (creds.method === "none") {
|
|
87
|
-
throw new ApiError("Not authenticated.
|
|
109
|
+
throw new ApiError("Not authenticated. Run: zivis auth login", 401, "AUTH_REQUIRED");
|
|
88
110
|
}
|
|
89
|
-
const url = `${
|
|
111
|
+
const url = `${this.config.apiBaseUrl}${path}`;
|
|
90
112
|
const headers = {
|
|
91
113
|
"User-Agent": "@zivis-ai/cli",
|
|
92
114
|
...this.buildAuthHeaders(creds),
|
|
@@ -120,3 +142,4 @@ export class ApiError extends Error {
|
|
|
120
142
|
this.name = "ApiError";
|
|
121
143
|
}
|
|
122
144
|
}
|
|
145
|
+
//# sourceMappingURL=api-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,OAAO,SAAS;IACZ,MAAM,CAAc;IAE5B,YAAY,SAAsB,cAAc;QAC9C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACK,gBAAgB,CACtB,KAAsB;QAEtB,QAAQ,KAAK,CAAC,MAAM,EAAE,CAAC;YACrB,KAAK,OAAO;gBACV,OAAO,EAAE,aAAa,EAAE,UAAU,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YAC1D,KAAK,QAAQ;gBAC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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
|
+
*/
|
|
1
10
|
import type { AuthCredentials, AuthMethod, ZivisConfig } from "../types.js";
|
|
2
11
|
export { login } from "./oauth.js";
|
|
3
12
|
export { keychainClearAll, keychainClearSession, getStorageName, getSessionAccount } from "./keychain.js";
|
|
4
|
-
export { keychainStore, keychainRead
|
|
13
|
+
export { keychainStore, keychainRead } from "./keychain.js";
|
|
5
14
|
export { loadTokens } from "./token-refresh.js";
|
|
6
15
|
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
|
+
*/
|
|
7
25
|
export declare function resolveAuth(config?: ZivisConfig, forceMethod?: AuthMethod): Promise<AuthCredentials>;
|
|
26
|
+
/**
|
|
27
|
+
* Get a human-readable description of the current auth state
|
|
28
|
+
*/
|
|
8
29
|
export declare function getAuthDescription(config?: ZivisConfig): Promise<string>;
|
package/dist/auth/index.js
CHANGED
|
@@ -1,44 +1,64 @@
|
|
|
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
|
+
*/
|
|
1
10
|
import { keychainRead } from "./keychain.js";
|
|
2
11
|
import { getValidAccessToken } from "./token-refresh.js";
|
|
3
|
-
import { DEFAULT_CONFIG
|
|
12
|
+
import { DEFAULT_CONFIG } from "../types.js";
|
|
4
13
|
export { login } from "./oauth.js";
|
|
5
14
|
export { keychainClearAll, keychainClearSession, getStorageName, getSessionAccount } from "./keychain.js";
|
|
6
|
-
export { keychainStore, keychainRead
|
|
15
|
+
export { keychainStore, keychainRead } from "./keychain.js";
|
|
7
16
|
export { loadTokens } from "./token-refresh.js";
|
|
8
17
|
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
|
+
*/
|
|
9
27
|
export async function resolveAuth(config = DEFAULT_CONFIG, forceMethod) {
|
|
10
28
|
const session = config.session;
|
|
11
|
-
|
|
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
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
const envKey = process.env.ZIVIS_API_KEY;
|
|
22
|
-
if (envKey) {
|
|
23
|
-
return { method: "apikey", apiKey: envKey };
|
|
24
|
-
}
|
|
29
|
+
// 1. OAuth tokens (unless forced to apikey)
|
|
25
30
|
if (forceMethod !== "apikey") {
|
|
26
31
|
const accessToken = await getValidAccessToken(config);
|
|
27
32
|
if (accessToken) {
|
|
28
33
|
return { method: "oauth", accessToken };
|
|
29
34
|
}
|
|
30
35
|
}
|
|
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
|
+
const envKey = process.env.ZIVIS_API_KEY;
|
|
40
|
+
if (envKey) {
|
|
41
|
+
return { method: "apikey", apiKey: envKey };
|
|
42
|
+
}
|
|
43
|
+
// CROSS-TENANT SAFETY: If a named session is active, do NOT fall through
|
|
44
|
+
// to default keychain credentials. This prevents accidentally using admin tokens
|
|
45
|
+
// when working in a customer's project.
|
|
31
46
|
if (session) {
|
|
32
47
|
return { method: "none" };
|
|
33
48
|
}
|
|
49
|
+
// 3. API key from keychain (only for default/no-session)
|
|
34
50
|
if (forceMethod !== "oauth") {
|
|
35
|
-
const apiKey = await keychainRead("apikey"
|
|
51
|
+
const apiKey = await keychainRead("apikey");
|
|
36
52
|
if (apiKey) {
|
|
37
53
|
return { method: "apikey", apiKey };
|
|
38
54
|
}
|
|
39
55
|
}
|
|
56
|
+
// 4. Not authenticated
|
|
40
57
|
return { method: "none" };
|
|
41
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Get a human-readable description of the current auth state
|
|
61
|
+
*/
|
|
42
62
|
export async function getAuthDescription(config = DEFAULT_CONFIG) {
|
|
43
63
|
const creds = await resolveAuth(config);
|
|
44
64
|
switch (creds.method) {
|
|
@@ -50,3 +70,4 @@ export async function getAuthDescription(config = DEFAULT_CONFIG) {
|
|
|
50
70
|
return "Not authenticated";
|
|
51
71
|
}
|
|
52
72
|
}
|
|
73
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.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MAAM,EAAE,CAAC;IAC5B,CAAC;IAED,yDAAyD;IACzD,IAAI,WAAW,KAAK,OAAO,EAAE,CAAC;QAC5B,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC5C,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;QACtC,CAAC;IACH,CAAC;IAED,uBAAuB;IACvB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAC5B,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,SAAsB,cAAc;IAEpC,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,CAAC;IACxC,QAAQ,KAAK,CAAC,MAAM,EAAE,CAAC;QACrB,KAAK,OAAO;YACV,OAAO,sBAAsB,CAAC;QAChC,KAAK,QAAQ;YACX,OAAO,YAAY,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;QACpG,KAAK,MAAM;YACT,OAAO,mBAAmB,CAAC;IAC/B,CAAC;AACH,CAAC"}
|
package/dist/auth/jwt.d.ts
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
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
|
+
*/
|
|
1
9
|
export interface JwtClaims {
|
|
10
|
+
/** WorkOS user sub (e.g., "user_01HXYZ...") */
|
|
2
11
|
sub?: string;
|
|
12
|
+
/** WorkOS org ID (e.g., "org_01HXYZ...") */
|
|
3
13
|
org_id?: string;
|
|
14
|
+
/** Email (present on id_token, sometimes on access_token) */
|
|
4
15
|
email?: string;
|
|
16
|
+
/** Expiry (unix seconds) */
|
|
5
17
|
exp?: number;
|
|
6
18
|
[key: string]: unknown;
|
|
7
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Decode a JWT payload WITHOUT verifying the signature.
|
|
22
|
+
* Returns null if the token is malformed.
|
|
23
|
+
*/
|
|
8
24
|
export declare function decodeJwtPayload(token: string): JwtClaims | null;
|
package/dist/auth/jwt.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
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
|
+
*/
|
|
1
13
|
export function decodeJwtPayload(token) {
|
|
2
14
|
try {
|
|
3
15
|
const parts = token.split(".");
|
|
@@ -10,3 +22,4 @@ export function decodeJwtPayload(token) {
|
|
|
10
22
|
return null;
|
|
11
23
|
}
|
|
12
24
|
}
|
|
25
|
+
//# sourceMappingURL=jwt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt.js","sourceRoot":"","sources":["../../src/auth/jwt.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAcH;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QACpC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACpE,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAc,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/dist/auth/keychain.d.ts
CHANGED
|
@@ -1,8 +1,34 @@
|
|
|
1
|
-
|
|
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
|
+
*/
|
|
2
18
|
export declare function getSessionAccount(session?: string): string;
|
|
3
|
-
export declare function keychainStore(account: string, value: string
|
|
4
|
-
export declare function keychainRead(account: string
|
|
5
|
-
export declare function keychainDelete(account: string
|
|
6
|
-
|
|
7
|
-
|
|
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
|
+
* Delete credentials for a specific session
|
|
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
|
+
*/
|
|
8
34
|
export declare function getStorageName(): string;
|