@vibecheckai/cli 2.8.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/bin/_deprecations.js +35 -0
- package/bin/_router.js +46 -0
- package/bin/cli-hygiene.js +241 -0
- package/bin/guardrail.js +834 -0
- package/bin/runners/cli-utils.js +1070 -0
- package/bin/runners/context/ai-task-decomposer.js +337 -0
- package/bin/runners/context/analyzer.js +462 -0
- package/bin/runners/context/api-contracts.js +427 -0
- package/bin/runners/context/context-diff.js +342 -0
- package/bin/runners/context/context-pruner.js +291 -0
- package/bin/runners/context/dependency-graph.js +414 -0
- package/bin/runners/context/generators/claude.js +107 -0
- package/bin/runners/context/generators/codex.js +108 -0
- package/bin/runners/context/generators/copilot.js +119 -0
- package/bin/runners/context/generators/cursor.js +514 -0
- package/bin/runners/context/generators/mcp.js +151 -0
- package/bin/runners/context/generators/windsurf.js +180 -0
- package/bin/runners/context/git-context.js +302 -0
- package/bin/runners/context/index.js +1042 -0
- package/bin/runners/context/insights.js +173 -0
- package/bin/runners/context/mcp-server/generate-rules.js +337 -0
- package/bin/runners/context/mcp-server/index.js +1176 -0
- package/bin/runners/context/mcp-server/package.json +24 -0
- package/bin/runners/context/memory.js +200 -0
- package/bin/runners/context/monorepo.js +215 -0
- package/bin/runners/context/multi-repo-federation.js +404 -0
- package/bin/runners/context/patterns.js +253 -0
- package/bin/runners/context/proof-context.js +972 -0
- package/bin/runners/context/security-scanner.js +303 -0
- package/bin/runners/context/semantic-search.js +350 -0
- package/bin/runners/context/shared.js +264 -0
- package/bin/runners/context/team-conventions.js +310 -0
- package/bin/runners/lib/ai-bridge.js +416 -0
- package/bin/runners/lib/analysis-core.js +271 -0
- package/bin/runners/lib/analyzers.js +541 -0
- package/bin/runners/lib/audit-bridge.js +391 -0
- package/bin/runners/lib/auth-truth.js +193 -0
- package/bin/runners/lib/auth.js +215 -0
- package/bin/runners/lib/backup.js +62 -0
- package/bin/runners/lib/billing.js +107 -0
- package/bin/runners/lib/claims.js +118 -0
- package/bin/runners/lib/cli-ui.js +540 -0
- package/bin/runners/lib/compliance-bridge-new.js +0 -0
- package/bin/runners/lib/compliance-bridge.js +165 -0
- package/bin/runners/lib/contracts/auth-contract.js +194 -0
- package/bin/runners/lib/contracts/env-contract.js +178 -0
- package/bin/runners/lib/contracts/external-contract.js +198 -0
- package/bin/runners/lib/contracts/guard.js +168 -0
- package/bin/runners/lib/contracts/index.js +89 -0
- package/bin/runners/lib/contracts/plan-validator.js +311 -0
- package/bin/runners/lib/contracts/route-contract.js +192 -0
- package/bin/runners/lib/detect.js +89 -0
- package/bin/runners/lib/doctor/autofix.js +254 -0
- package/bin/runners/lib/doctor/index.js +37 -0
- package/bin/runners/lib/doctor/modules/dependencies.js +325 -0
- package/bin/runners/lib/doctor/modules/index.js +46 -0
- package/bin/runners/lib/doctor/modules/network.js +250 -0
- package/bin/runners/lib/doctor/modules/project.js +312 -0
- package/bin/runners/lib/doctor/modules/runtime.js +224 -0
- package/bin/runners/lib/doctor/modules/security.js +348 -0
- package/bin/runners/lib/doctor/modules/system.js +213 -0
- package/bin/runners/lib/doctor/modules/vibecheck.js +394 -0
- package/bin/runners/lib/doctor/reporter.js +262 -0
- package/bin/runners/lib/doctor/service.js +262 -0
- package/bin/runners/lib/doctor/types.js +113 -0
- package/bin/runners/lib/doctor/ui.js +263 -0
- package/bin/runners/lib/doctor-enhanced.js +233 -0
- package/bin/runners/lib/doctor-v2.js +608 -0
- package/bin/runners/lib/enforcement.js +72 -0
- package/bin/runners/lib/enterprise-detect.js +603 -0
- package/bin/runners/lib/enterprise-init.js +942 -0
- package/bin/runners/lib/entitlements-v2.js +381 -0
- package/bin/runners/lib/entitlements.generated.js +0 -0
- package/bin/runners/lib/entitlements.js +332 -0
- package/bin/runners/lib/env-template.js +66 -0
- package/bin/runners/lib/env.js +189 -0
- package/bin/runners/lib/error-handler.js +320 -0
- package/bin/runners/lib/firewall-prompt.js +50 -0
- package/bin/runners/lib/graph/graph-builder.js +265 -0
- package/bin/runners/lib/graph/html-renderer.js +413 -0
- package/bin/runners/lib/graph/index.js +32 -0
- package/bin/runners/lib/graph/runtime-collector.js +215 -0
- package/bin/runners/lib/graph/static-extractor.js +518 -0
- package/bin/runners/lib/init-wizard.js +308 -0
- package/bin/runners/lib/json-output.js +76 -0
- package/bin/runners/lib/llm.js +75 -0
- package/bin/runners/lib/meter.js +61 -0
- package/bin/runners/lib/missions/evidence.js +126 -0
- package/bin/runners/lib/missions/plan.js +69 -0
- package/bin/runners/lib/missions/templates.js +147 -0
- package/bin/runners/lib/patch.js +40 -0
- package/bin/runners/lib/permissions/auth-model.js +213 -0
- package/bin/runners/lib/permissions/idor-prover.js +205 -0
- package/bin/runners/lib/permissions/index.js +45 -0
- package/bin/runners/lib/permissions/matrix-builder.js +198 -0
- package/bin/runners/lib/pkgjson.js +28 -0
- package/bin/runners/lib/preflight.js +142 -0
- package/bin/runners/lib/reality-findings.js +84 -0
- package/bin/runners/lib/redact.js +29 -0
- package/bin/runners/lib/replay/capsule-manager.js +154 -0
- package/bin/runners/lib/replay/index.js +263 -0
- package/bin/runners/lib/replay/player.js +348 -0
- package/bin/runners/lib/replay/recorder.js +331 -0
- package/bin/runners/lib/report-engine.js +447 -0
- package/bin/runners/lib/report-html.js +1117 -0
- package/bin/runners/lib/report-templates.js +964 -0
- package/bin/runners/lib/route-detection.js +1140 -0
- package/bin/runners/lib/route-truth.js +477 -0
- package/bin/runners/lib/sandbox/index.js +59 -0
- package/bin/runners/lib/sandbox/proof-chain.js +399 -0
- package/bin/runners/lib/sandbox/sandbox-runner.js +205 -0
- package/bin/runners/lib/sandbox/worktree.js +174 -0
- package/bin/runners/lib/scan-cache.js +330 -0
- package/bin/runners/lib/scan-output-schema.js +344 -0
- package/bin/runners/lib/score-history.js +282 -0
- package/bin/runners/lib/security-bridge.js +249 -0
- package/bin/runners/lib/server-usage.js +513 -0
- package/bin/runners/lib/share-pack.js +239 -0
- package/bin/runners/lib/snippets.js +67 -0
- package/bin/runners/lib/truth.js +667 -0
- package/bin/runners/lib/unified-output.js +189 -0
- package/bin/runners/lib/validate-patch.js +156 -0
- package/bin/runners/lib/verification.js +345 -0
- package/bin/runners/reality/engine.js +917 -0
- package/bin/runners/reality/flows.js +122 -0
- package/bin/runners/reality/report.js +378 -0
- package/bin/runners/reality/session.js +193 -0
- package/bin/runners/runAIAgent.js +2 -0
- package/bin/runners/runAudit.js +2 -0
- package/bin/runners/runAuth.js +106 -0
- package/bin/runners/runAutopilot.js +2 -0
- package/bin/runners/runBadge.js +2 -0
- package/bin/runners/runCertify.js +2 -0
- package/bin/runners/runClaimVerifier.js +483 -0
- package/bin/runners/runContext.js +56 -0
- package/bin/runners/runContextCompiler.js +385 -0
- package/bin/runners/runCtx.js +187 -0
- package/bin/runners/runCtxGuard.js +176 -0
- package/bin/runners/runCtxSync.js +116 -0
- package/bin/runners/runDashboard.js +10 -0
- package/bin/runners/runDoctor.js +245 -0
- package/bin/runners/runEnhancedShip.js +2 -0
- package/bin/runners/runFix.js +735 -0
- package/bin/runners/runFixPacks.js +2 -0
- package/bin/runners/runGate.js +17 -0
- package/bin/runners/runGraph.js +283 -0
- package/bin/runners/runInit.js +260 -0
- package/bin/runners/runInitGha.js +101 -0
- package/bin/runners/runInstall.js +76 -0
- package/bin/runners/runInteractive.js +388 -0
- package/bin/runners/runLaunch.js +2 -0
- package/bin/runners/runMcp.js +19 -0
- package/bin/runners/runMdc.js +2 -0
- package/bin/runners/runMissionGenerator.js +282 -0
- package/bin/runners/runNaturalLanguage.js +3 -0
- package/bin/runners/runPR.js +96 -0
- package/bin/runners/runPermissions.js +290 -0
- package/bin/runners/runPromptFirewall.js +211 -0
- package/bin/runners/runProof.js +2 -0
- package/bin/runners/runProve.js +392 -0
- package/bin/runners/runReality.js +489 -0
- package/bin/runners/runRealitySniff.js +2 -0
- package/bin/runners/runReplay.js +469 -0
- package/bin/runners/runReport.js +478 -0
- package/bin/runners/runScan.js +835 -0
- package/bin/runners/runShare.js +34 -0
- package/bin/runners/runShip.js +1062 -0
- package/bin/runners/runStatus.js +136 -0
- package/bin/runners/runTruthpack.js +634 -0
- package/bin/runners/runUpgrade.js +2 -0
- package/bin/runners/runValidate.js +2 -0
- package/bin/runners/runVerifyAgentOutput.js +2 -0
- package/bin/runners/runWatch.js +230 -0
- package/bin/runners/utils.js +360 -0
- package/bin/scan.js +612 -0
- package/bin/vibecheck.js +834 -0
- package/package.json +11 -11
- package/dist/autopatch/verified-autopatch.d.ts +0 -111
- package/dist/autopatch/verified-autopatch.d.ts.map +0 -1
- package/dist/autopatch/verified-autopatch.js +0 -503
- package/dist/autopatch/verified-autopatch.js.map +0 -1
- package/dist/bundles/index.js +0 -8
- package/dist/bundles/vibecheck-core.js +0 -25799
- package/dist/bundles/vibecheck-security.js +0 -208693
- package/dist/bundles/vibecheck-ship.js +0 -2318
- package/dist/commands/baseline.d.ts +0 -7
- package/dist/commands/baseline.d.ts.map +0 -1
- package/dist/commands/baseline.js +0 -79
- package/dist/commands/baseline.js.map +0 -1
- package/dist/commands/cache.d.ts +0 -13
- package/dist/commands/cache.d.ts.map +0 -1
- package/dist/commands/cache.js +0 -165
- package/dist/commands/cache.js.map +0 -1
- package/dist/commands/checkpoint.d.ts +0 -8
- package/dist/commands/checkpoint.d.ts.map +0 -1
- package/dist/commands/checkpoint.js +0 -35
- package/dist/commands/checkpoint.js.map +0 -1
- package/dist/commands/doctor.d.ts +0 -17
- package/dist/commands/doctor.d.ts.map +0 -1
- package/dist/commands/doctor.js +0 -226
- package/dist/commands/doctor.js.map +0 -1
- package/dist/commands/evidence.d.ts +0 -45
- package/dist/commands/evidence.d.ts.map +0 -1
- package/dist/commands/evidence.js +0 -197
- package/dist/commands/evidence.js.map +0 -1
- package/dist/commands/explain.d.ts +0 -8
- package/dist/commands/explain.d.ts.map +0 -1
- package/dist/commands/explain.js +0 -52
- package/dist/commands/explain.js.map +0 -1
- package/dist/commands/fix-consolidated.d.ts +0 -19
- package/dist/commands/fix-consolidated.d.ts.map +0 -1
- package/dist/commands/fix-consolidated.js +0 -165
- package/dist/commands/fix-consolidated.js.map +0 -1
- package/dist/commands/index.d.ts +0 -8
- package/dist/commands/index.d.ts.map +0 -1
- package/dist/commands/index.js +0 -15
- package/dist/commands/index.js.map +0 -1
- package/dist/commands/init.d.ts +0 -8
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js +0 -125
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/launcher.d.ts +0 -10
- package/dist/commands/launcher.d.ts.map +0 -1
- package/dist/commands/launcher.js +0 -174
- package/dist/commands/launcher.js.map +0 -1
- package/dist/commands/on.d.ts +0 -8
- package/dist/commands/on.d.ts.map +0 -1
- package/dist/commands/on.js +0 -123
- package/dist/commands/on.js.map +0 -1
- package/dist/commands/replay.d.ts +0 -8
- package/dist/commands/replay.d.ts.map +0 -1
- package/dist/commands/replay.js +0 -52
- package/dist/commands/replay.js.map +0 -1
- package/dist/commands/scan-consolidated.d.ts +0 -61
- package/dist/commands/scan-consolidated.d.ts.map +0 -1
- package/dist/commands/scan-consolidated.js +0 -243
- package/dist/commands/scan-consolidated.js.map +0 -1
- package/dist/commands/scan-secrets.d.ts +0 -47
- package/dist/commands/scan-secrets.d.ts.map +0 -1
- package/dist/commands/scan-secrets.js +0 -225
- package/dist/commands/scan-secrets.js.map +0 -1
- package/dist/commands/scan-vulnerabilities-enhanced.d.ts +0 -41
- package/dist/commands/scan-vulnerabilities-enhanced.d.ts.map +0 -1
- package/dist/commands/scan-vulnerabilities-enhanced.js +0 -368
- package/dist/commands/scan-vulnerabilities-enhanced.js.map +0 -1
- package/dist/commands/scan-vulnerabilities-osv.d.ts +0 -58
- package/dist/commands/scan-vulnerabilities-osv.d.ts.map +0 -1
- package/dist/commands/scan-vulnerabilities-osv.js +0 -722
- package/dist/commands/scan-vulnerabilities-osv.js.map +0 -1
- package/dist/commands/scan-vulnerabilities.d.ts +0 -32
- package/dist/commands/scan-vulnerabilities.d.ts.map +0 -1
- package/dist/commands/scan-vulnerabilities.js +0 -283
- package/dist/commands/scan-vulnerabilities.js.map +0 -1
- package/dist/commands/secrets-allowlist.d.ts +0 -7
- package/dist/commands/secrets-allowlist.d.ts.map +0 -1
- package/dist/commands/secrets-allowlist.js +0 -85
- package/dist/commands/secrets-allowlist.js.map +0 -1
- package/dist/commands/ship-consolidated.d.ts +0 -58
- package/dist/commands/ship-consolidated.d.ts.map +0 -1
- package/dist/commands/ship-consolidated.js +0 -515
- package/dist/commands/ship-consolidated.js.map +0 -1
- package/dist/commands/stats.d.ts +0 -8
- package/dist/commands/stats.d.ts.map +0 -1
- package/dist/commands/stats.js +0 -134
- package/dist/commands/stats.js.map +0 -1
- package/dist/commands/upgrade.d.ts +0 -8
- package/dist/commands/upgrade.d.ts.map +0 -1
- package/dist/commands/upgrade.js +0 -30
- package/dist/commands/upgrade.js.map +0 -1
- package/dist/fix/applicator.d.ts +0 -44
- package/dist/fix/applicator.d.ts.map +0 -1
- package/dist/fix/applicator.js +0 -144
- package/dist/fix/applicator.js.map +0 -1
- package/dist/fix/backup.d.ts +0 -38
- package/dist/fix/backup.d.ts.map +0 -1
- package/dist/fix/backup.js +0 -154
- package/dist/fix/backup.js.map +0 -1
- package/dist/fix/engine.d.ts +0 -55
- package/dist/fix/engine.d.ts.map +0 -1
- package/dist/fix/engine.js +0 -285
- package/dist/fix/engine.js.map +0 -1
- package/dist/fix/index.d.ts +0 -5
- package/dist/fix/index.d.ts.map +0 -1
- package/dist/fix/index.js +0 -12
- package/dist/fix/index.js.map +0 -1
- package/dist/fix/interactive.d.ts +0 -22
- package/dist/fix/interactive.d.ts.map +0 -1
- package/dist/fix/interactive.js +0 -172
- package/dist/fix/interactive.js.map +0 -1
- package/dist/formatters/index.d.ts +0 -6
- package/dist/formatters/index.d.ts.map +0 -1
- package/dist/formatters/index.js +0 -11
- package/dist/formatters/index.js.map +0 -1
- package/dist/formatters/sarif-enhanced.d.ts +0 -78
- package/dist/formatters/sarif-enhanced.d.ts.map +0 -1
- package/dist/formatters/sarif-enhanced.js +0 -144
- package/dist/formatters/sarif-enhanced.js.map +0 -1
- package/dist/formatters/sarif-v2.d.ts +0 -121
- package/dist/formatters/sarif-v2.d.ts.map +0 -1
- package/dist/formatters/sarif-v2.js +0 -356
- package/dist/formatters/sarif-v2.js.map +0 -1
- package/dist/formatters/sarif.d.ts +0 -72
- package/dist/formatters/sarif.d.ts.map +0 -1
- package/dist/formatters/sarif.js +0 -146
- package/dist/formatters/sarif.js.map +0 -1
- package/dist/index.d.ts +0 -61
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -4388
- package/dist/index.js.map +0 -1
- package/dist/init/ci-generator.d.ts +0 -18
- package/dist/init/ci-generator.d.ts.map +0 -1
- package/dist/init/ci-generator.js +0 -317
- package/dist/init/ci-generator.js.map +0 -1
- package/dist/init/detect-framework.d.ts +0 -15
- package/dist/init/detect-framework.d.ts.map +0 -1
- package/dist/init/detect-framework.js +0 -301
- package/dist/init/detect-framework.js.map +0 -1
- package/dist/init/hooks-installer.d.ts +0 -22
- package/dist/init/hooks-installer.d.ts.map +0 -1
- package/dist/init/hooks-installer.js +0 -310
- package/dist/init/hooks-installer.js.map +0 -1
- package/dist/init/index.d.ts +0 -8
- package/dist/init/index.d.ts.map +0 -1
- package/dist/init/index.js +0 -22
- package/dist/init/index.js.map +0 -1
- package/dist/init/templates.d.ts +0 -402
- package/dist/init/templates.d.ts.map +0 -1
- package/dist/init/templates.js +0 -240
- package/dist/init/templates.js.map +0 -1
- package/dist/mcp/server.d.ts +0 -12
- package/dist/mcp/server.d.ts.map +0 -1
- package/dist/mcp/server.js +0 -42
- package/dist/mcp/server.js.map +0 -1
- package/dist/mcp/telemetry.d.ts +0 -40
- package/dist/mcp/telemetry.d.ts.map +0 -1
- package/dist/mcp/telemetry.js +0 -98
- package/dist/mcp/telemetry.js.map +0 -1
- package/dist/reality/no-dead-buttons/button-sweep-generator.d.ts +0 -32
- package/dist/reality/no-dead-buttons/button-sweep-generator.d.ts.map +0 -1
- package/dist/reality/no-dead-buttons/button-sweep-generator.js +0 -236
- package/dist/reality/no-dead-buttons/button-sweep-generator.js.map +0 -1
- package/dist/reality/no-dead-buttons/index.d.ts +0 -11
- package/dist/reality/no-dead-buttons/index.d.ts.map +0 -1
- package/dist/reality/no-dead-buttons/index.js +0 -18
- package/dist/reality/no-dead-buttons/index.js.map +0 -1
- package/dist/reality/no-dead-buttons/static-scanner.d.ts +0 -34
- package/dist/reality/no-dead-buttons/static-scanner.d.ts.map +0 -1
- package/dist/reality/no-dead-buttons/static-scanner.js +0 -230
- package/dist/reality/no-dead-buttons/static-scanner.js.map +0 -1
- package/dist/reality/reality-graph.d.ts +0 -192
- package/dist/reality/reality-graph.d.ts.map +0 -1
- package/dist/reality/reality-graph.js +0 -600
- package/dist/reality/reality-graph.js.map +0 -1
- package/dist/reality/reality-runner.d.ts +0 -89
- package/dist/reality/reality-runner.d.ts.map +0 -1
- package/dist/reality/reality-runner.js +0 -540
- package/dist/reality/reality-runner.js.map +0 -1
- package/dist/reality/receipt-generator.d.ts +0 -152
- package/dist/reality/receipt-generator.d.ts.map +0 -1
- package/dist/reality/receipt-generator.js +0 -495
- package/dist/reality/receipt-generator.js.map +0 -1
- package/dist/reality/runtime-tracer.d.ts +0 -75
- package/dist/reality/runtime-tracer.d.ts.map +0 -1
- package/dist/reality/runtime-tracer.js +0 -109
- package/dist/reality/runtime-tracer.js.map +0 -1
- package/dist/runtime/auth-utils.d.ts +0 -43
- package/dist/runtime/auth-utils.d.ts.map +0 -1
- package/dist/runtime/auth-utils.js +0 -130
- package/dist/runtime/auth-utils.js.map +0 -1
- package/dist/runtime/client.d.ts +0 -74
- package/dist/runtime/client.d.ts.map +0 -1
- package/dist/runtime/client.js +0 -222
- package/dist/runtime/client.js.map +0 -1
- package/dist/runtime/creds.d.ts +0 -48
- package/dist/runtime/creds.d.ts.map +0 -1
- package/dist/runtime/creds.js +0 -245
- package/dist/runtime/creds.js.map +0 -1
- package/dist/runtime/exit-codes.d.ts +0 -49
- package/dist/runtime/exit-codes.d.ts.map +0 -1
- package/dist/runtime/exit-codes.js +0 -93
- package/dist/runtime/exit-codes.js.map +0 -1
- package/dist/runtime/index.d.ts +0 -9
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/runtime/index.js +0 -25
- package/dist/runtime/index.js.map +0 -1
- package/dist/runtime/json-output.d.ts +0 -42
- package/dist/runtime/json-output.d.ts.map +0 -1
- package/dist/runtime/json-output.js +0 -59
- package/dist/runtime/json-output.js.map +0 -1
- package/dist/runtime/semver.d.ts +0 -37
- package/dist/runtime/semver.d.ts.map +0 -1
- package/dist/runtime/semver.js +0 -110
- package/dist/runtime/semver.js.map +0 -1
- package/dist/scan/dead-ui-detector.d.ts +0 -48
- package/dist/scan/dead-ui-detector.d.ts.map +0 -1
- package/dist/scan/dead-ui-detector.js +0 -170
- package/dist/scan/dead-ui-detector.js.map +0 -1
- package/dist/scan/playwright-sweep.d.ts +0 -40
- package/dist/scan/playwright-sweep.d.ts.map +0 -1
- package/dist/scan/playwright-sweep.js +0 -216
- package/dist/scan/playwright-sweep.js.map +0 -1
- package/dist/scan/proof-bundle.d.ts +0 -25
- package/dist/scan/proof-bundle.d.ts.map +0 -1
- package/dist/scan/proof-bundle.js +0 -203
- package/dist/scan/proof-bundle.js.map +0 -1
- package/dist/scan/proof-graph.d.ts +0 -59
- package/dist/scan/proof-graph.d.ts.map +0 -1
- package/dist/scan/proof-graph.js +0 -64
- package/dist/scan/proof-graph.js.map +0 -1
- package/dist/scan/reality-sniff.d.ts +0 -56
- package/dist/scan/reality-sniff.d.ts.map +0 -1
- package/dist/scan/reality-sniff.js +0 -200
- package/dist/scan/reality-sniff.js.map +0 -1
- package/dist/scan/structural-verifier.d.ts +0 -20
- package/dist/scan/structural-verifier.d.ts.map +0 -1
- package/dist/scan/structural-verifier.js +0 -112
- package/dist/scan/structural-verifier.js.map +0 -1
- package/dist/scan/verification-engine.d.ts +0 -47
- package/dist/scan/verification-engine.d.ts.map +0 -1
- package/dist/scan/verification-engine.js +0 -141
- package/dist/scan/verification-engine.js.map +0 -1
- package/dist/scanner/baseline.d.ts +0 -52
- package/dist/scanner/baseline.d.ts.map +0 -1
- package/dist/scanner/baseline.js +0 -85
- package/dist/scanner/baseline.js.map +0 -1
- package/dist/scanner/incremental.d.ts +0 -30
- package/dist/scanner/incremental.d.ts.map +0 -1
- package/dist/scanner/incremental.js +0 -82
- package/dist/scanner/incremental.js.map +0 -1
- package/dist/scanner/parallel.d.ts +0 -43
- package/dist/scanner/parallel.d.ts.map +0 -1
- package/dist/scanner/parallel.js +0 -99
- package/dist/scanner/parallel.js.map +0 -1
- package/dist/standalone.d.ts +0 -1
- package/dist/standalone.d.ts.map +0 -1
- package/dist/standalone.js +0 -1
- package/dist/standalone.js.map +0 -1
- package/dist/truth-pack/index.d.ts +0 -102
- package/dist/truth-pack/index.d.ts.map +0 -1
- package/dist/truth-pack/index.js +0 -694
- package/dist/truth-pack/index.js.map +0 -1
- package/dist/ui/frame.d.ts +0 -68
- package/dist/ui/frame.d.ts.map +0 -1
- package/dist/ui/frame.js +0 -165
- package/dist/ui/frame.js.map +0 -1
- package/dist/ui/index.d.ts +0 -5
- package/dist/ui/index.d.ts.map +0 -1
- package/dist/ui/index.js +0 -16
- package/dist/ui/index.js.map +0 -1
- package/dist/ui.d.ts +0 -36
- package/dist/ui.d.ts.map +0 -1
- package/dist/ui.js +0 -45
- package/dist/ui.js.map +0 -1
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runtime Tracer
|
|
3
|
-
*
|
|
4
|
-
* Collects runtime traces during execution:
|
|
5
|
-
* - HTTP requests made
|
|
6
|
-
* - Routes hit
|
|
7
|
-
* - Database queries executed
|
|
8
|
-
*/
|
|
9
|
-
export interface RuntimeTrace {
|
|
10
|
-
requests: Array<{
|
|
11
|
-
method: string;
|
|
12
|
-
url: string;
|
|
13
|
-
statusCode: number;
|
|
14
|
-
timestamp: string;
|
|
15
|
-
duration: number;
|
|
16
|
-
headers?: Record<string, string>;
|
|
17
|
-
}>;
|
|
18
|
-
routes: Array<{
|
|
19
|
-
path: string;
|
|
20
|
-
method: string;
|
|
21
|
-
hit: boolean;
|
|
22
|
-
timestamp: string;
|
|
23
|
-
responseTime?: number;
|
|
24
|
-
}>;
|
|
25
|
-
dbQueries: Array<{
|
|
26
|
-
query: string;
|
|
27
|
-
duration: number;
|
|
28
|
-
timestamp: string;
|
|
29
|
-
table?: string;
|
|
30
|
-
}>;
|
|
31
|
-
}
|
|
32
|
-
declare class RuntimeTracer {
|
|
33
|
-
private traces;
|
|
34
|
-
/**
|
|
35
|
-
* Record an HTTP request
|
|
36
|
-
*/
|
|
37
|
-
recordRequest(method: string, url: string, statusCode: number, duration: number, headers?: Record<string, string>): void;
|
|
38
|
-
/**
|
|
39
|
-
* Record a route hit
|
|
40
|
-
*/
|
|
41
|
-
recordRoute(path: string, method: string, hit: boolean, responseTime?: number): void;
|
|
42
|
-
/**
|
|
43
|
-
* Record a database query
|
|
44
|
-
*/
|
|
45
|
-
recordDbQuery(query: string, duration: number, table?: string): void;
|
|
46
|
-
/**
|
|
47
|
-
* Get all traces
|
|
48
|
-
*/
|
|
49
|
-
getTraces(): RuntimeTrace;
|
|
50
|
-
/**
|
|
51
|
-
* Reset traces
|
|
52
|
-
*/
|
|
53
|
-
reset(): void;
|
|
54
|
-
}
|
|
55
|
-
export declare const runtimeTracer: RuntimeTracer;
|
|
56
|
-
/**
|
|
57
|
-
* Playwright request interceptor for tracing HTTP requests
|
|
58
|
-
*/
|
|
59
|
-
export declare function createRequestInterceptor(): (request: any) => void;
|
|
60
|
-
/**
|
|
61
|
-
* Playwright response interceptor for tracing HTTP responses
|
|
62
|
-
*/
|
|
63
|
-
export declare function createResponseInterceptor(): (response: any) => Promise<void>;
|
|
64
|
-
/**
|
|
65
|
-
* Extract routes from Playwright trace or network logs
|
|
66
|
-
*/
|
|
67
|
-
export declare function extractRoutesFromTrace(tracePath: string): Array<{
|
|
68
|
-
path: string;
|
|
69
|
-
method: string;
|
|
70
|
-
hit: boolean;
|
|
71
|
-
timestamp: string;
|
|
72
|
-
responseTime?: number;
|
|
73
|
-
}>;
|
|
74
|
-
export {};
|
|
75
|
-
//# sourceMappingURL=runtime-tracer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-tracer.d.ts","sourceRoot":"","sources":["../../src/reality/runtime-tracer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,KAAK,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,EAAE,MAAM,CAAC;QACZ,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAClC,CAAC,CAAC;IACH,MAAM,EAAE,KAAK,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,EAAE,OAAO,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC,CAAC;IACH,SAAS,EAAE,KAAK,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;CACJ;AAED,cAAM,aAAa;IACjB,OAAO,CAAC,MAAM,CAIZ;IAEF;;OAEG;IACH,aAAa,CACX,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,IAAI;IAWP;;OAEG;IACH,WAAW,CACT,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,OAAO,EACZ,YAAY,CAAC,EAAE,MAAM,GACpB,IAAI;IAUP;;OAEG;IACH,aAAa,CACX,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,MAAM,GACb,IAAI;IASP;;OAEG;IACH,SAAS,IAAI,YAAY;IAIzB;;OAEG;IACH,KAAK,IAAI,IAAI;CAOd;AAGD,eAAO,MAAM,aAAa,eAAsB,CAAC;AAEjD;;GAEG;AACH,wBAAgB,wBAAwB,KAC9B,SAAS,GAAG,UAOrB;AAED;;GAEG;AACH,wBAAgB,yBAAyB,KACzB,UAAU,GAAG,mBAc5B;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK,CAAC;IAC/D,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,OAAO,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC,CAID"}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Runtime Tracer
|
|
4
|
-
*
|
|
5
|
-
* Collects runtime traces during execution:
|
|
6
|
-
* - HTTP requests made
|
|
7
|
-
* - Routes hit
|
|
8
|
-
* - Database queries executed
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.runtimeTracer = void 0;
|
|
12
|
-
exports.createRequestInterceptor = createRequestInterceptor;
|
|
13
|
-
exports.createResponseInterceptor = createResponseInterceptor;
|
|
14
|
-
exports.extractRoutesFromTrace = extractRoutesFromTrace;
|
|
15
|
-
class RuntimeTracer {
|
|
16
|
-
constructor() {
|
|
17
|
-
this.traces = {
|
|
18
|
-
requests: [],
|
|
19
|
-
routes: [],
|
|
20
|
-
dbQueries: [],
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Record an HTTP request
|
|
25
|
-
*/
|
|
26
|
-
recordRequest(method, url, statusCode, duration, headers) {
|
|
27
|
-
this.traces.requests.push({
|
|
28
|
-
method,
|
|
29
|
-
url,
|
|
30
|
-
statusCode,
|
|
31
|
-
timestamp: new Date().toISOString(),
|
|
32
|
-
duration,
|
|
33
|
-
headers,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Record a route hit
|
|
38
|
-
*/
|
|
39
|
-
recordRoute(path, method, hit, responseTime) {
|
|
40
|
-
this.traces.routes.push({
|
|
41
|
-
path,
|
|
42
|
-
method,
|
|
43
|
-
hit,
|
|
44
|
-
timestamp: new Date().toISOString(),
|
|
45
|
-
responseTime,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Record a database query
|
|
50
|
-
*/
|
|
51
|
-
recordDbQuery(query, duration, table) {
|
|
52
|
-
this.traces.dbQueries.push({
|
|
53
|
-
query: query.length > 200 ? query.substring(0, 200) + '...' : query, // Truncate long queries
|
|
54
|
-
duration,
|
|
55
|
-
timestamp: new Date().toISOString(),
|
|
56
|
-
table,
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Get all traces
|
|
61
|
-
*/
|
|
62
|
-
getTraces() {
|
|
63
|
-
return { ...this.traces };
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Reset traces
|
|
67
|
-
*/
|
|
68
|
-
reset() {
|
|
69
|
-
this.traces = {
|
|
70
|
-
requests: [],
|
|
71
|
-
routes: [],
|
|
72
|
-
dbQueries: [],
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
// Singleton instance
|
|
77
|
-
exports.runtimeTracer = new RuntimeTracer();
|
|
78
|
-
/**
|
|
79
|
-
* Playwright request interceptor for tracing HTTP requests
|
|
80
|
-
*/
|
|
81
|
-
function createRequestInterceptor() {
|
|
82
|
-
return (request) => {
|
|
83
|
-
const startTime = Date.now();
|
|
84
|
-
request.continue().then(() => {
|
|
85
|
-
// Request completed
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Playwright response interceptor for tracing HTTP responses
|
|
91
|
-
*/
|
|
92
|
-
function createResponseInterceptor() {
|
|
93
|
-
return async (response) => {
|
|
94
|
-
const request = response.request();
|
|
95
|
-
const endTime = Date.now();
|
|
96
|
-
const startTime = request._startTime || endTime;
|
|
97
|
-
const duration = endTime - startTime;
|
|
98
|
-
exports.runtimeTracer.recordRequest(request.method(), request.url(), response.status(), duration, response.headers());
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Extract routes from Playwright trace or network logs
|
|
103
|
-
*/
|
|
104
|
-
function extractRoutesFromTrace(tracePath) {
|
|
105
|
-
// This would parse Playwright trace files
|
|
106
|
-
// For now, return empty array - implementation would parse trace.zip
|
|
107
|
-
return [];
|
|
108
|
-
}
|
|
109
|
-
//# sourceMappingURL=runtime-tracer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-tracer.js","sourceRoot":"","sources":["../../src/reality/runtime-tracer.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAgHH,4DAQC;AAKD,8DAeC;AAKD,wDAUC;AAjID,MAAM,aAAa;IAAnB;QACU,WAAM,GAAiB;YAC7B,QAAQ,EAAE,EAAE;YACZ,MAAM,EAAE,EAAE;YACV,SAAS,EAAE,EAAE;SACd,CAAC;IAyEJ,CAAC;IAvEC;;OAEG;IACH,aAAa,CACX,MAAc,EACd,GAAW,EACX,UAAkB,EAClB,QAAgB,EAChB,OAAgC;QAEhC,IAAI,CAAC,MAAM,CAAC,QAAQ,C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AC,QAAQ,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;YAC3B,oBAAoB;QACtB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,yBAAyB;IACvC,OAAO,KAAK,EAAE,QAAa,EAAE,EAAE;QAC7B,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC;QACnC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC3B,MAAM,SAAS,GAAI,OAAe,CAAC,UAAU,IAAI,OAAO,CAAC;QACzD,MAAM,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;QAErC,qBAAa,CAAC,aAAa,CACzB,OAAO,CAAC,MAAM,EAAE,EAChB,OAAO,CAAC,GAAG,EAAE,EACb,QAAQ,CAAC,MAAM,EAAE,EACjB,QAAQ,EACR,QAAQ,CAAC,OAAO,EAAE,CACnB,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,sBAAsB,CAAC,SAAiB;IAOtD,0CAA0C;IAC1C,qEAAqE;IACrE,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Enterprise Auth Utilities
|
|
3
|
-
* - Key masking for secure display
|
|
4
|
-
* - Expiry warning calculations
|
|
5
|
-
* - Cache validity checks
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Mask an API key for secure display
|
|
9
|
-
* Keeps prefix and last 4 characters: gr_pro_****abcd
|
|
10
|
-
*/
|
|
11
|
-
export declare function maskApiKey(apiKey: string): string;
|
|
12
|
-
/**
|
|
13
|
-
* Calculate hours until expiry
|
|
14
|
-
* Returns null if no expiry or already expired
|
|
15
|
-
*/
|
|
16
|
-
export declare function hoursUntilExpiry(expiresAt: string | undefined): number | null;
|
|
17
|
-
/**
|
|
18
|
-
* Check if expiry is within warning threshold (72 hours)
|
|
19
|
-
*/
|
|
20
|
-
export declare function isExpiryWarning(expiresAt: string | undefined, thresholdHours?: number): boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Format expiry for display
|
|
23
|
-
*/
|
|
24
|
-
export declare function formatExpiry(expiresAt: string | undefined): string;
|
|
25
|
-
/**
|
|
26
|
-
* Check if cached entitlements should be reused
|
|
27
|
-
* Returns true if cache is valid and has > 5 minutes remaining
|
|
28
|
-
*/
|
|
29
|
-
export declare function shouldUseCachedEntitlements(expiresAt: string | undefined): boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Get client metadata for API requests
|
|
32
|
-
*/
|
|
33
|
-
export declare function getClientMetadata(): {
|
|
34
|
-
version: string;
|
|
35
|
-
os: string;
|
|
36
|
-
arch: string;
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* Validate API key format
|
|
40
|
-
* Returns error message or null if valid
|
|
41
|
-
*/
|
|
42
|
-
export declare function validateApiKeyFormat(apiKey: string): string | null;
|
|
43
|
-
//# sourceMappingURL=auth-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-utils.d.ts","sourceRoot":"","sources":["../../src/runtime/auth-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAqBjD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAU7E;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,cAAc,GAAE,MAAW,GAAG,OAAO,CAInG;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAYlE;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAQlF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAcjF;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAmBlE"}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Enterprise Auth Utilities
|
|
4
|
-
* - Key masking for secure display
|
|
5
|
-
* - Expiry warning calculations
|
|
6
|
-
* - Cache validity checks
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.maskApiKey = maskApiKey;
|
|
10
|
-
exports.hoursUntilExpiry = hoursUntilExpiry;
|
|
11
|
-
exports.isExpiryWarning = isExpiryWarning;
|
|
12
|
-
exports.formatExpiry = formatExpiry;
|
|
13
|
-
exports.shouldUseCachedEntitlements = shouldUseCachedEntitlements;
|
|
14
|
-
exports.getClientMetadata = getClientMetadata;
|
|
15
|
-
exports.validateApiKeyFormat = validateApiKeyFormat;
|
|
16
|
-
/**
|
|
17
|
-
* Mask an API key for secure display
|
|
18
|
-
* Keeps prefix and last 4 characters: gr_pro_****abcd
|
|
19
|
-
*/
|
|
20
|
-
function maskApiKey(apiKey) {
|
|
21
|
-
if (!apiKey || apiKey.length < 12) {
|
|
22
|
-
return '****';
|
|
23
|
-
}
|
|
24
|
-
// Find the prefix pattern (gr_tier_)
|
|
25
|
-
const prefixMatch = apiKey.match(/^(gr_[a-z]+_)/);
|
|
26
|
-
if (prefixMatch) {
|
|
27
|
-
const prefix = prefixMatch[1];
|
|
28
|
-
const suffix = apiKey.slice(-4);
|
|
29
|
-
const maskedLength = apiKey.length - prefix.length - 4;
|
|
30
|
-
// Use exactly 8 asterisks for keys of this length, or actual length if different
|
|
31
|
-
// This provides consistent masking regardless of actual secret length
|
|
32
|
-
const asteriskCount = maskedLength >= 8 ? 8 : Math.max(4, maskedLength);
|
|
33
|
-
return `${prefix}${'*'.repeat(asteriskCount)}${suffix}`;
|
|
34
|
-
}
|
|
35
|
-
// Fallback: show first 3 and last 4
|
|
36
|
-
const prefix = apiKey.slice(0, 3);
|
|
37
|
-
const suffix = apiKey.slice(-4);
|
|
38
|
-
return `${prefix}****${suffix}`;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Calculate hours until expiry
|
|
42
|
-
* Returns null if no expiry or already expired
|
|
43
|
-
*/
|
|
44
|
-
function hoursUntilExpiry(expiresAt) {
|
|
45
|
-
if (!expiresAt)
|
|
46
|
-
return null;
|
|
47
|
-
const expiry = new Date(expiresAt);
|
|
48
|
-
const now = new Date();
|
|
49
|
-
if (expiry <= now)
|
|
50
|
-
return 0;
|
|
51
|
-
const diffMs = expiry.getTime() - now.getTime();
|
|
52
|
-
return Math.floor(diffMs / (1000 * 60 * 60));
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Check if expiry is within warning threshold (72 hours)
|
|
56
|
-
*/
|
|
57
|
-
function isExpiryWarning(expiresAt, thresholdHours = 72) {
|
|
58
|
-
const hours = hoursUntilExpiry(expiresAt);
|
|
59
|
-
if (hours === null)
|
|
60
|
-
return false;
|
|
61
|
-
return hours > 0 && hours <= thresholdHours;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Format expiry for display
|
|
65
|
-
*/
|
|
66
|
-
function formatExpiry(expiresAt) {
|
|
67
|
-
const hours = hoursUntilExpiry(expiresAt);
|
|
68
|
-
if (hours === null)
|
|
69
|
-
return 'No expiry set';
|
|
70
|
-
if (hours === 0)
|
|
71
|
-
return 'Expired';
|
|
72
|
-
if (hours < 24)
|
|
73
|
-
return `${hours}h`;
|
|
74
|
-
const days = Math.floor(hours / 24);
|
|
75
|
-
const remainingHours = hours % 24;
|
|
76
|
-
if (days === 1)
|
|
77
|
-
return `1 day ${remainingHours}h`;
|
|
78
|
-
return `${days} days ${remainingHours}h`;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Check if cached entitlements should be reused
|
|
82
|
-
* Returns true if cache is valid and has > 5 minutes remaining
|
|
83
|
-
*/
|
|
84
|
-
function shouldUseCachedEntitlements(expiresAt) {
|
|
85
|
-
if (!expiresAt)
|
|
86
|
-
return false;
|
|
87
|
-
const expiry = new Date(expiresAt);
|
|
88
|
-
const now = new Date();
|
|
89
|
-
const fiveMinutesFromNow = new Date(now.getTime() + 5 * 60 * 1000);
|
|
90
|
-
return expiry > fiveMinutesFromNow;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Get client metadata for API requests
|
|
94
|
-
*/
|
|
95
|
-
function getClientMetadata() {
|
|
96
|
-
let version = '1.0.0';
|
|
97
|
-
try {
|
|
98
|
-
const pkg = require('../../package.json');
|
|
99
|
-
version = pkg.version || '1.0.0';
|
|
100
|
-
}
|
|
101
|
-
catch {
|
|
102
|
-
// Use default version
|
|
103
|
-
}
|
|
104
|
-
return {
|
|
105
|
-
version,
|
|
106
|
-
os: process.platform,
|
|
107
|
-
arch: process.arch,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Validate API key format
|
|
112
|
-
* Returns error message or null if valid
|
|
113
|
-
*/
|
|
114
|
-
function validateApiKeyFormat(apiKey) {
|
|
115
|
-
if (!apiKey) {
|
|
116
|
-
return 'API key is required';
|
|
117
|
-
}
|
|
118
|
-
if (!apiKey.startsWith('gr_')) {
|
|
119
|
-
return 'API key must start with "gr_"';
|
|
120
|
-
}
|
|
121
|
-
// Check format before length to give more specific error
|
|
122
|
-
if (!/^gr_[a-z]+_[a-zA-Z0-9]+$/.test(apiKey)) {
|
|
123
|
-
return 'API key format is invalid';
|
|
124
|
-
}
|
|
125
|
-
if (apiKey.length < 20) {
|
|
126
|
-
return 'API key is too short';
|
|
127
|
-
}
|
|
128
|
-
return null;
|
|
129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"}
|
package/dist/runtime/client.d.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Enterprise API Client
|
|
3
|
-
* - Real entitlement validation (no key prefix parsing)
|
|
4
|
-
* - Proper timeouts and retries with exponential backoff
|
|
5
|
-
* - User-agent for tracking
|
|
6
|
-
* - Circuit breaker pattern for resilience
|
|
7
|
-
*/
|
|
8
|
-
import { Tier } from './creds';
|
|
9
|
-
export interface AuthValidateRequest {
|
|
10
|
-
apiKey: string;
|
|
11
|
-
client: {
|
|
12
|
-
version: string;
|
|
13
|
-
os: string;
|
|
14
|
-
arch: string;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
export interface AuthValidateResponse {
|
|
18
|
-
ok: boolean;
|
|
19
|
-
tier: Tier;
|
|
20
|
-
email?: string;
|
|
21
|
-
entitlements?: string[];
|
|
22
|
-
expiresAt?: string;
|
|
23
|
-
issuedAt?: string;
|
|
24
|
-
reason?: string;
|
|
25
|
-
}
|
|
26
|
-
export interface ValidateResponse {
|
|
27
|
-
ok: boolean;
|
|
28
|
-
tier: Tier;
|
|
29
|
-
email?: string;
|
|
30
|
-
entitlements?: string[];
|
|
31
|
-
expiresAt?: string;
|
|
32
|
-
issuedAt?: string;
|
|
33
|
-
error?: string;
|
|
34
|
-
}
|
|
35
|
-
export interface ClientOptions {
|
|
36
|
-
baseUrl?: string;
|
|
37
|
-
timeout?: number;
|
|
38
|
-
maxRetries?: number;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Validate API key against the enterprise auth endpoint
|
|
42
|
-
* POST /v1/cli/auth/validate with proper request format and retries
|
|
43
|
-
*/
|
|
44
|
-
export declare function validateApiKey(opts: {
|
|
45
|
-
apiKey: string;
|
|
46
|
-
baseUrl?: string;
|
|
47
|
-
timeout?: number;
|
|
48
|
-
maxRetries?: number;
|
|
49
|
-
}): Promise<ValidateResponse>;
|
|
50
|
-
/**
|
|
51
|
-
* Legacy validate function - wraps new validateApiKey for backwards compatibility
|
|
52
|
-
*/
|
|
53
|
-
export declare function validateCredentials(opts: {
|
|
54
|
-
apiKey?: string;
|
|
55
|
-
accessToken?: string;
|
|
56
|
-
baseUrl?: string;
|
|
57
|
-
timeout?: number;
|
|
58
|
-
}): Promise<ValidateResponse>;
|
|
59
|
-
/**
|
|
60
|
-
* Refresh access token using refresh token
|
|
61
|
-
*/
|
|
62
|
-
export declare function refreshAccessToken(opts: {
|
|
63
|
-
refreshToken: string;
|
|
64
|
-
baseUrl?: string;
|
|
65
|
-
}): Promise<{
|
|
66
|
-
accessToken?: string;
|
|
67
|
-
expiresIn?: number;
|
|
68
|
-
error?: string;
|
|
69
|
-
}>;
|
|
70
|
-
/**
|
|
71
|
-
* Calculate cache expiry (15 minutes from now)
|
|
72
|
-
*/
|
|
73
|
-
export declare function getCacheExpiry(minutes?: number): string;
|
|
74
|
-
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/runtime/client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG/B,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;QAChB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,OAAO,CAAC;IACZ,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,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|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Enterprise API Client
|
|
4
|
-
* - Real entitlement validation (no key prefix parsing)
|
|
5
|
-
* - Proper timeouts and retries with exponential backoff
|
|
6
|
-
* - User-agent for tracking
|
|
7
|
-
* - Circuit breaker pattern for resilience
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.validateApiKey = validateApiKey;
|
|
11
|
-
exports.validateCredentials = validateCredentials;
|
|
12
|
-
exports.refreshAccessToken = refreshAccessToken;
|
|
13
|
-
exports.getCacheExpiry = getCacheExpiry;
|
|
14
|
-
const auth_utils_1 = require("./auth-utils");
|
|
15
|
-
const DEFAULT_API_BASE = process.env.VIBECHECK_API_BASE_URL || 'https://api.vibecheckai.dev';
|
|
16
|
-
const DEFAULT_TIMEOUT = 10000;
|
|
17
|
-
const DEFAULT_MAX_RETRIES = 3;
|
|
18
|
-
const RETRY_DELAYS = [1000, 2000, 4000]; // Exponential backoff
|
|
19
|
-
/**
|
|
20
|
-
* Sleep utility for retry delays
|
|
21
|
-
*/
|
|
22
|
-
function sleep(ms) {
|
|
23
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Validate API key against the enterprise auth endpoint
|
|
27
|
-
* POST /v1/cli/auth/validate with proper request format and retries
|
|
28
|
-
*/
|
|
29
|
-
async function validateApiKey(opts) {
|
|
30
|
-
const baseUrl = opts.baseUrl || DEFAULT_API_BASE;
|
|
31
|
-
const timeout = opts.timeout || DEFAULT_TIMEOUT;
|
|
32
|
-
const maxRetries = opts.maxRetries ?? DEFAULT_MAX_RETRIES;
|
|
33
|
-
const clientMeta = (0, auth_utils_1.getClientMetadata)();
|
|
34
|
-
const requestBody = {
|
|
35
|
-
apiKey: opts.apiKey,
|
|
36
|
-
client: clientMeta,
|
|
37
|
-
};
|
|
38
|
-
let lastError = 'Unknown error';
|
|
39
|
-
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
40
|
-
const controller = new AbortController();
|
|
41
|
-
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
42
|
-
try {
|
|
43
|
-
const res = await fetch(`${baseUrl}/v1/cli/auth/validate`, {
|
|
44
|
-
method: 'POST',
|
|
45
|
-
headers: {
|
|
46
|
-
'content-type': 'application/json',
|
|
47
|
-
'user-agent': `vibecheck-cli-tool/${clientMeta.version} (${clientMeta.os}; ${clientMeta.arch}; node ${process.version})`,
|
|
48
|
-
'x-client-version': clientMeta.version,
|
|
49
|
-
},
|
|
50
|
-
body: JSON.stringify(requestBody),
|
|
51
|
-
signal: controller.signal,
|
|
52
|
-
});
|
|
53
|
-
clearTimeout(timeoutId);
|
|
54
|
-
if (!res.ok) {
|
|
55
|
-
const errorBody = await res.text().catch(() => '');
|
|
56
|
-
let errorMessage;
|
|
57
|
-
try {
|
|
58
|
-
const errorJson = JSON.parse(errorBody);
|
|
59
|
-
errorMessage = errorJson.reason || errorJson.message || errorJson.error || `HTTP ${res.status}`;
|
|
60
|
-
}
|
|
61
|
-
catch {
|
|
62
|
-
errorMessage = `HTTP ${res.status}: ${res.statusText}`;
|
|
63
|
-
}
|
|
64
|
-
if (res.status === 401) {
|
|
65
|
-
return { ok: false, tier: 'free', error: 'Invalid or expired API key' };
|
|
66
|
-
}
|
|
67
|
-
if (res.status === 403) {
|
|
68
|
-
return { ok: false, tier: 'free', error: 'Access denied - API key revoked or suspended' };
|
|
69
|
-
}
|
|
70
|
-
if (res.status === 429) {
|
|
71
|
-
lastError = 'Rate limited - please try again later';
|
|
72
|
-
if (attempt < maxRetries) {
|
|
73
|
-
await sleep(RETRY_DELAYS[attempt] || 4000);
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
return { ok: false, tier: 'free', error: lastError };
|
|
77
|
-
}
|
|
78
|
-
if (res.status >= 500) {
|
|
79
|
-
lastError = `Server error: ${errorMessage}`;
|
|
80
|
-
if (attempt < maxRetries) {
|
|
81
|
-
await sleep(RETRY_DELAYS[attempt] || 4000);
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
return { ok: false, tier: 'free', error: lastError };
|
|
85
|
-
}
|
|
86
|
-
return { ok: false, tier: 'free', error: errorMessage };
|
|
87
|
-
}
|
|
88
|
-
const data = await res.json();
|
|
89
|
-
if (!data.ok) {
|
|
90
|
-
return {
|
|
91
|
-
ok: false,
|
|
92
|
-
tier: 'free',
|
|
93
|
-
error: data.reason || 'Validation failed'
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
return {
|
|
97
|
-
ok: true,
|
|
98
|
-
tier: data.tier || 'free',
|
|
99
|
-
email: data.email,
|
|
100
|
-
entitlements: data.entitlements,
|
|
101
|
-
expiresAt: data.expiresAt,
|
|
102
|
-
issuedAt: data.issuedAt,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
catch (err) {
|
|
106
|
-
clearTimeout(timeoutId);
|
|
107
|
-
if (err.name === 'AbortError') {
|
|
108
|
-
lastError = 'Request timed out';
|
|
109
|
-
}
|
|
110
|
-
else if (err.code === 'ECONNREFUSED' || err.code === 'ENOTFOUND') {
|
|
111
|
-
lastError = 'Unable to reach vibecheck API - check your network connection';
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
lastError = `Network error: ${err.message}`;
|
|
115
|
-
}
|
|
116
|
-
if (attempt < maxRetries) {
|
|
117
|
-
await sleep(RETRY_DELAYS[attempt] || 4000);
|
|
118
|
-
continue;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return { ok: false, tier: 'free', error: lastError };
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Legacy validate function - wraps new validateApiKey for backwards compatibility
|
|
126
|
-
*/
|
|
127
|
-
async function validateCredentials(opts) {
|
|
128
|
-
if (!opts.apiKey && !opts.accessToken) {
|
|
129
|
-
return { ok: false, tier: 'free', error: 'No credentials provided' };
|
|
130
|
-
}
|
|
131
|
-
if (opts.apiKey) {
|
|
132
|
-
return validateApiKey({
|
|
133
|
-
apiKey: opts.apiKey,
|
|
134
|
-
baseUrl: opts.baseUrl,
|
|
135
|
-
timeout: opts.timeout,
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
// For access tokens, use the legacy endpoint
|
|
139
|
-
const baseUrl = opts.baseUrl || DEFAULT_API_BASE;
|
|
140
|
-
const timeout = opts.timeout || DEFAULT_TIMEOUT;
|
|
141
|
-
const controller = new AbortController();
|
|
142
|
-
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
143
|
-
try {
|
|
144
|
-
const clientMeta = (0, auth_utils_1.getClientMetadata)();
|
|
145
|
-
const res = await fetch(`${baseUrl}/v1/cli/validate`, {
|
|
146
|
-
method: 'POST',
|
|
147
|
-
headers: {
|
|
148
|
-
'content-type': 'application/json',
|
|
149
|
-
'authorization': `Bearer ${opts.accessToken}`,
|
|
150
|
-
'user-agent': `vibecheck-cli-tool/${clientMeta.version} (node ${process.version})`,
|
|
151
|
-
},
|
|
152
|
-
body: JSON.stringify({ ts: new Date().toISOString() }),
|
|
153
|
-
signal: controller.signal,
|
|
154
|
-
});
|
|
155
|
-
clearTimeout(timeoutId);
|
|
156
|
-
if (!res.ok) {
|
|
157
|
-
if (res.status === 401) {
|
|
158
|
-
return { ok: false, tier: 'free', error: 'Invalid or expired credentials' };
|
|
159
|
-
}
|
|
160
|
-
return { ok: false, tier: 'free', error: `API error: ${res.status}` };
|
|
161
|
-
}
|
|
162
|
-
const data = await res.json();
|
|
163
|
-
return { ...data, ok: true };
|
|
164
|
-
}
|
|
165
|
-
catch (err) {
|
|
166
|
-
clearTimeout(timeoutId);
|
|
167
|
-
if (err.name === 'AbortError') {
|
|
168
|
-
return { ok: false, tier: 'free', error: 'Request timed out' };
|
|
169
|
-
}
|
|
170
|
-
return { ok: false, tier: 'free', error: `Network error: ${err.message}` };
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Refresh access token using refresh token
|
|
175
|
-
*/
|
|
176
|
-
async function refreshAccessToken(opts) {
|
|
177
|
-
const baseUrl = opts.baseUrl || DEFAULT_API_BASE;
|
|
178
|
-
const controller = new AbortController();
|
|
179
|
-
const timeoutId = setTimeout(() => controller.abort(), DEFAULT_TIMEOUT);
|
|
180
|
-
try {
|
|
181
|
-
const res = await fetch(`${baseUrl}/v1/cli/refresh`, {
|
|
182
|
-
method: 'POST',
|
|
183
|
-
headers: {
|
|
184
|
-
'content-type': 'application/json',
|
|
185
|
-
'user-agent': `vibecheck-cli-tool/${getVersion()} (node ${process.version})`,
|
|
186
|
-
},
|
|
187
|
-
body: JSON.stringify({ refreshToken: opts.refreshToken }),
|
|
188
|
-
signal: controller.signal,
|
|
189
|
-
});
|
|
190
|
-
if (!res.ok) {
|
|
191
|
-
return { error: `Refresh failed: ${res.status}` };
|
|
192
|
-
}
|
|
193
|
-
return await res.json();
|
|
194
|
-
}
|
|
195
|
-
catch (err) {
|
|
196
|
-
return { error: err.message };
|
|
197
|
-
}
|
|
198
|
-
finally {
|
|
199
|
-
clearTimeout(timeoutId);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Get CLI version from package.json
|
|
204
|
-
*/
|
|
205
|
-
function getVersion() {
|
|
206
|
-
try {
|
|
207
|
-
const pkg = require('../../package.json');
|
|
208
|
-
return pkg.version || '0.0.0';
|
|
209
|
-
}
|
|
210
|
-
catch {
|
|
211
|
-
return '0.0.0';
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Calculate cache expiry (15 minutes from now)
|
|
216
|
-
*/
|
|
217
|
-
function getCacheExpiry(minutes = 15) {
|
|
218
|
-
const expiry = new Date();
|
|
219
|
-
expiry.setMinutes(expiry.getMinutes() + minutes);
|
|
220
|
-
return expiry.toISOString();
|
|
221
|
-
}
|
|
222
|
-
//# sourceMappingURL=client.js.map
|