@kici-dev/orchestrator 0.0.0 → 0.1.1
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 +661 -0
- package/README.md +1 -6
- package/dist/__test-helpers__/mock-db.d.ts +103 -0
- package/dist/__test-helpers__/mock-ws.d.ts +13 -0
- package/dist/agent/dispatcher.d.ts +231 -0
- package/dist/agent/ownership-tracker.d.ts +46 -0
- package/dist/agent/registry.d.ts +255 -0
- package/dist/agent/token-store.d.ts +96 -0
- package/dist/app.d.ts +234 -0
- package/dist/audit/access-log.d.ts +92 -0
- package/dist/audit/sampling-rate-limiter.d.ts +41 -0
- package/dist/cache/build-coordinator.d.ts +42 -0
- package/dist/cache/dep-cache.d.ts +51 -0
- package/dist/cache/index.d.ts +16 -0
- package/dist/cache/pending-builds.d.ts +14 -0
- package/dist/cache/pending-dynamics.d.ts +15 -0
- package/dist/cache/pending-inits.d.ts +19 -0
- package/dist/cache/pending-tracker.d.ts +65 -0
- package/dist/cache/source-cache.d.ts +30 -0
- package/dist/cli/api-client.d.ts +411 -0
- package/dist/cli/commands/access-log.d.ts +30 -0
- package/dist/cli/commands/agent-service/index.d.ts +15 -0
- package/dist/cli/commands/agent-service/install.d.ts +9 -0
- package/dist/cli/commands/agent-service/logs.d.ts +9 -0
- package/dist/cli/commands/agent-service/restart.d.ts +8 -0
- package/dist/cli/commands/agent-service/start.d.ts +8 -0
- package/dist/cli/commands/agent-service/status.d.ts +10 -0
- package/dist/cli/commands/agent-service/stop.d.ts +8 -0
- package/dist/cli/commands/agent-service/uninstall.d.ts +9 -0
- package/dist/cli/commands/agent-service/upgrade.d.ts +11 -0
- package/dist/cli/commands/agent.d.ts +10 -0
- package/dist/cli/commands/api-key.d.ts +12 -0
- package/dist/cli/commands/audit.d.ts +9 -0
- package/dist/cli/commands/backend.d.ts +17 -0
- package/dist/cli/commands/cold-store-impl.d.ts +101 -0
- package/dist/cli/commands/cold-store.d.ts +30 -0
- package/dist/cli/commands/config.d.ts +16 -0
- package/dist/cli/commands/db.d.ts +19 -0
- package/dist/cli/commands/debug-bundle.d.ts +16 -0
- package/dist/cli/commands/diagnose.d.ts +15 -0
- package/dist/cli/commands/environment.d.ts +24 -0
- package/dist/cli/commands/event-dlq.d.ts +19 -0
- package/dist/cli/commands/event-log.d.ts +27 -0
- package/dist/cli/commands/event.d.ts +4 -0
- package/dist/cli/commands/execution.d.ts +17 -0
- package/dist/cli/commands/inspect-bundle.d.ts +16 -0
- package/dist/cli/commands/maintenance.d.ts +4 -0
- package/dist/cli/commands/orchestrator-service/index.d.ts +12 -0
- package/dist/cli/commands/orchestrator-service/install.d.ts +10 -0
- package/dist/cli/commands/orchestrator-service/logs.d.ts +10 -0
- package/dist/cli/commands/orchestrator-service/restart.d.ts +8 -0
- package/dist/cli/commands/orchestrator-service/start.d.ts +8 -0
- package/dist/cli/commands/orchestrator-service/status.d.ts +10 -0
- package/dist/cli/commands/orchestrator-service/stop.d.ts +8 -0
- package/dist/cli/commands/orchestrator-service/uninstall.d.ts +9 -0
- package/dist/cli/commands/orchestrator-service/upgrade.d.ts +12 -0
- package/dist/cli/commands/org-settings.d.ts +17 -0
- package/dist/cli/commands/peer.d.ts +13 -0
- package/dist/cli/commands/queue.d.ts +16 -0
- package/dist/cli/commands/registration.d.ts +18 -0
- package/dist/cli/commands/rotate.d.ts +9 -0
- package/dist/cli/commands/runs.d.ts +34 -0
- package/dist/cli/commands/secret.d.ts +12 -0
- package/dist/cli/commands/shared/db.d.ts +16 -0
- package/dist/cli/commands/shared/versioned-upgrade.d.ts +38 -0
- package/dist/cli/commands/source.d.ts +24 -0
- package/dist/cli/commands/token.d.ts +10 -0
- package/dist/cli/commands/workflow.d.ts +31 -0
- package/dist/cli/join.d.ts +14 -0
- package/dist/cli/kici-admin.d.ts +13 -0
- package/dist/cli/lazy-deps/cache.d.ts +17 -0
- package/dist/cli/lazy-deps/downloader.d.ts +33 -0
- package/dist/cli/lazy-deps/registry.d.ts +43 -0
- package/dist/cli/service/compose.d.ts +25 -0
- package/dist/cli/service/index.d.ts +24 -0
- package/dist/cli/service/launchd.d.ts +34 -0
- package/dist/cli/service/platform-detect.d.ts +59 -0
- package/dist/cli/service/systemd.d.ts +41 -0
- package/dist/cli/service/types.d.ts +91 -0
- package/dist/cli/service/windows.d.ts +20 -0
- package/dist/cli/wizard/agent-wizard.d.ts +24 -0
- package/dist/cli/wizard/orchestrator-wizard.d.ts +38 -0
- package/dist/cli/wizard/prompts.d.ts +23 -0
- package/dist/cli.js +11435 -0
- package/dist/cluster/cluster-identity.d.ts +59 -0
- package/dist/cluster/coordinator.d.ts +204 -0
- package/dist/cluster/health-api.d.ts +30 -0
- package/dist/cluster/index.d.ts +24 -0
- package/dist/cluster/join-client.d.ts +75 -0
- package/dist/cluster/join-handler.d.ts +58 -0
- package/dist/cluster/join-token.d.ts +94 -0
- package/dist/cluster/orphan-recovery.d.ts +67 -0
- package/dist/cluster/peer-client.d.ts +190 -0
- package/dist/cluster/peer-credentials.d.ts +108 -0
- package/dist/cluster/peer-crypto.d.ts +57 -0
- package/dist/cluster/peer-handler.d.ts +97 -0
- package/dist/cluster/peer-registry.d.ts +186 -0
- package/dist/cluster/raft-state.d.ts +36 -0
- package/dist/cluster/raft.d.ts +140 -0
- package/dist/cold-store/load-access-log-range.d.ts +73 -0
- package/dist/cold-store/load-event-log-range.d.ts +62 -0
- package/dist/cold-store/load-secret-audit-log-range.d.ts +38 -0
- package/dist/cold-store/orchestrator-cold-store.d.ts +58 -0
- package/dist/cold-store/tables/access-log.d.ts +80 -0
- package/dist/cold-store/tables/event-log.d.ts +70 -0
- package/dist/cold-store/tables/execution-jobs.d.ts +63 -0
- package/dist/cold-store/tables/execution-runs.d.ts +81 -0
- package/dist/cold-store/tables/execution-steps.d.ts +65 -0
- package/dist/cold-store/tables/secret-audit-log.d.ts +77 -0
- package/dist/concurrency/dispatch-next-queued.d.ts +63 -0
- package/dist/concurrency/group-tracker.d.ts +51 -0
- package/dist/concurrency/index.d.ts +3 -0
- package/dist/concurrency/queue-manager.d.ts +68 -0
- package/dist/concurrency/waiters.d.ts +58 -0
- package/dist/config/encryption.d.ts +82 -0
- package/dist/config/env-overlay.d.ts +45 -0
- package/dist/config/index.d.ts +16 -0
- package/dist/config/loader.d.ts +26 -0
- package/dist/config/reload.d.ts +113 -0
- package/dist/config/resolver.d.ts +47 -0
- package/dist/config/schema.d.ts +210 -0
- package/dist/config/shared-store.d.ts +142 -0
- package/dist/config/types.d.ts +218 -0
- package/dist/config.d.ts +249 -0
- package/dist/cron/cron-scheduler.d.ts +78 -0
- package/dist/cron/cron-store.d.ts +38 -0
- package/dist/dashboard/handler.d.ts +243 -0
- package/dist/db/client.d.ts +13 -0
- package/dist/db/migration-provider.d.ts +9 -0
- package/dist/db/migrations/001_initial.d.ts +8 -0
- package/dist/db/migrations/002_config_versions_key_version.d.ts +16 -0
- package/dist/db/migrations/003_access_log.d.ts +26 -0
- package/dist/db/migrations/004_rename_bundle_to_source.d.ts +19 -0
- package/dist/db/migrations/005_cold_store_chunk_counter.d.ts +19 -0
- package/dist/db/migrations/006_runs_jobs_steps_archived_at.d.ts +38 -0
- package/dist/db/migrations/007_audit_logs_archived_at.d.ts +42 -0
- package/dist/db/migrations/008_event_log_archived_at.d.ts +40 -0
- package/dist/db/migrations/009_access_log_trigram.d.ts +15 -0
- package/dist/db/migrations/010_cold_store_chunks.d.ts +34 -0
- package/dist/db/migrations/011_drop_source_secrets_notify.d.ts +21 -0
- package/dist/db/migrations/012_peer_credentials_active_uniq.d.ts +28 -0
- package/dist/db/migrations/013_execution_log_bytes.d.ts +21 -0
- package/dist/db/migrations/014_kici_events_lease_retry.d.ts +36 -0
- package/dist/db/migrations/015_org_settings_customer_scoped.d.ts +30 -0
- package/dist/db/migrations/016_org_settings_allow_http_npm.d.ts +15 -0
- package/dist/db/migrations/017_org_id_widen.d.ts +4 -0
- package/dist/db/migrations/018_org_id_prefix_backfill.d.ts +4 -0
- package/dist/db/migrator.d.ts +32 -0
- package/dist/db/types.d.ts +1266 -0
- package/dist/diagnostics/bundle-reader.d.ts +48 -0
- package/dist/diagnostics/bundle-writer.d.ts +57 -0
- package/dist/diagnostics/checks/agents.d.ts +10 -0
- package/dist/diagnostics/checks/certs.d.ts +9 -0
- package/dist/diagnostics/checks/config.d.ts +10 -0
- package/dist/diagnostics/checks/db.d.ts +9 -0
- package/dist/diagnostics/checks/disk.d.ts +9 -0
- package/dist/diagnostics/checks/index.d.ts +17 -0
- package/dist/diagnostics/checks/ws.d.ts +9 -0
- package/dist/diagnostics/index.d.ts +13 -0
- package/dist/diagnostics/runner.d.ts +23 -0
- package/dist/diagnostics/types.d.ts +38 -0
- package/dist/entry-helpers.d.ts +93 -0
- package/dist/environments/binding-store.d.ts +27 -0
- package/dist/environments/environment-store.d.ts +74 -0
- package/dist/environments/held-runs.d.ts +64 -0
- package/dist/environments/index.d.ts +10 -0
- package/dist/environments/protection/branch-gate.d.ts +5 -0
- package/dist/environments/protection/concurrency-gate.d.ts +7 -0
- package/dist/environments/protection/pipeline.d.ts +18 -0
- package/dist/environments/protection/reviewer-gate.d.ts +7 -0
- package/dist/environments/protection/trust-gate.d.ts +7 -0
- package/dist/environments/protection/wait-timer-gate.d.ts +7 -0
- package/dist/environments/variable-store.d.ts +39 -0
- package/dist/events/circuit-breaker.d.ts +33 -0
- package/dist/events/event-emitter.d.ts +55 -0
- package/dist/events/event-retry-scanner.d.ts +52 -0
- package/dist/events/event-router.d.ts +183 -0
- package/dist/events/event-store.d.ts +157 -0
- package/dist/events/trust-store.d.ts +54 -0
- package/dist/events/types.d.ts +61 -0
- package/dist/helpers/ip-extraction.d.ts +29 -0
- package/dist/helpers/rate-limiter.d.ts +23 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +772 -0
- package/dist/lockfile-cache.d.ts +39 -0
- package/dist/metrics/agent-metrics-aggregator.d.ts +116 -0
- package/dist/metrics/metrics-reporter.d.ts +40 -0
- package/dist/metrics/prometheus.d.ts +261 -0
- package/dist/metrics/scheduled-jobs.d.ts +20 -0
- package/dist/orchestrator-core.d.ts +193 -0
- package/dist/pipeline/dispatch-matched-workflow.d.ts +102 -0
- package/dist/pipeline/inline-eval.d.ts +28 -0
- package/dist/pipeline/install-secrets-resolver.d.ts +73 -0
- package/dist/pipeline/manual-schedule.d.ts +21 -0
- package/dist/pipeline/needs-scheduler.d.ts +85 -0
- package/dist/pipeline/process-webhook.d.ts +38 -0
- package/dist/pipeline/processor.d.ts +326 -0
- package/dist/pipeline/rerun.d.ts +79 -0
- package/dist/pipeline/test-pipeline.d.ts +110 -0
- package/dist/provider-registry.d.ts +122 -0
- package/dist/providers/generic/index.d.ts +23 -0
- package/dist/providers/generic/normalizer.d.ts +112 -0
- package/dist/providers/generic/verification.d.ts +47 -0
- package/dist/providers/github/auth.d.ts +60 -0
- package/dist/providers/github/changed-files.d.ts +51 -0
- package/dist/providers/github/check-status-poster.d.ts +35 -0
- package/dist/providers/github/contributor-resolver.d.ts +30 -0
- package/dist/providers/github/index.d.ts +20 -0
- package/dist/providers/github/lock-file.d.ts +32 -0
- package/dist/providers/github/normalizer.d.ts +103 -0
- package/dist/providers/github/repo-url.d.ts +35 -0
- package/dist/providers/internal/index.d.ts +32 -0
- package/dist/providers/internal/lock-file-fetcher.d.ts +34 -0
- package/dist/providers/internal/normalizer.d.ts +89 -0
- package/dist/providers/internal/repo-url-builder.d.ts +42 -0
- package/dist/providers/universal-git/changed-files.d.ts +42 -0
- package/dist/providers/universal-git/clone-token.d.ts +83 -0
- package/dist/providers/universal-git/config.d.ts +192 -0
- package/dist/providers/universal-git/index.d.ts +55 -0
- package/dist/providers/universal-git/lock-file.d.ts +71 -0
- package/dist/providers/universal-git/normalizer.d.ts +90 -0
- package/dist/providers/universal-git/repo-url.d.ts +50 -0
- package/dist/providers/universal-git/ssh-auth.d.ts +94 -0
- package/dist/queue/bootstrap.d.ts +50 -0
- package/dist/queue/cleanup.d.ts +41 -0
- package/dist/queue/depth-refresher.d.ts +65 -0
- package/dist/queue/job-queue.d.ts +343 -0
- package/dist/queue/scheduled-job.d.ts +91 -0
- package/dist/registration/extractor.d.ts +44 -0
- package/dist/registration/registration-index.d.ts +162 -0
- package/dist/registration/registration-store.d.ts +111 -0
- package/dist/reporting/check-run-summary.d.ts +102 -0
- package/dist/reporting/commit-status.d.ts +382 -0
- package/dist/reporting/execution-tracker.d.ts +538 -0
- package/dist/reporting/fs-log-storage.d.ts +41 -0
- package/dist/reporting/log-pull-handler.d.ts +35 -0
- package/dist/reporting/log-storage.d.ts +70 -0
- package/dist/reporting/log-writer.d.ts +45 -0
- package/dist/reporting/s3-log-storage.d.ts +42 -0
- package/dist/reporting/step-log-buffer.d.ts +57 -0
- package/dist/routes/admin-access-log.d.ts +34 -0
- package/dist/routes/admin-backends.d.ts +28 -0
- package/dist/routes/admin-config.d.ts +57 -0
- package/dist/routes/admin-db.d.ts +20 -0
- package/dist/routes/admin-environments.d.ts +42 -0
- package/dist/routes/admin-errors.d.ts +4 -0
- package/dist/routes/admin-event-dlq.d.ts +39 -0
- package/dist/routes/admin-event-log.d.ts +42 -0
- package/dist/routes/admin-events.d.ts +46 -0
- package/dist/routes/admin-maintenance.d.ts +22 -0
- package/dist/routes/admin-org-settings.d.ts +29 -0
- package/dist/routes/admin-queue-execution.d.ts +27 -0
- package/dist/routes/admin-registrations.d.ts +37 -0
- package/dist/routes/admin-runs.d.ts +57 -0
- package/dist/routes/admin-scheduled-jobs.d.ts +36 -0
- package/dist/routes/admin-sources.d.ts +18 -0
- package/dist/routes/admin.d.ts +103 -0
- package/dist/routes/capabilities.d.ts +24 -0
- package/dist/routes/diagnostics.d.ts +16 -0
- package/dist/routes/health.d.ts +20 -0
- package/dist/routes/test-trigger.d.ts +41 -0
- package/dist/routes/uploads.d.ts +38 -0
- package/dist/routes/webhooks.d.ts +36 -0
- package/dist/scaler/bare-metal-backend.d.ts +107 -0
- package/dist/scaler/config.d.ts +303 -0
- package/dist/scaler/container-backend.d.ts +125 -0
- package/dist/scaler/file-tail.d.ts +23 -0
- package/dist/scaler/firecracker-api.d.ts +100 -0
- package/dist/scaler/firecracker-backend.d.ts +263 -0
- package/dist/scaler/index.d.ts +24 -0
- package/dist/scaler/ip-allocator.d.ts +177 -0
- package/dist/scaler/label-matcher.d.ts +73 -0
- package/dist/scaler/log-forwarder.d.ts +54 -0
- package/dist/scaler/machine-ledger.d.ts +160 -0
- package/dist/scaler/manager.d.ts +338 -0
- package/dist/scaler/nftables.d.ts +85 -0
- package/dist/scaler/types.d.ts +388 -0
- package/dist/scaler/warm-pool.d.ts +81 -0
- package/dist/secrets/audit-logger.d.ts +65 -0
- package/dist/secrets/backend-health.d.ts +60 -0
- package/dist/secrets/backend-registry.d.ts +68 -0
- package/dist/secrets/backend-sync.d.ts +40 -0
- package/dist/secrets/cleanup.d.ts +40 -0
- package/dist/secrets/config.d.ts +51 -0
- package/dist/secrets/crypto.d.ts +49 -0
- package/dist/secrets/ephemeral-keys.d.ts +49 -0
- package/dist/secrets/index.d.ts +17 -0
- package/dist/secrets/pg-secret-store.d.ts +105 -0
- package/dist/secrets/rbac.d.ts +47 -0
- package/dist/secrets/secret-output-store.d.ts +46 -0
- package/dist/secrets/secret-resolver.d.ts +137 -0
- package/dist/secrets/source-credentials.d.ts +61 -0
- package/dist/secrets/token-manager.d.ts +63 -0
- package/dist/secrets/vault-secret-store.d.ts +85 -0
- package/dist/security/comment-handler.d.ts +67 -0
- package/dist/security/contributor-cache.d.ts +75 -0
- package/dist/security/global-workflow-policy.d.ts +72 -0
- package/dist/security/lock-source.d.ts +34 -0
- package/dist/security/trust-resolver.d.ts +108 -0
- package/dist/security/workflow-diff.d.ts +26 -0
- package/dist/server.d.ts +17 -0
- package/dist/server.js +48055 -0
- package/dist/sources/index.d.ts +10 -0
- package/dist/sources/source-manager.d.ts +63 -0
- package/dist/sources/source-store.d.ts +79 -0
- package/dist/sources/source-validator.d.ts +16 -0
- package/dist/stale-detector/stale-run-detector.d.ts +109 -0
- package/dist/standalone.d.ts +20 -0
- package/dist/standalone.js +41546 -0
- package/dist/storage/blob-routes.d.ts +20 -0
- package/dist/storage/filesystem.d.ts +60 -0
- package/dist/storage/index.d.ts +20 -0
- package/dist/storage/s3.d.ts +68 -0
- package/dist/storage/sign-url.d.ts +45 -0
- package/dist/storage/types.d.ts +98 -0
- package/dist/webhook/dedup.d.ts +44 -0
- package/dist/webhook/event-log.d.ts +83 -0
- package/dist/webhook/generic-sources.d.ts +169 -0
- package/dist/webhook/handler.d.ts +23 -0
- package/dist/webhook/relay-buffer.d.ts +96 -0
- package/dist/webhook/verify-inbound.d.ts +78 -0
- package/dist/worker/in-memory-execution-tracker.d.ts +94 -0
- package/dist/worker/in-memory-job-queue.d.ts +74 -0
- package/dist/worker/static-agent-token-store.d.ts +58 -0
- package/dist/worker/worker-status.d.ts +36 -0
- package/dist/worker-core.d.ts +74 -0
- package/dist/ws/agent-api-registry.d.ts +49 -0
- package/dist/ws/agent-handler.d.ts +176 -0
- package/dist/ws/agent-heartbeat.d.ts +45 -0
- package/dist/ws/dashboard-backends-handler.d.ts +51 -0
- package/dist/ws/dashboard-diagnostics-handler.d.ts +56 -0
- package/dist/ws/dashboard-env-handler.d.ts +107 -0
- package/dist/ws/dashboard-global-workflows-handler.d.ts +72 -0
- package/dist/ws/dashboard-registrations-handler.d.ts +84 -0
- package/dist/ws/event-buffer.d.ts +16 -0
- package/dist/ws/observer-handler.d.ts +42 -0
- package/dist/ws/observer-registry.d.ts +88 -0
- package/dist/ws/platform-client.d.ts +270 -0
- package/dist/ws/server-options.d.ts +15 -0
- package/package.json +87 -6
- package/sbom.spdx.json +14370 -0
- package/index.js +0 -3
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic webhook normalizer.
|
|
3
|
+
*
|
|
4
|
+
* Implements the WebhookNormalizer interface for non-GitHub webhook sources.
|
|
5
|
+
* Handles arbitrary HTTP payloads: JSON and URL-encoded form data.
|
|
6
|
+
* Extracts event type from configurable header or JSONPath in body.
|
|
7
|
+
* Filters sensitive headers per source configuration.
|
|
8
|
+
*/
|
|
9
|
+
import type { WebhookNormalizer, SimulatedEvent } from '@kici-dev/engine';
|
|
10
|
+
import type { GenericSourceManager } from '../../webhook/generic-sources.js';
|
|
11
|
+
/**
|
|
12
|
+
* Generic webhook normalizer implementing WebhookNormalizer from @kici-dev/engine.
|
|
13
|
+
*
|
|
14
|
+
* Transforms arbitrary HTTP webhook payloads into KiCI's universal SimulatedEvent format.
|
|
15
|
+
* Unlike Git providers, generic webhooks have no repo, ref, or SHA -- they carry
|
|
16
|
+
* event payloads from external services (Stripe, Slack, custom APIs, etc.).
|
|
17
|
+
*/
|
|
18
|
+
export declare class GenericWebhookNormalizer implements WebhookNormalizer {
|
|
19
|
+
private readonly sourceManager;
|
|
20
|
+
readonly provider: "generic";
|
|
21
|
+
constructor(sourceManager: GenericSourceManager);
|
|
22
|
+
/**
|
|
23
|
+
* Extract routing key from the X-KiCI-Source-ID header.
|
|
24
|
+
* The route handler sets this header based on the URL path parameter.
|
|
25
|
+
*/
|
|
26
|
+
extractRoutingKey(headers: Record<string, string>, _payload: unknown): string | null;
|
|
27
|
+
/**
|
|
28
|
+
* Extract delivery ID from configurable header or generate one.
|
|
29
|
+
* Checks X-Request-ID, X-Delivery-ID, or X-Idempotency-Key headers.
|
|
30
|
+
*/
|
|
31
|
+
extractDeliveryId(headers: Record<string, string>): string | null;
|
|
32
|
+
/**
|
|
33
|
+
* Extract event type from configurable header.
|
|
34
|
+
* Falls back to X-Event-Type header.
|
|
35
|
+
*/
|
|
36
|
+
extractEventType(headers: Record<string, string>): string | null;
|
|
37
|
+
/**
|
|
38
|
+
* Verify signature -- delegates to the generic verification module.
|
|
39
|
+
* This method is part of the WebhookNormalizer interface but generic webhooks
|
|
40
|
+
* use the separate verifyGenericWebhook function with per-source config.
|
|
41
|
+
* Returns true here as a no-op; actual verification is handled upstream.
|
|
42
|
+
*/
|
|
43
|
+
verifySignature(_body: string, _headers: Record<string, string>, _secret: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Normalize a generic webhook event into a SimulatedEvent.
|
|
46
|
+
*
|
|
47
|
+
* Generic webhooks produce events with:
|
|
48
|
+
* - type: the extracted event type or 'generic_webhook' fallback
|
|
49
|
+
* - action: undefined (no sub-action concept for generic sources)
|
|
50
|
+
* - targetBranch: '__generic__' (no branch concept)
|
|
51
|
+
* - payload: the raw parsed payload with filtered headers
|
|
52
|
+
* - provider: 'generic'
|
|
53
|
+
*/
|
|
54
|
+
normalizeEvent(eventType: string, _action: string | null, payload: unknown): SimulatedEvent | null;
|
|
55
|
+
/**
|
|
56
|
+
* Extract repository identifier -- generic webhooks have no repo concept.
|
|
57
|
+
*/
|
|
58
|
+
extractRepoIdentifier(_payload: unknown): string | null;
|
|
59
|
+
/**
|
|
60
|
+
* Extract ref -- generic webhooks have no ref concept.
|
|
61
|
+
*/
|
|
62
|
+
extractRef(_eventType: string, _payload: unknown): string;
|
|
63
|
+
/**
|
|
64
|
+
* Extract credentials -- generic webhooks carry no provider credentials.
|
|
65
|
+
*/
|
|
66
|
+
extractCredentials(_payload: unknown): Record<string, unknown>;
|
|
67
|
+
/**
|
|
68
|
+
* Parse and normalize a full generic webhook request.
|
|
69
|
+
*
|
|
70
|
+
* This is the main entry point for generic webhook processing:
|
|
71
|
+
* 1. Looks up source config by routing key
|
|
72
|
+
* 2. Parses body as JSON or URL-encoded form data
|
|
73
|
+
* 3. Extracts event type from configured header or JSONPath in body
|
|
74
|
+
* 4. Filters sensitive headers
|
|
75
|
+
* 5. Returns normalized WebhookData
|
|
76
|
+
*
|
|
77
|
+
* @param routingKey - The routing key for this source (from URL path)
|
|
78
|
+
* @param rawBody - Raw request body string
|
|
79
|
+
* @param headers - Request headers (lowercase keys)
|
|
80
|
+
* @returns Normalized data or null if source not found/disabled
|
|
81
|
+
*/
|
|
82
|
+
normalizeGenericRequest(routingKey: string, rawBody: string, headers: Record<string, string>): Promise<{
|
|
83
|
+
event: string;
|
|
84
|
+
payload: Record<string, unknown>;
|
|
85
|
+
headers: Record<string, string>;
|
|
86
|
+
routingKey: string;
|
|
87
|
+
} | null>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Parse request body as JSON or URL-encoded form data.
|
|
91
|
+
*/
|
|
92
|
+
export declare function parseBody(rawBody: string, contentType?: string): Record<string, unknown>;
|
|
93
|
+
/**
|
|
94
|
+
* Extract event type from headers or payload path.
|
|
95
|
+
*
|
|
96
|
+
* Priority:
|
|
97
|
+
* 1. Source-configured header (event_type_header)
|
|
98
|
+
* 2. Source-configured JSONPath in body (event_type_path) -- simple dot notation
|
|
99
|
+
* 3. Fallback header X-Event-Type
|
|
100
|
+
* 4. Default: 'default'
|
|
101
|
+
*/
|
|
102
|
+
export declare function extractEventType(headers: Record<string, string>, payload: Record<string, unknown>, eventTypeHeader?: string | null, eventTypePath?: string | null): string;
|
|
103
|
+
/**
|
|
104
|
+
* Get a nested value from an object using dot notation.
|
|
105
|
+
* e.g., getNestedValue({a: {b: 'c'}}, 'a.b') => 'c'
|
|
106
|
+
*/
|
|
107
|
+
export declare function getNestedValue(obj: Record<string, unknown>, path: string): unknown;
|
|
108
|
+
/**
|
|
109
|
+
* Filter out sensitive headers.
|
|
110
|
+
*/
|
|
111
|
+
export declare function filterHeaders(headers: Record<string, string>, stripHeaders: string[]): Record<string, string>;
|
|
112
|
+
//# sourceMappingURL=normalizer.d.ts.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic webhook verification module.
|
|
3
|
+
*
|
|
4
|
+
* Supports multiple verification methods for non-GitHub webhook sources:
|
|
5
|
+
* - HMAC-SHA256 signature verification (reuses engine's verifySignature)
|
|
6
|
+
* - Bearer token comparison (constant-time)
|
|
7
|
+
* - IP allowlist (exact match)
|
|
8
|
+
* - None (no verification, always passes)
|
|
9
|
+
*/
|
|
10
|
+
/** Supported verification methods */
|
|
11
|
+
export type VerificationMethod = 'hmac_sha256' | 'bearer_token' | 'ip_allowlist' | 'none';
|
|
12
|
+
/** HMAC-SHA256 verification config */
|
|
13
|
+
export interface HmacVerificationConfig {
|
|
14
|
+
method: 'hmac_sha256';
|
|
15
|
+
secret: string;
|
|
16
|
+
/** Header containing the signature (default: x-signature-256) */
|
|
17
|
+
headerName?: string;
|
|
18
|
+
}
|
|
19
|
+
/** Bearer token verification config */
|
|
20
|
+
export interface BearerVerificationConfig {
|
|
21
|
+
method: 'bearer_token';
|
|
22
|
+
token: string;
|
|
23
|
+
/** Header containing the token (default: authorization) */
|
|
24
|
+
headerName?: string;
|
|
25
|
+
}
|
|
26
|
+
/** IP allowlist verification config */
|
|
27
|
+
export interface IpAllowlistVerificationConfig {
|
|
28
|
+
method: 'ip_allowlist';
|
|
29
|
+
allowlist: string[];
|
|
30
|
+
}
|
|
31
|
+
/** No verification config */
|
|
32
|
+
export interface NoneVerificationConfig {
|
|
33
|
+
method: 'none';
|
|
34
|
+
}
|
|
35
|
+
/** Discriminated union of all verification configs */
|
|
36
|
+
export type VerificationConfig = HmacVerificationConfig | BearerVerificationConfig | IpAllowlistVerificationConfig | NoneVerificationConfig;
|
|
37
|
+
/**
|
|
38
|
+
* Verify a generic webhook request.
|
|
39
|
+
*
|
|
40
|
+
* @param body - Raw request body as string
|
|
41
|
+
* @param headers - Request headers (lowercase keys)
|
|
42
|
+
* @param config - Verification configuration for this source
|
|
43
|
+
* @param clientIp - Client IP address (required for ip_allowlist method)
|
|
44
|
+
* @returns true if verification passes
|
|
45
|
+
*/
|
|
46
|
+
export declare function verifyGenericWebhook(body: string, headers: Record<string, string>, config: VerificationConfig, clientIp?: string): boolean;
|
|
47
|
+
//# sourceMappingURL=verification.d.ts.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub clone token provider and authentication utilities.
|
|
3
|
+
*
|
|
4
|
+
* Implements the CloneTokenProvider interface from @kici-dev/engine for GitHub.
|
|
5
|
+
* Uses GitHub App installation tokens for repository access.
|
|
6
|
+
*/
|
|
7
|
+
import { Octokit } from '@octokit/rest';
|
|
8
|
+
import type { CloneTokenProvider } from '@kici-dev/engine';
|
|
9
|
+
/**
|
|
10
|
+
* Configuration required for GitHub App authentication.
|
|
11
|
+
*/
|
|
12
|
+
export interface GitHubAppConfig {
|
|
13
|
+
/** GitHub App ID (numeric string) */
|
|
14
|
+
appId: string;
|
|
15
|
+
/** GitHub App private key (PEM format) */
|
|
16
|
+
privateKey: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Credentials for GitHub operations requiring installation-level access.
|
|
20
|
+
*/
|
|
21
|
+
export interface GitHubCredentials {
|
|
22
|
+
installationId: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Create an Octokit instance authenticated as a GitHub App installation.
|
|
26
|
+
*
|
|
27
|
+
* Uses @octokit/auth-app to handle:
|
|
28
|
+
* - JWT generation for app-level authentication
|
|
29
|
+
* - Installation token creation and automatic refresh
|
|
30
|
+
*
|
|
31
|
+
* Each call creates a new Octokit instance scoped to the specific installation.
|
|
32
|
+
* The auth-app strategy handles token caching internally per Octokit instance.
|
|
33
|
+
*
|
|
34
|
+
* @param config - GitHub App credentials (appId + privateKey)
|
|
35
|
+
* @param installationId - GitHub App installation ID for the target account/org
|
|
36
|
+
* @returns Octokit instance with auto-refreshing installation tokens
|
|
37
|
+
*/
|
|
38
|
+
export declare function createInstallationOctokit(config: GitHubAppConfig, installationId: number): Octokit;
|
|
39
|
+
/**
|
|
40
|
+
* GitHub-specific implementation of CloneTokenProvider.
|
|
41
|
+
*
|
|
42
|
+
* Creates short-lived installation access tokens for agent repo clone operations.
|
|
43
|
+
* Uses the GitHub App credentials to generate tokens scoped to a specific installation.
|
|
44
|
+
*/
|
|
45
|
+
export declare class GitHubCloneTokenProvider implements CloneTokenProvider {
|
|
46
|
+
private readonly config;
|
|
47
|
+
readonly provider: "github";
|
|
48
|
+
constructor(config: GitHubAppConfig);
|
|
49
|
+
/** Get the GitHub App config for this provider instance. */
|
|
50
|
+
getAppConfig(): GitHubAppConfig;
|
|
51
|
+
/**
|
|
52
|
+
* Create a short-lived installation access token for cloning a repo.
|
|
53
|
+
*
|
|
54
|
+
* @param _repoIdentifier - "owner/repo" format (not used for GitHub token creation)
|
|
55
|
+
* @param credentials - Must be GitHubCredentials with installationId
|
|
56
|
+
* @returns Installation access token string
|
|
57
|
+
*/
|
|
58
|
+
createCloneToken(_repoIdentifier: string, credentials: unknown): Promise<string | null>;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub changed files fetcher.
|
|
3
|
+
*
|
|
4
|
+
* Implements the ChangedFilesFetcher interface from @kici-dev/engine for GitHub.
|
|
5
|
+
* Retrieves changed files for PR and push events via the GitHub API.
|
|
6
|
+
*/
|
|
7
|
+
import type { ChangedFilesFetcher } from '@kici-dev/engine';
|
|
8
|
+
import { type GitHubAppConfig } from './auth.js';
|
|
9
|
+
/**
|
|
10
|
+
* Check if an error is a GitHub 429 rate limit response.
|
|
11
|
+
* Octokit throws RequestError with a numeric `status` property.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isRateLimitError(err: unknown): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Execute a function with retry on 429 rate limit errors.
|
|
16
|
+
* Uses exponential backoff: 1s, 2s, 4s.
|
|
17
|
+
* Non-429 errors are rethrown immediately.
|
|
18
|
+
*/
|
|
19
|
+
export declare function withRateLimitRetry<T>(fn: () => Promise<T>, context: string): Promise<T>;
|
|
20
|
+
/**
|
|
21
|
+
* GitHub-specific implementation of ChangedFilesFetcher.
|
|
22
|
+
*
|
|
23
|
+
* For PRs: uses paginated pulls.listFiles API (handles up to 3000 files).
|
|
24
|
+
* For pushes: uses repos.compareCommits API (logs warning at 300+ files).
|
|
25
|
+
* For initial pushes (zero SHA): returns empty array.
|
|
26
|
+
* For unknown events: returns empty array.
|
|
27
|
+
*/
|
|
28
|
+
export declare class GitHubChangedFilesFetcher implements ChangedFilesFetcher {
|
|
29
|
+
private readonly config;
|
|
30
|
+
readonly provider: "github";
|
|
31
|
+
constructor(config: GitHubAppConfig);
|
|
32
|
+
/**
|
|
33
|
+
* Get changed files for a GitHub webhook event.
|
|
34
|
+
*
|
|
35
|
+
* @param repoIdentifier - "owner/repo" format
|
|
36
|
+
* @param eventType - GitHub event type ("pull_request" or "push")
|
|
37
|
+
* @param payload - Raw GitHub webhook payload
|
|
38
|
+
* @param credentials - Must be GitHubCredentials with installationId
|
|
39
|
+
* @returns Array of changed file paths
|
|
40
|
+
*/
|
|
41
|
+
getChangedFiles(repoIdentifier: string, eventType: string, payload: unknown, credentials: unknown): Promise<string[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Get changed files for a pull request event using paginated listFiles API.
|
|
44
|
+
*/
|
|
45
|
+
private getPrChangedFiles;
|
|
46
|
+
/**
|
|
47
|
+
* Get changed files for a push event using compareCommits API.
|
|
48
|
+
*/
|
|
49
|
+
private getPushChangedFiles;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=changed-files.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub implementation of the CheckStatusPoster interface.
|
|
3
|
+
*
|
|
4
|
+
* Posts check statuses to GitHub PRs using the Checks API for:
|
|
5
|
+
* - Security holds (pending): "KiCI Security: Held for approval"
|
|
6
|
+
* - Workflow modifications (neutral): "KiCI: Workflow changes detected"
|
|
7
|
+
* - Approved runs (success) / Rejected/expired runs (failure)
|
|
8
|
+
*
|
|
9
|
+
* Reuses the Octokit infrastructure from auth.ts via createInstallationOctokit.
|
|
10
|
+
* Uses a fixed check name per category so that subsequent updates (approve/reject)
|
|
11
|
+
* can find and update the existing check run.
|
|
12
|
+
*/
|
|
13
|
+
import type { CheckStatusPoster, CheckStatus } from '@kici-dev/engine';
|
|
14
|
+
import type { Octokit } from '@octokit/rest';
|
|
15
|
+
import type { WorkflowModification } from '../../security/workflow-diff.js';
|
|
16
|
+
/**
|
|
17
|
+
* GitHub CheckStatusPoster using the Checks API.
|
|
18
|
+
*
|
|
19
|
+
* Creates or updates check runs for security events. The check name
|
|
20
|
+
* is fixed so that updates (approve/reject) modify the same check.
|
|
21
|
+
*/
|
|
22
|
+
export declare class GitHubCheckStatusPoster implements CheckStatusPoster {
|
|
23
|
+
private readonly getOctokit;
|
|
24
|
+
readonly provider: "github";
|
|
25
|
+
constructor(getOctokit: (credentials: unknown) => Octokit);
|
|
26
|
+
postCheckStatus(repoIdentifier: string, commitSha: string, status: CheckStatus, title: string, summary: string, credentials: unknown): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Post an informational check for workflow modifications detected in a PR.
|
|
29
|
+
*
|
|
30
|
+
* Uses a separate check name ("KiCI: Workflow changes") so it doesn't
|
|
31
|
+
* conflict with the security hold check. Always posted as neutral/completed.
|
|
32
|
+
*/
|
|
33
|
+
postWorkflowModificationCheck(repoIdentifier: string, commitSha: string, modifications: WorkflowModification[], credentials: unknown): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=check-status-poster.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub ContributorResolver implementation.
|
|
3
|
+
*
|
|
4
|
+
* Resolves contributor permissions by querying the GitHub API for
|
|
5
|
+
* collaborator permission levels on a repository.
|
|
6
|
+
*/
|
|
7
|
+
import type { ContributorResolver, ContributorInfo } from '@kici-dev/engine';
|
|
8
|
+
import { type GitHubAppConfig } from './auth.js';
|
|
9
|
+
/**
|
|
10
|
+
* GitHub-specific implementation of ContributorResolver.
|
|
11
|
+
*
|
|
12
|
+
* Uses the GitHub API to check a user's permission level on a repository.
|
|
13
|
+
* Handles 403 (insufficient app permissions) and 404 (not a collaborator)
|
|
14
|
+
* gracefully by returning 'none' permission.
|
|
15
|
+
*/
|
|
16
|
+
export declare class GitHubContributorResolver implements ContributorResolver {
|
|
17
|
+
private readonly config;
|
|
18
|
+
readonly provider: "github";
|
|
19
|
+
constructor(config: GitHubAppConfig);
|
|
20
|
+
/**
|
|
21
|
+
* Resolve a contributor's permission level on a GitHub repository.
|
|
22
|
+
*
|
|
23
|
+
* @param repoIdentifier - "owner/repo" format
|
|
24
|
+
* @param username - GitHub username
|
|
25
|
+
* @param credentials - GitHubCredentials with installationId
|
|
26
|
+
* @returns ContributorInfo with mapped permission level
|
|
27
|
+
*/
|
|
28
|
+
resolveContributor(repoIdentifier: string, username: string, credentials: unknown): Promise<ContributorInfo>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=contributor-resolver.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub provider implementations for KiCI.
|
|
3
|
+
*
|
|
4
|
+
* Each class implements a corresponding interface from @kici-dev/engine:
|
|
5
|
+
* - GitHubWebhookNormalizer -> WebhookNormalizer
|
|
6
|
+
* - GitHubLockFileFetcher -> LockFileFetcher
|
|
7
|
+
* - GitHubChangedFilesFetcher -> ChangedFilesFetcher
|
|
8
|
+
* - GitHubCloneTokenProvider -> CloneTokenProvider
|
|
9
|
+
* - GitHubRepoUrlBuilder -> RepoUrlBuilder
|
|
10
|
+
* - GitHubContributorResolver -> ContributorResolver
|
|
11
|
+
*/
|
|
12
|
+
export { GitHubWebhookNormalizer } from './normalizer.js';
|
|
13
|
+
export { GitHubLockFileFetcher } from './lock-file.js';
|
|
14
|
+
export { GitHubChangedFilesFetcher } from './changed-files.js';
|
|
15
|
+
export { GitHubCloneTokenProvider, createInstallationOctokit } from './auth.js';
|
|
16
|
+
export type { GitHubAppConfig, GitHubCredentials } from './auth.js';
|
|
17
|
+
export { GitHubRepoUrlBuilder } from './repo-url.js';
|
|
18
|
+
export { GitHubContributorResolver } from './contributor-resolver.js';
|
|
19
|
+
export { GitHubCheckStatusPoster } from './check-status-poster.js';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub lock file fetcher.
|
|
3
|
+
*
|
|
4
|
+
* Implements the LockFileFetcher interface from @kici-dev/engine for GitHub.
|
|
5
|
+
* Fetches kici.lock.json from a GitHub repository via the Contents API.
|
|
6
|
+
*
|
|
7
|
+
* NOTE: This is the raw fetcher without caching. The orchestrator wraps
|
|
8
|
+
* this with an LRU cache (LockFileCache) for production use.
|
|
9
|
+
*/
|
|
10
|
+
import type { LockFileFetcher, LockFile } from '@kici-dev/engine';
|
|
11
|
+
import { type GitHubAppConfig } from './auth.js';
|
|
12
|
+
/**
|
|
13
|
+
* GitHub-specific implementation of LockFileFetcher.
|
|
14
|
+
*
|
|
15
|
+
* Fetches .kici/kici.lock.json from a GitHub repository using the Contents API.
|
|
16
|
+
* Does NOT include caching -- the orchestrator wraps this fetcher with an LRU cache.
|
|
17
|
+
*/
|
|
18
|
+
export declare class GitHubLockFileFetcher implements LockFileFetcher {
|
|
19
|
+
private readonly config;
|
|
20
|
+
readonly provider: "github";
|
|
21
|
+
constructor(config: GitHubAppConfig);
|
|
22
|
+
/**
|
|
23
|
+
* Fetch the lock file from a GitHub repository at a specific ref.
|
|
24
|
+
*
|
|
25
|
+
* @param repoIdentifier - "owner/repo" format
|
|
26
|
+
* @param ref - Git ref (branch, tag, SHA)
|
|
27
|
+
* @param credentials - Must be GitHubCredentials with installationId
|
|
28
|
+
* @returns Parsed LockFile, or null if not found
|
|
29
|
+
*/
|
|
30
|
+
fetchLockFile(repoIdentifier: string, ref: string, credentials: unknown): Promise<LockFile | null>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=lock-file.d.ts.map
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub webhook normalizer.
|
|
3
|
+
*
|
|
4
|
+
* Implements the WebhookNormalizer interface from @kici-dev/engine for GitHub webhooks.
|
|
5
|
+
* Handles header extraction, HMAC-SHA256 signature verification, and event normalization.
|
|
6
|
+
*/
|
|
7
|
+
import type { WebhookNormalizer, SimulatedEvent, AccessCacheInvalidation } from '@kici-dev/engine';
|
|
8
|
+
/**
|
|
9
|
+
* GitHub-specific implementation of WebhookNormalizer.
|
|
10
|
+
*
|
|
11
|
+
* Maps GitHub webhook headers and payloads to KiCI's universal format.
|
|
12
|
+
* Headers are expected lowercase (Hono normalizes them).
|
|
13
|
+
*/
|
|
14
|
+
export declare class GitHubWebhookNormalizer implements WebhookNormalizer {
|
|
15
|
+
readonly provider: "github";
|
|
16
|
+
/**
|
|
17
|
+
* Extract routing key from GitHub webhook headers.
|
|
18
|
+
*
|
|
19
|
+
* Uses the X-GitHub-Hook-Installation-Target-ID header which identifies
|
|
20
|
+
* the GitHub App receiving the webhook.
|
|
21
|
+
*
|
|
22
|
+
* @returns "github:{appId}" or null if header is missing
|
|
23
|
+
*/
|
|
24
|
+
extractRoutingKey(headers: Record<string, string>, _payload: unknown): string | null;
|
|
25
|
+
/**
|
|
26
|
+
* Extract delivery ID from X-GitHub-Delivery header.
|
|
27
|
+
*
|
|
28
|
+
* GitHub sends a UUID as the delivery identifier for deduplication.
|
|
29
|
+
*/
|
|
30
|
+
extractDeliveryId(headers: Record<string, string>): string | null;
|
|
31
|
+
/**
|
|
32
|
+
* Extract event type from X-GitHub-Event header.
|
|
33
|
+
*
|
|
34
|
+
* Returns the raw GitHub event type (e.g., "push", "pull_request").
|
|
35
|
+
*/
|
|
36
|
+
extractEventType(headers: Record<string, string>): string | null;
|
|
37
|
+
/**
|
|
38
|
+
* Verify webhook signature using HMAC-SHA256.
|
|
39
|
+
*
|
|
40
|
+
* GitHub signs webhooks with the X-Hub-Signature-256 header using
|
|
41
|
+
* the shared webhook secret configured on the GitHub App.
|
|
42
|
+
*/
|
|
43
|
+
verifySignature(body: string, headers: Record<string, string>, secret: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Normalize a GitHub webhook event into a SimulatedEvent.
|
|
46
|
+
*
|
|
47
|
+
* Handles all 15 supported GitHub event types:
|
|
48
|
+
* - pull_request, push, issue_comment, pull_request_review,
|
|
49
|
+
* pull_request_review_comment, repository_dispatch, release,
|
|
50
|
+
* create, delete, status, workflow_run, fork, star, watch
|
|
51
|
+
* - push events with refs/tags/ prefix return type: 'tag'
|
|
52
|
+
*
|
|
53
|
+
* Returns null for events not in the supported list.
|
|
54
|
+
*/
|
|
55
|
+
normalizeEvent(eventType: string, action: string | null, payload: unknown): SimulatedEvent | null;
|
|
56
|
+
/**
|
|
57
|
+
* Extract repository identifier from a GitHub webhook payload.
|
|
58
|
+
*
|
|
59
|
+
* Prefers repository.full_name, falls back to owner.login/name.
|
|
60
|
+
*/
|
|
61
|
+
extractRepoIdentifier(payload: unknown): string | null;
|
|
62
|
+
/**
|
|
63
|
+
* Extract commit SHA or ref from a GitHub webhook payload.
|
|
64
|
+
*
|
|
65
|
+
* Maps each GitHub event type to the appropriate payload field
|
|
66
|
+
* for lock file fetching.
|
|
67
|
+
*/
|
|
68
|
+
extractRef(eventType: string, payload: unknown): string;
|
|
69
|
+
/**
|
|
70
|
+
* Extract GitHub-specific credentials from a webhook payload.
|
|
71
|
+
*
|
|
72
|
+
* Extracts installationId from payload.installation.id, needed for
|
|
73
|
+
* generating installation tokens for repo access.
|
|
74
|
+
*/
|
|
75
|
+
extractCredentials(payload: unknown): Record<string, unknown>;
|
|
76
|
+
/**
|
|
77
|
+
* Map GitHub membership-related webhook events to ContributorCache
|
|
78
|
+
* invalidations. See WebhookNormalizer.getAccessCacheInvalidations.
|
|
79
|
+
*
|
|
80
|
+
* Covered event types:
|
|
81
|
+
*
|
|
82
|
+
* - `member` (`added` / `removed` / `edited`): a collaborator's repo
|
|
83
|
+
* permission changed -> `repo-user` invalidation for the exact
|
|
84
|
+
* `{repo, user}` pair.
|
|
85
|
+
* - `organization` (`member_added` / `member_removed`): a user was added
|
|
86
|
+
* to or removed from the org. The user's effective permission on every
|
|
87
|
+
* repo under the org may have shifted -> `user-in-org`.
|
|
88
|
+
* - `membership` (`added` / `removed`, usually team scope): same reasoning
|
|
89
|
+
* as `organization`. Slightly broader than strictly required, but the
|
|
90
|
+
* cache refills cheaply and over-invalidation is safe.
|
|
91
|
+
* - `team` (`added_to_repository` / `removed_from_repository`): every
|
|
92
|
+
* member of the team gained or lost repo access -> `repo`.
|
|
93
|
+
*
|
|
94
|
+
* Any other event type (including other `team` actions like `created` /
|
|
95
|
+
* `deleted` / `edited` which carry no repo context) returns `[]`.
|
|
96
|
+
*
|
|
97
|
+
* Payload fields are probed defensively; a missing field returns `[]`
|
|
98
|
+
* rather than throwing — this is best-effort and we do not want a
|
|
99
|
+
* malformed payload to crash webhook processing.
|
|
100
|
+
*/
|
|
101
|
+
getAccessCacheInvalidations(eventType: string, _action: string | null, payload: unknown): AccessCacheInvalidation[];
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=normalizer.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub repository URL builder.
|
|
3
|
+
*
|
|
4
|
+
* Implements the RepoUrlBuilder interface from @kici-dev/engine for GitHub.
|
|
5
|
+
* Constructs HTTPS clone URLs and raw file access URLs.
|
|
6
|
+
*/
|
|
7
|
+
import type { RepoUrlBuilder } from '@kici-dev/engine';
|
|
8
|
+
/**
|
|
9
|
+
* GitHub-specific implementation of RepoUrlBuilder.
|
|
10
|
+
*
|
|
11
|
+
* Builds URLs for github.com repositories.
|
|
12
|
+
* repoIdentifier is expected in "owner/repo" format.
|
|
13
|
+
*/
|
|
14
|
+
export declare class GitHubRepoUrlBuilder implements RepoUrlBuilder {
|
|
15
|
+
readonly provider: "github";
|
|
16
|
+
/**
|
|
17
|
+
* Build the HTTPS clone URL for a GitHub repository.
|
|
18
|
+
*
|
|
19
|
+
* @param repoIdentifier - "owner/repo" format
|
|
20
|
+
* @returns https://github.com/owner/repo.git
|
|
21
|
+
*/
|
|
22
|
+
buildCloneUrl(repoIdentifier: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Build the raw file URL for a file at a specific ref.
|
|
25
|
+
*
|
|
26
|
+
* Uses GitHub's raw endpoint for direct file access.
|
|
27
|
+
*
|
|
28
|
+
* @param repoIdentifier - "owner/repo" format
|
|
29
|
+
* @param ref - Git ref (branch, tag, SHA)
|
|
30
|
+
* @param path - File path relative to repo root
|
|
31
|
+
* @returns https://github.com/owner/repo/raw/ref/path
|
|
32
|
+
*/
|
|
33
|
+
buildRawFileUrl(repoIdentifier: string, ref: string, path: string): string;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=repo-url.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal provider implementations for KiCI E2E tests.
|
|
3
|
+
*
|
|
4
|
+
* Provides a complete provider bundle for testing the webhook processing pipeline
|
|
5
|
+
* without GitHub dependencies. Uses file:// URLs for cloning and reads lock files
|
|
6
|
+
* directly from the filesystem.
|
|
7
|
+
*
|
|
8
|
+
* Classes:
|
|
9
|
+
* - InternalWebhookNormalizer -> WebhookNormalizer (extracts from custom headers)
|
|
10
|
+
* - InternalLockFileFetcher -> LockFileFetcher (reads from local filesystem)
|
|
11
|
+
* - InternalRepoUrlBuilder -> RepoUrlBuilder (returns file:// URLs)
|
|
12
|
+
*/
|
|
13
|
+
import type { ProviderBundle } from '../../provider-registry.js';
|
|
14
|
+
export { InternalWebhookNormalizer } from './normalizer.js';
|
|
15
|
+
export { InternalLockFileFetcher } from './lock-file-fetcher.js';
|
|
16
|
+
export { InternalRepoUrlBuilder } from './repo-url-builder.js';
|
|
17
|
+
/**
|
|
18
|
+
* Create a ProviderBundle for internal/test webhook sources.
|
|
19
|
+
*
|
|
20
|
+
* Provides normalizer, lock file fetcher, and repo URL builder.
|
|
21
|
+
* Clone token provider and changed files fetcher are null since
|
|
22
|
+
* file:// URLs need no auth and internal events don't track changed files.
|
|
23
|
+
*
|
|
24
|
+
* @param opts.repoBasePath - Base directory where test repos live on disk
|
|
25
|
+
* @param opts.cloneUrlBase - Optional URL base for clone operations (e.g. git://host/path)
|
|
26
|
+
* @returns Complete ProviderBundle for internal provider
|
|
27
|
+
*/
|
|
28
|
+
export declare function createInternalProviderBundle(opts: {
|
|
29
|
+
repoBasePath: string;
|
|
30
|
+
cloneUrlBase?: string;
|
|
31
|
+
}): ProviderBundle;
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal lock file fetcher for E2E tests.
|
|
3
|
+
*
|
|
4
|
+
* Implements the LockFileFetcher interface from @kici-dev/engine by reading
|
|
5
|
+
* kici.lock.json directly from the local filesystem. Used when the internal
|
|
6
|
+
* provider processes webhooks for repos accessible via file:// URLs.
|
|
7
|
+
*/
|
|
8
|
+
import type { LockFileFetcher, LockFile } from '@kici-dev/engine';
|
|
9
|
+
/**
|
|
10
|
+
* Internal provider implementation of LockFileFetcher.
|
|
11
|
+
*
|
|
12
|
+
* Reads kici.lock.json from the local filesystem at the path derived from
|
|
13
|
+
* the repoIdentifier (which is expected to be a file:// URL or a local path).
|
|
14
|
+
*/
|
|
15
|
+
export declare class InternalLockFileFetcher implements LockFileFetcher {
|
|
16
|
+
private readonly repoBasePath;
|
|
17
|
+
readonly provider: "internal";
|
|
18
|
+
/**
|
|
19
|
+
* @param repoBasePath - Base directory for test repos. When repoIdentifier
|
|
20
|
+
* starts with 'file://', it is stripped and used as-is. Otherwise
|
|
21
|
+
* repoBasePath is used as the root.
|
|
22
|
+
*/
|
|
23
|
+
constructor(repoBasePath: string);
|
|
24
|
+
/**
|
|
25
|
+
* Fetch the lock file from the local filesystem.
|
|
26
|
+
*
|
|
27
|
+
* @param repoIdentifier - Either a file:// URL or a relative path under repoBasePath
|
|
28
|
+
* @param _ref - Git ref (ignored for filesystem access -- always reads current state)
|
|
29
|
+
* @param _credentials - Not used (file:// access needs no auth)
|
|
30
|
+
* @returns Parsed LockFile, or null if not found
|
|
31
|
+
*/
|
|
32
|
+
fetchLockFile(repoIdentifier: string, _ref: string, _credentials: unknown): Promise<LockFile | null>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=lock-file-fetcher.d.ts.map
|