@kya-os/checkpoint-shared 1.1.0 → 1.2.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/CHANGELOG.md +31 -0
- package/dist/beacon-types/index.d.mts +427 -0
- package/dist/beacon-types/index.d.ts +427 -0
- package/dist/beacon-types/index.js +204 -0
- package/dist/beacon-types/index.mjs +191 -0
- package/dist/deploy/index.d.mts +380 -0
- package/dist/deploy/index.d.ts +380 -0
- package/dist/deploy/index.js +221 -0
- package/dist/deploy/index.mjs +207 -0
- package/dist/gateway/index.d.mts +575 -0
- package/dist/gateway/index.d.ts +575 -0
- package/dist/gateway/index.js +98 -0
- package/dist/gateway/index.mjs +88 -0
- package/dist/index.d.mts +1471 -106
- package/dist/index.d.ts +1471 -106
- package/dist/index.js +1869 -1029
- package/dist/index.mjs +1826 -1028
- package/dist/mcpi/agentshield-api/index.d.mts +47 -0
- package/dist/mcpi/agentshield-api/index.d.ts +47 -0
- package/dist/mcpi/agentshield-api/index.js +2 -0
- package/dist/mcpi/agentshield-api/index.mjs +1 -0
- package/dist/mcpi/approval-grant/index.d.mts +79 -0
- package/dist/mcpi/approval-grant/index.d.ts +79 -0
- package/dist/mcpi/approval-grant/index.js +157 -0
- package/dist/mcpi/approval-grant/index.mjs +150 -0
- package/dist/mcpi/dashboard-config/index.d.mts +14075 -0
- package/dist/mcpi/dashboard-config/index.d.ts +14075 -0
- package/dist/mcpi/dashboard-config/index.js +517 -0
- package/dist/mcpi/dashboard-config/index.mjs +492 -0
- package/dist/test-fixtures/index.d.mts +17 -8
- package/dist/test-fixtures/index.d.ts +17 -8
- package/dist/test-fixtures/index.js +73 -7
- package/dist/test-fixtures/index.mjs +73 -8
- package/dist/tool-protection/index.d.mts +1120 -0
- package/dist/tool-protection/index.d.ts +1120 -0
- package/dist/tool-protection/index.js +370 -0
- package/dist/tool-protection/index.mjs +338 -0
- package/package.json +40 -3
package/dist/index.js
CHANGED
|
@@ -5039,6 +5039,32 @@ var ReasoningStepSchema = external_exports.object({
|
|
|
5039
5039
|
contribution: external_exports.number(),
|
|
5040
5040
|
explanation: external_exports.string()
|
|
5041
5041
|
});
|
|
5042
|
+
var TraceStepSchema = external_exports.object({
|
|
5043
|
+
/**
|
|
5044
|
+
* Stable stage identifier. Canonical names: `"detection"` | `"identity"`
|
|
5045
|
+
* | `"scope"` | `"reputation"` | `"policy"`. Mirrors `TraceStep::name`
|
|
5046
|
+
* on the Rust side.
|
|
5047
|
+
*/
|
|
5048
|
+
name: external_exports.string(),
|
|
5049
|
+
/**
|
|
5050
|
+
* Per-step verdict. `"pass"` = step ran and succeeded, `"fail"` = step
|
|
5051
|
+
* ran and rejected, `"skip"` = step was skipped (e.g. no identity
|
|
5052
|
+
* material on PlainHttp). Mirrors `TraceVerdict` on the Rust side,
|
|
5053
|
+
* which serializes lowercase.
|
|
5054
|
+
*/
|
|
5055
|
+
verdict: external_exports.enum(["pass", "fail", "skip"]),
|
|
5056
|
+
/**
|
|
5057
|
+
* Stage execution time in microseconds. Mirrors `latency_micros` on the
|
|
5058
|
+
* Rust side which carries the `#[serde(rename = "latencyMicros")]` wire
|
|
5059
|
+
* key.
|
|
5060
|
+
*/
|
|
5061
|
+
latencyMicros: external_exports.number(),
|
|
5062
|
+
/**
|
|
5063
|
+
* Optional human-readable reason. Always present when verdict is
|
|
5064
|
+
* `"fail"`.
|
|
5065
|
+
*/
|
|
5066
|
+
reason: external_exports.string().optional()
|
|
5067
|
+
});
|
|
5042
5068
|
var DetectionReasoningSchema = external_exports.object({
|
|
5043
5069
|
primaryFactors: external_exports.array(external_exports.string()),
|
|
5044
5070
|
supportingEvidence: external_exports.array(external_exports.string()),
|
|
@@ -5103,9 +5129,26 @@ var DetectionDetailSchema = external_exports.object({
|
|
|
5103
5129
|
// Backwards compatibility
|
|
5104
5130
|
agentType: external_exports.string().optional(),
|
|
5105
5131
|
// Verification and enhanced risk assessment
|
|
5106
|
-
verificationMethod: external_exports.enum([
|
|
5132
|
+
verificationMethod: external_exports.enum([
|
|
5133
|
+
"signature",
|
|
5134
|
+
"pattern",
|
|
5135
|
+
"behavioral",
|
|
5136
|
+
"network",
|
|
5137
|
+
"mcp_i_handshake",
|
|
5138
|
+
"kyaos_handshake",
|
|
5139
|
+
"kya-http",
|
|
5140
|
+
"kya-http-delegated",
|
|
5141
|
+
"none",
|
|
5142
|
+
"error"
|
|
5143
|
+
]).optional(),
|
|
5107
5144
|
riskLevel: external_exports.string().optional(),
|
|
5108
5145
|
forgeabilityRisk: external_exports.enum(["low", "medium", "high"]).optional(),
|
|
5146
|
+
// draft-kya-http-02 §1 assurance tier the engine established for this
|
|
5147
|
+
// verdict (`anonymous` | `attested-bearer` | `key-bound` | `registered` |
|
|
5148
|
+
// `delegated`). Stamped by the engine on every verdict; the canonical
|
|
5149
|
+
// ladder is `AssuranceTierSchema` in `../policy/schemas`. Kept a loose
|
|
5150
|
+
// string here (like `riskLevel`) to avoid a core→policy module dependency.
|
|
5151
|
+
assurance: external_exports.string().optional(),
|
|
5109
5152
|
// NEW: Enhanced risk assessment
|
|
5110
5153
|
riskAssessment: external_exports.object({
|
|
5111
5154
|
level: external_exports.enum(["low", "medium", "high", "critical"]),
|
|
@@ -5120,7 +5163,14 @@ var DetectionDetailSchema = external_exports.object({
|
|
|
5120
5163
|
requestId: external_exports.string().optional(),
|
|
5121
5164
|
/** Engine self-identification — see EngineInfoSchema. Optional for
|
|
5122
5165
|
* pre-Phase-0.1 SDKs; dashboard treats absence as "legacy SDK." */
|
|
5123
|
-
engine: EngineInfoSchema.optional()
|
|
5166
|
+
engine: EngineInfoSchema.optional(),
|
|
5167
|
+
/** Scopes granted by a verified single-hop delegation (the mcp-i path).
|
|
5168
|
+
* Surfaced by the engine so a host can FORWARD them into
|
|
5169
|
+
* `context.granted_scopes` (authorize()) without re-decoding the delegation
|
|
5170
|
+
* credential — the engine already verified them. Omitted/empty for L1
|
|
5171
|
+
* envelopes or any unverified/forged path. Mirrors the Rust
|
|
5172
|
+
* `DetectionDetail.granted_scopes` (additive, omitted when empty). */
|
|
5173
|
+
grantedScopes: external_exports.array(external_exports.string()).optional()
|
|
5124
5174
|
});
|
|
5125
5175
|
var DetectionResultSchema = DetectionDetailSchema;
|
|
5126
5176
|
var DetectionModeSchema = external_exports.enum(["strict", "balanced", "lenient"]);
|
|
@@ -5243,6 +5293,17 @@ var AgentTypeSchema = external_exports.enum([
|
|
|
5243
5293
|
// Content/Writing AI
|
|
5244
5294
|
"writer",
|
|
5245
5295
|
"jasper",
|
|
5296
|
+
// Additional AI vendors — Engine-Pattern-Codegen-Retirement-1 backfilled
|
|
5297
|
+
// these after the SSOT migration surfaced legacy patterns_generated.rs
|
|
5298
|
+
// entries (xAI Grok, DeepSeek-User/DeepSeekBot, Amazon Q + NovaAct,
|
|
5299
|
+
// KYA Agent) that were never represented in TS. Their patterns lived
|
|
5300
|
+
// only in the retired YAML→Rust pipeline; without these types the
|
|
5301
|
+
// backfilled `KNOWN_AGENT_PATTERNS` entries would have to coerce to
|
|
5302
|
+
// `'unknown'` and lose per-vendor classification downstream.
|
|
5303
|
+
"xai",
|
|
5304
|
+
"deepseek",
|
|
5305
|
+
"amazon",
|
|
5306
|
+
"kya",
|
|
5246
5307
|
// Unknown AI agent
|
|
5247
5308
|
"unknown"
|
|
5248
5309
|
]);
|
|
@@ -5497,7 +5558,11 @@ var KNOWN_AGENT_PATTERNS = [
|
|
|
5497
5558
|
id: "openai-chatgpt",
|
|
5498
5559
|
type: "openai",
|
|
5499
5560
|
name: "ChatGPT",
|
|
5500
|
-
|
|
5561
|
+
// `OAI-SearchBot` backfilled by Engine-Pattern-Codegen-Retirement-1
|
|
5562
|
+
// after the legacy YAML→Rust path was retired. Previously detected
|
|
5563
|
+
// only via the legacy generator; the new TS SSOT migration would
|
|
5564
|
+
// have silently lost it.
|
|
5565
|
+
patterns: ["ChatGPT-User", "OAI-SearchBot", "gpt-4", "gpt-3.5", "gpt-4-turbo", "gpt-4o"],
|
|
5501
5566
|
headers: {
|
|
5502
5567
|
"X-OpenAI-Assistant": "*"
|
|
5503
5568
|
},
|
|
@@ -5554,6 +5619,18 @@ var KNOWN_AGENT_PATTERNS = [
|
|
|
5554
5619
|
// was missing, which left ~14 real Claude-User sessions on
|
|
5555
5620
|
// production stamped (bot, …) instead of (ai_agent, ai_assistant).
|
|
5556
5621
|
"Claude-User",
|
|
5622
|
+
// `Claude-SearchBot` and `claude-code` backfilled by
|
|
5623
|
+
// Engine-Pattern-Codegen-Retirement-1 — both were in the retired
|
|
5624
|
+
// YAML→Rust pipeline but never represented in TS. Claude-Code is
|
|
5625
|
+
// Anthropic's CLI agent (this very tool); Claude-SearchBot is
|
|
5626
|
+
// their search-augmented fetcher (parallel to OAI-SearchBot).
|
|
5627
|
+
"Claude-SearchBot",
|
|
5628
|
+
"claude-code",
|
|
5629
|
+
// Engine-Pattern-Codegen-Retirement-1 round 2 (Bugbot #e111d65f):
|
|
5630
|
+
// the retired YAML→Rust pipeline matched both `claude-code` AND
|
|
5631
|
+
// `claude code` (space-separated). Some host wrappers stamp the
|
|
5632
|
+
// tool name with a space; the hyphenated form alone misses them.
|
|
5633
|
+
"claude code",
|
|
5557
5634
|
"claude-3",
|
|
5558
5635
|
"claude-2",
|
|
5559
5636
|
"claude-instant",
|
|
@@ -5621,7 +5698,13 @@ var KNOWN_AGENT_PATTERNS = [
|
|
|
5621
5698
|
id: "perplexity-user",
|
|
5622
5699
|
type: "perplexity",
|
|
5623
5700
|
name: "Perplexity",
|
|
5624
|
-
|
|
5701
|
+
// `Comet` is Perplexity's AI-powered browser; backfilled into the
|
|
5702
|
+
// TS canonical via Engine-Pattern-Codegen-Retirement-1 after the
|
|
5703
|
+
// SSOT consolidation surfaced the gap. Previously detected only by
|
|
5704
|
+
// the legacy YAML→Rust codegen path; `apps/web/scripts/seed-agent-
|
|
5705
|
+
// types-data.ts` listed it as a Perplexity AI detection while
|
|
5706
|
+
// `KNOWN_AGENT_PATTERNS` did not. Now structurally enforced.
|
|
5707
|
+
patterns: ["Perplexity-User", "Perplexity-AI", "Comet"],
|
|
5625
5708
|
confidence: 0.95,
|
|
5626
5709
|
category: "ai_assistant",
|
|
5627
5710
|
isLegitimate: true
|
|
@@ -5651,45 +5734,81 @@ var KNOWN_AGENT_PATTERNS = [
|
|
|
5651
5734
|
category: "scraper",
|
|
5652
5735
|
isLegitimate: true
|
|
5653
5736
|
},
|
|
5737
|
+
{
|
|
5738
|
+
// ORDERING NOTE: `gemini-deep-research` MUST appear BEFORE
|
|
5739
|
+
// `google-bard` so the more-specific 'Gemini-Deep-Research'
|
|
5740
|
+
// pattern wins under the engine's first-match-wins iteration over
|
|
5741
|
+
// AI_AGENT_PATTERNS. The legacy YAML→Rust output collapsed all
|
|
5742
|
+
// Google patterns under a single "Google AI" name with identical
|
|
5743
|
+
// confidence (0.90), so shadowing was benign; the SSOT migration
|
|
5744
|
+
// surfaced different names + confidences (0.95 scraper vs 0.90
|
|
5745
|
+
// ai_assistant), making the order load-bearing.
|
|
5746
|
+
//
|
|
5747
|
+
// Google's "Deep Research" training/research crawler — distinct
|
|
5748
|
+
// UA from Bard/Gemini interactive sessions.
|
|
5749
|
+
id: "gemini-deep-research",
|
|
5750
|
+
type: "google",
|
|
5751
|
+
name: "Gemini-Deep-Research",
|
|
5752
|
+
patterns: ["Gemini-Deep-Research", "gemini-deep-research"],
|
|
5753
|
+
confidence: 0.95,
|
|
5754
|
+
category: "scraper",
|
|
5755
|
+
isLegitimate: true
|
|
5756
|
+
},
|
|
5654
5757
|
{
|
|
5655
5758
|
id: "google-bard",
|
|
5656
5759
|
type: "google",
|
|
5657
5760
|
name: "Google Bard",
|
|
5761
|
+
// Engine-Pattern-Codegen-Retirement-1 corrections:
|
|
5762
|
+
// - REMOVED `Google-InspectionTool` from this entry. The legacy
|
|
5763
|
+
// YAML→Rust pipeline classified Google-InspectionTool as a
|
|
5764
|
+
// Googlebot-family search inspection tool (Search Console
|
|
5765
|
+
// verification, structured-data testing), not a Bard/Gemini AI
|
|
5766
|
+
// session. Moved to `NON_AI_PATTERNS` in
|
|
5767
|
+
// `rust/crates/kya-os-engine/src/stages/patterns.rs` under the
|
|
5768
|
+
// `Googlebot` family so classification stays SearchCrawler.
|
|
5769
|
+
// - ADDED `LaMDA` (Google's pre-Bard conversational AI; legacy
|
|
5770
|
+
// YAML had it under Google AI) and `GoogleAgent-Mariner`
|
|
5771
|
+
// (Google's browser-controlling agent product) — both were in
|
|
5772
|
+
// the retired pipeline, never in TS.
|
|
5773
|
+
// - The broad 'gemini' pattern below shadows narrower Gemini-*
|
|
5774
|
+
// UAs under first-match-wins. The Gemini-Deep-Research entry
|
|
5775
|
+
// above must stay ordered first to avoid being shadowed.
|
|
5658
5776
|
patterns: [
|
|
5659
5777
|
"Bard",
|
|
5660
|
-
"Google-InspectionTool",
|
|
5661
5778
|
"gemini",
|
|
5662
5779
|
"gemini-pro",
|
|
5663
5780
|
"gemini-1.5",
|
|
5664
5781
|
"gemini-1.5-pro",
|
|
5665
5782
|
"gemini-ultra",
|
|
5666
5783
|
"palm",
|
|
5667
|
-
"palm2"
|
|
5784
|
+
"palm2",
|
|
5785
|
+
"LaMDA",
|
|
5786
|
+
"GoogleAgent-Mariner"
|
|
5668
5787
|
],
|
|
5669
5788
|
confidence: 0.9,
|
|
5670
5789
|
category: "ai_assistant",
|
|
5671
5790
|
isLegitimate: true
|
|
5672
5791
|
},
|
|
5673
|
-
{
|
|
5674
|
-
// Google's "Deep Research" training/research crawler — distinct UA
|
|
5675
|
-
// from Bard/Gemini interactive sessions. Pattern matches the
|
|
5676
|
-
// canonical 'Gemini-Deep-Research/<version>' UA token; the broad
|
|
5677
|
-
// 'gemini' substring in google-bard would otherwise win and stamp
|
|
5678
|
-
// these crawler hits as ai_assistant.
|
|
5679
|
-
id: "gemini-deep-research",
|
|
5680
|
-
type: "google",
|
|
5681
|
-
name: "Gemini-Deep-Research",
|
|
5682
|
-
patterns: ["Gemini-Deep-Research", "gemini-deep-research"],
|
|
5683
|
-
confidence: 0.95,
|
|
5684
|
-
category: "scraper",
|
|
5685
|
-
isLegitimate: true
|
|
5686
|
-
},
|
|
5687
5792
|
// Microsoft Copilot
|
|
5688
5793
|
{
|
|
5689
5794
|
id: "microsoft-copilot",
|
|
5690
5795
|
type: "microsoft",
|
|
5691
5796
|
name: "Microsoft Copilot",
|
|
5692
|
-
patterns: [
|
|
5797
|
+
patterns: [
|
|
5798
|
+
"copilot",
|
|
5799
|
+
"github-copilot",
|
|
5800
|
+
"microsoft-copilot",
|
|
5801
|
+
// Engine-Pattern-Codegen-Retirement-1 round 2 (Bugbot #89cfb23d):
|
|
5802
|
+
// the retired YAML→Rust pipeline carried `BingPreview/.*ChatGPT`
|
|
5803
|
+
// for Bing Copilot UAs. Without this, BingPreview+ChatGPT UAs hit
|
|
5804
|
+
// the non-AI `BingPreview` Bingbot rule and resolve as SearchBot.
|
|
5805
|
+
// Note: this entry must order BEFORE the Bingbot regex in the
|
|
5806
|
+
// composed table — AI patterns lead, so the dispatch order in
|
|
5807
|
+
// patterns.rs::AI_AGENT_PATTERNS (AI_PATTERNS_FROM_TS then
|
|
5808
|
+
// NON_AI_PATTERNS) preserves the precedence the legacy table
|
|
5809
|
+
// gave Microsoft AI at confidence 0.9.
|
|
5810
|
+
"BingPreview/.*ChatGPT"
|
|
5811
|
+
],
|
|
5693
5812
|
confidence: 0.9,
|
|
5694
5813
|
category: "ai_assistant",
|
|
5695
5814
|
isLegitimate: true
|
|
@@ -5724,7 +5843,12 @@ var KNOWN_AGENT_PATTERNS = [
|
|
|
5724
5843
|
id: "cohere-bot",
|
|
5725
5844
|
type: "cohere",
|
|
5726
5845
|
name: "CohereBot",
|
|
5727
|
-
|
|
5846
|
+
// Engine-Pattern-Codegen-Retirement-1 round 2 (Bugbot #8007b7a3):
|
|
5847
|
+
// the retired YAML→Rust pipeline matched the literal `CohereBot`
|
|
5848
|
+
// token; without it the UA falls through to the generic-bot
|
|
5849
|
+
// fallback (`bot` substring) and resolves as `Generic Bot` /
|
|
5850
|
+
// OtherBot, losing vendor attribution.
|
|
5851
|
+
patterns: ["cohere-ai", "CohereBot"],
|
|
5728
5852
|
confidence: 0.85,
|
|
5729
5853
|
category: "scraper",
|
|
5730
5854
|
isLegitimate: true
|
|
@@ -5897,6 +6021,86 @@ var KNOWN_AGENT_PATTERNS = [
|
|
|
5897
6021
|
confidence: 0.8,
|
|
5898
6022
|
category: "ai_assistant",
|
|
5899
6023
|
isLegitimate: true
|
|
6024
|
+
},
|
|
6025
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
6026
|
+
// Engine-Pattern-Codegen-Retirement-1 backfills.
|
|
6027
|
+
//
|
|
6028
|
+
// Each entry below was detected by the retired YAML→Rust codegen path
|
|
6029
|
+
// (`patterns_generated.rs`) but never represented in TS. The SSOT
|
|
6030
|
+
// migration would have silently dropped detection for these vendors.
|
|
6031
|
+
// Names + confidences mirror the legacy pipeline so classify_agent /
|
|
6032
|
+
// classify_vendor downstream consumers don't see a behavioral shift.
|
|
6033
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
6034
|
+
// xAI Grok — Elon's AI; user-facing assistant + crawler share the
|
|
6035
|
+
// same vendor brand, all routed through this single entry. The
|
|
6036
|
+
// legacy pipeline emitted them under one "xAI Grok" name, so a split
|
|
6037
|
+
// would change downstream classification.
|
|
6038
|
+
{
|
|
6039
|
+
id: "xai-grok",
|
|
6040
|
+
type: "xai",
|
|
6041
|
+
name: "xAI Grok",
|
|
6042
|
+
patterns: ["xAI-Grok", "GrokBot", "Grok-DeepSearch"],
|
|
6043
|
+
confidence: 0.95,
|
|
6044
|
+
category: "ai_assistant",
|
|
6045
|
+
isLegitimate: true
|
|
6046
|
+
},
|
|
6047
|
+
// DeepSeek — split into interactive (DeepSeek-User) and crawler
|
|
6048
|
+
// (DeepSeekBot), parallel to the openai-chatgpt / openai-gptbot
|
|
6049
|
+
// and anthropic-claude / anthropic-claudebot splits.
|
|
6050
|
+
{
|
|
6051
|
+
id: "deepseek-user",
|
|
6052
|
+
type: "deepseek",
|
|
6053
|
+
name: "DeepSeek AI",
|
|
6054
|
+
patterns: ["DeepSeek-User"],
|
|
6055
|
+
confidence: 0.95,
|
|
6056
|
+
category: "ai_assistant",
|
|
6057
|
+
isLegitimate: true
|
|
6058
|
+
},
|
|
6059
|
+
{
|
|
6060
|
+
id: "deepseek-bot",
|
|
6061
|
+
type: "deepseek",
|
|
6062
|
+
name: "DeepSeekBot",
|
|
6063
|
+
patterns: ["DeepSeekBot"],
|
|
6064
|
+
confidence: 0.95,
|
|
6065
|
+
category: "scraper",
|
|
6066
|
+
isLegitimate: true
|
|
6067
|
+
},
|
|
6068
|
+
// Amazon Q + NovaAct — Amazon's AI assistant product family.
|
|
6069
|
+
// NovaAct is the AWS-branded browser-controlling agent (parallel to
|
|
6070
|
+
// Anthropic's Claude-Code, Google's GoogleAgent-Mariner).
|
|
6071
|
+
{
|
|
6072
|
+
id: "amazon-q",
|
|
6073
|
+
type: "amazon",
|
|
6074
|
+
name: "Amazon Q",
|
|
6075
|
+
patterns: ["Amazon-Q", "NovaAct"],
|
|
6076
|
+
confidence: 0.95,
|
|
6077
|
+
category: "ai_assistant",
|
|
6078
|
+
isLegitimate: true
|
|
6079
|
+
},
|
|
6080
|
+
// KYA Agent — our own product family. KYA-Agent/<version> is the
|
|
6081
|
+
// canonical UA; KYA-OS is the umbrella protocol token; KYA-Compute/
|
|
6082
|
+
// is the signed-compute variant. All ai_assistant — none of these
|
|
6083
|
+
// are training crawlers.
|
|
6084
|
+
//
|
|
6085
|
+
// Display name is `'Kya Agent'` (sentence case), NOT `'KYA Agent'`
|
|
6086
|
+
// (brand all-caps). Matches every other consumer's expectation:
|
|
6087
|
+
// `did-verifier.ts` hardcodes `'Kya Agent'` as the display fallback
|
|
6088
|
+
// for did:key / unhumanizable did:web (3 sites), the gateway router
|
|
6089
|
+
// docstring refers to the "Kya Agent" pattern, and the signed-agent
|
|
6090
|
+
// e2e test asserts on `'Kya Agent'` for both the unsigned Tier-3 UA
|
|
6091
|
+
// path and the signed DID-verified path. The prior `'KYA Agent'`
|
|
6092
|
+
// value here was a codegen-source outlier that produced consistent
|
|
6093
|
+
// brand-case-vs-sentence-case drift between Tier 3 emissions (which
|
|
6094
|
+
// read this) and Tier 1 emissions (which use the did-verifier
|
|
6095
|
+
// hardcode). One source of truth, sentence case.
|
|
6096
|
+
{
|
|
6097
|
+
id: "kya-agent",
|
|
6098
|
+
type: "kya",
|
|
6099
|
+
name: "Kya Agent",
|
|
6100
|
+
patterns: ["KYA-Agent/", "KYA-OS", "KYA-Compute/"],
|
|
6101
|
+
confidence: 0.95,
|
|
6102
|
+
category: "ai_assistant",
|
|
6103
|
+
isLegitimate: true
|
|
5900
6104
|
}
|
|
5901
6105
|
];
|
|
5902
6106
|
var CLOUD_PROVIDER_RANGES = {
|
|
@@ -7249,403 +7453,736 @@ var StatsResponseSchema = external_exports.object({
|
|
|
7249
7453
|
})
|
|
7250
7454
|
});
|
|
7251
7455
|
|
|
7252
|
-
// src/
|
|
7253
|
-
var
|
|
7254
|
-
|
|
7255
|
-
|
|
7256
|
-
|
|
7257
|
-
|
|
7258
|
-
|
|
7259
|
-
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
-
|
|
7267
|
-
|
|
7268
|
-
|
|
7269
|
-
|
|
7270
|
-
|
|
7271
|
-
clickCount: external_exports.number().min(0).optional(),
|
|
7272
|
-
mouseMovements: external_exports.number().min(0).optional(),
|
|
7273
|
-
keystrokes: external_exports.number().min(0).optional(),
|
|
7274
|
-
// Device/viewport info
|
|
7275
|
-
screenResolution: external_exports.string().optional(),
|
|
7276
|
-
viewport: external_exports.string().optional(),
|
|
7277
|
-
// Custom metadata
|
|
7278
|
-
metadata: external_exports.record(external_exports.unknown()).optional()
|
|
7279
|
-
});
|
|
7280
|
-
var EventTrackingResponseSchema = external_exports.object({
|
|
7281
|
-
success: external_exports.boolean(),
|
|
7282
|
-
eventId: external_exports.string().uuid(),
|
|
7283
|
-
sessionId: external_exports.string(),
|
|
7284
|
-
detection: DetectionResultSchema,
|
|
7285
|
-
// Rate limit info
|
|
7286
|
-
rateLimit: external_exports.object({
|
|
7287
|
-
limit: external_exports.number(),
|
|
7288
|
-
remaining: external_exports.number(),
|
|
7289
|
-
reset: external_exports.number()
|
|
7290
|
-
}).optional(),
|
|
7291
|
-
// Debug info (only in development)
|
|
7292
|
-
debug: external_exports.object({
|
|
7293
|
-
processingTime: external_exports.number(),
|
|
7294
|
-
rulesVersion: external_exports.string(),
|
|
7295
|
-
serverRegion: external_exports.string().optional(),
|
|
7296
|
-
cacheHit: external_exports.boolean().optional()
|
|
7297
|
-
}).optional()
|
|
7456
|
+
// src/types/pixel.ts
|
|
7457
|
+
var PixelEventTypeSchema = external_exports.enum([
|
|
7458
|
+
"pageview",
|
|
7459
|
+
"detection",
|
|
7460
|
+
"interaction",
|
|
7461
|
+
"error",
|
|
7462
|
+
"session_start",
|
|
7463
|
+
"session_end",
|
|
7464
|
+
"custom"
|
|
7465
|
+
]);
|
|
7466
|
+
var BrowserInfoSchema = external_exports.object({
|
|
7467
|
+
name: external_exports.string().optional(),
|
|
7468
|
+
version: external_exports.string().optional(),
|
|
7469
|
+
platform: external_exports.string().optional(),
|
|
7470
|
+
mobile: external_exports.boolean().default(false),
|
|
7471
|
+
language: external_exports.string().optional(),
|
|
7472
|
+
cookiesEnabled: external_exports.boolean().optional(),
|
|
7473
|
+
doNotTrack: external_exports.boolean().optional(),
|
|
7474
|
+
plugins: external_exports.array(external_exports.string()).optional()
|
|
7298
7475
|
});
|
|
7299
|
-
var
|
|
7300
|
-
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
-
continueOnError: external_exports.boolean().default(true),
|
|
7309
|
-
includeDetailed: external_exports.boolean().default(false)
|
|
7310
|
-
}).optional()
|
|
7476
|
+
var PageContextSchema = external_exports.object({
|
|
7477
|
+
url: external_exports.string().url(),
|
|
7478
|
+
title: external_exports.string().optional(),
|
|
7479
|
+
referrer: external_exports.string().optional(),
|
|
7480
|
+
path: external_exports.string(),
|
|
7481
|
+
hostname: external_exports.string(),
|
|
7482
|
+
protocol: external_exports.string(),
|
|
7483
|
+
search: external_exports.string().optional(),
|
|
7484
|
+
hash: external_exports.string().optional()
|
|
7311
7485
|
});
|
|
7312
|
-
var
|
|
7313
|
-
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
|
|
7317
|
-
|
|
7318
|
-
|
|
7319
|
-
|
|
7320
|
-
|
|
7321
|
-
|
|
7322
|
-
error: external_exports.object({
|
|
7323
|
-
code: external_exports.string(),
|
|
7324
|
-
message: external_exports.string()
|
|
7325
|
-
}).optional()
|
|
7326
|
-
})
|
|
7327
|
-
),
|
|
7328
|
-
// Summary statistics
|
|
7329
|
-
summary: external_exports.object({
|
|
7330
|
-
total: external_exports.number(),
|
|
7331
|
-
successful: external_exports.number(),
|
|
7332
|
-
failed: external_exports.number(),
|
|
7333
|
-
agentsDetected: external_exports.number(),
|
|
7334
|
-
averageConfidence: external_exports.number().min(0).max(1),
|
|
7335
|
-
processingTime: external_exports.number()
|
|
7336
|
-
}),
|
|
7337
|
-
// Rate limit info
|
|
7338
|
-
rateLimit: external_exports.object({
|
|
7339
|
-
limit: external_exports.number(),
|
|
7340
|
-
remaining: external_exports.number(),
|
|
7341
|
-
reset: external_exports.number()
|
|
7342
|
-
}).optional()
|
|
7486
|
+
var BehavioralSignalsSchema = external_exports.object({
|
|
7487
|
+
mouseMovements: external_exports.number().int().min(0).default(0),
|
|
7488
|
+
clicks: external_exports.number().int().min(0).default(0),
|
|
7489
|
+
scrollEvents: external_exports.number().int().min(0).default(0),
|
|
7490
|
+
keyPresses: external_exports.number().int().min(0).default(0),
|
|
7491
|
+
touchEvents: external_exports.number().int().min(0).default(0),
|
|
7492
|
+
timeOnPage: external_exports.number().min(0).default(0),
|
|
7493
|
+
interactionRate: external_exports.number().min(0).max(1).default(0),
|
|
7494
|
+
scrollDepth: external_exports.number().min(0).max(100).default(0),
|
|
7495
|
+
isAutomated: external_exports.boolean().optional()
|
|
7343
7496
|
});
|
|
7344
|
-
var
|
|
7497
|
+
var PixelEventSchema = external_exports.object({
|
|
7498
|
+
// Event Identification
|
|
7345
7499
|
id: external_exports.string().uuid(),
|
|
7346
|
-
pixelId: external_exports.string()
|
|
7347
|
-
projectId: external_exports.string().uuid(),
|
|
7500
|
+
pixelId: external_exports.string(),
|
|
7348
7501
|
sessionId: external_exports.string(),
|
|
7349
|
-
|
|
7350
|
-
|
|
7502
|
+
eventType: PixelEventTypeSchema,
|
|
7503
|
+
// Timing
|
|
7504
|
+
timestamp: external_exports.union([external_exports.string(), external_exports.date()]),
|
|
7505
|
+
clientTimestamp: external_exports.union([external_exports.string(), external_exports.date()]).optional(),
|
|
7506
|
+
// Context
|
|
7507
|
+
page: PageContextSchema,
|
|
7508
|
+
browser: BrowserInfoSchema.optional(),
|
|
7509
|
+
// Request Information
|
|
7351
7510
|
userAgent: external_exports.string(),
|
|
7352
7511
|
ipAddress: external_exports.string().optional(),
|
|
7353
|
-
|
|
7354
|
-
// Detection
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
|
|
7358
|
-
|
|
7359
|
-
// Behavioral metrics
|
|
7360
|
-
timeOnPage: external_exports.number().optional(),
|
|
7361
|
-
scrollDepth: external_exports.number().optional(),
|
|
7362
|
-
clickCount: external_exports.number().optional(),
|
|
7363
|
-
// Metadata
|
|
7512
|
+
headers: external_exports.record(external_exports.string()).optional(),
|
|
7513
|
+
// Detection Results
|
|
7514
|
+
detection: DetectionResultSchema.optional(),
|
|
7515
|
+
// Behavioral Data
|
|
7516
|
+
behavioral: BehavioralSignalsSchema.optional(),
|
|
7517
|
+
// Custom Data
|
|
7364
7518
|
metadata: external_exports.record(external_exports.unknown()).optional(),
|
|
7365
|
-
|
|
7366
|
-
createdAt: external_exports.date(),
|
|
7367
|
-
processedAt: external_exports.date()
|
|
7519
|
+
customEventName: external_exports.string().optional()
|
|
7368
7520
|
});
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
7373
|
-
|
|
7374
|
-
"RS512",
|
|
7375
|
-
"ES256",
|
|
7376
|
-
"ES384",
|
|
7377
|
-
"ES512",
|
|
7378
|
-
"HS256",
|
|
7379
|
-
"HS384",
|
|
7380
|
-
"HS512"
|
|
7381
|
-
]);
|
|
7382
|
-
var VerificationProviderSchema = external_exports.enum([
|
|
7383
|
-
"chatgpt",
|
|
7384
|
-
"claude",
|
|
7385
|
-
"gemini",
|
|
7386
|
-
"perplexity",
|
|
7387
|
-
"custom"
|
|
7388
|
-
]);
|
|
7389
|
-
var SignatureVerificationRequestSchema = external_exports.object({
|
|
7390
|
-
// Signature to verify (from header)
|
|
7391
|
-
signature: external_exports.string().min(1),
|
|
7392
|
-
// Payload that was signed
|
|
7393
|
-
payload: external_exports.string().optional(),
|
|
7394
|
-
// Timestamp of signature
|
|
7395
|
-
timestamp: external_exports.number().optional(),
|
|
7396
|
-
// Provider-specific fields
|
|
7397
|
-
provider: VerificationProviderSchema.default("chatgpt"),
|
|
7398
|
-
// Public key (if custom provider)
|
|
7399
|
-
publicKey: external_exports.string().optional(),
|
|
7400
|
-
// Algorithm hint
|
|
7401
|
-
algorithm: SignatureAlgorithmSchema.optional(),
|
|
7402
|
-
// Additional headers for context
|
|
7403
|
-
headers: external_exports.record(external_exports.string()).optional()
|
|
7521
|
+
var BatchPixelEventRequestSchema = external_exports.object({
|
|
7522
|
+
pixelId: external_exports.string(),
|
|
7523
|
+
secretKey: external_exports.string().optional(),
|
|
7524
|
+
events: external_exports.array(PixelEventSchema).min(1).max(100),
|
|
7525
|
+
compressed: external_exports.boolean().default(false)
|
|
7404
7526
|
});
|
|
7405
|
-
var
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
validTo: external_exports.date(),
|
|
7428
|
-
fingerprint: external_exports.string()
|
|
7429
|
-
}).optional()
|
|
7430
|
-
}).optional(),
|
|
7431
|
-
// Error information if verification failed
|
|
7432
|
-
error: external_exports.object({
|
|
7433
|
-
code: external_exports.string(),
|
|
7434
|
-
message: external_exports.string(),
|
|
7435
|
-
reason: external_exports.enum([
|
|
7436
|
-
"invalid_signature",
|
|
7437
|
-
"expired_signature",
|
|
7438
|
-
"invalid_timestamp",
|
|
7439
|
-
"unknown_provider",
|
|
7440
|
-
"missing_public_key",
|
|
7441
|
-
"invalid_algorithm",
|
|
7442
|
-
"payload_mismatch"
|
|
7443
|
-
]).optional()
|
|
7444
|
-
}).optional(),
|
|
7445
|
-
// Metadata
|
|
7446
|
-
metadata: external_exports.object({
|
|
7447
|
-
requestId: external_exports.string().uuid(),
|
|
7448
|
-
verifiedAt: external_exports.date(),
|
|
7449
|
-
cached: external_exports.boolean().optional()
|
|
7450
|
-
}).optional()
|
|
7527
|
+
var PixelInstallConfigSchema = external_exports.object({
|
|
7528
|
+
pixelId: external_exports.string(),
|
|
7529
|
+
endpoint: external_exports.string().url().default("https://api.agentshield.ai/v1/pixel"),
|
|
7530
|
+
// Tracking Options
|
|
7531
|
+
autoTrack: external_exports.boolean().default(true),
|
|
7532
|
+
trackPageviews: external_exports.boolean().default(true),
|
|
7533
|
+
trackDetections: external_exports.boolean().default(true),
|
|
7534
|
+
trackBehavior: external_exports.boolean().default(false),
|
|
7535
|
+
// Performance Options
|
|
7536
|
+
batchEvents: external_exports.boolean().default(true),
|
|
7537
|
+
batchSize: external_exports.number().min(1).max(100).default(10),
|
|
7538
|
+
flushInterval: external_exports.number().min(1e3).max(6e4).default(5e3),
|
|
7539
|
+
// Privacy Options
|
|
7540
|
+
respectDoNotTrack: external_exports.boolean().default(true),
|
|
7541
|
+
anonymizeIp: external_exports.boolean().default(false),
|
|
7542
|
+
// Session Options
|
|
7543
|
+
sessionTimeout: external_exports.number().min(6e4).default(18e5),
|
|
7544
|
+
// 30 minutes
|
|
7545
|
+
sessionCookieName: external_exports.string().default("_as_session"),
|
|
7546
|
+
// Debug Options
|
|
7547
|
+
debug: external_exports.boolean().default(false),
|
|
7548
|
+
logLevel: external_exports.enum(["error", "warn", "info", "debug"]).default("error")
|
|
7451
7549
|
});
|
|
7452
|
-
var
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
|
|
7457
|
-
validFrom: external_exports.date(),
|
|
7458
|
-
validTo: external_exports.date().optional(),
|
|
7459
|
-
active: external_exports.boolean().default(true)
|
|
7550
|
+
var PixelInitSchema = external_exports.object({
|
|
7551
|
+
config: PixelInstallConfigSchema,
|
|
7552
|
+
onReady: external_exports.function().optional(),
|
|
7553
|
+
onError: external_exports.function().optional(),
|
|
7554
|
+
onDetection: external_exports.function().optional()
|
|
7460
7555
|
});
|
|
7461
|
-
var
|
|
7462
|
-
|
|
7463
|
-
|
|
7464
|
-
|
|
7465
|
-
|
|
7466
|
-
|
|
7556
|
+
var ClientDetectionSchema = external_exports.object({
|
|
7557
|
+
// Critical Perplexity detection signals
|
|
7558
|
+
headless: external_exports.boolean().optional(),
|
|
7559
|
+
canvas: external_exports.string().optional(),
|
|
7560
|
+
webrtc: external_exports.string().optional(),
|
|
7561
|
+
plugins: external_exports.number().optional(),
|
|
7562
|
+
automation: external_exports.string().nullable().optional(),
|
|
7563
|
+
// Browser characteristics
|
|
7564
|
+
chrome: external_exports.boolean().optional(),
|
|
7565
|
+
languages: external_exports.array(external_exports.string()).optional(),
|
|
7566
|
+
hardwareConcurrency: external_exports.number().nullable().optional(),
|
|
7567
|
+
deviceMemory: external_exports.number().nullable().optional(),
|
|
7568
|
+
maxTouchPoints: external_exports.number().optional(),
|
|
7569
|
+
platform: external_exports.string().optional(),
|
|
7570
|
+
vendor: external_exports.string().optional(),
|
|
7571
|
+
screenResolution: external_exports.string().optional(),
|
|
7572
|
+
colorDepth: external_exports.number().optional(),
|
|
7573
|
+
pixelRatio: external_exports.number().optional(),
|
|
7574
|
+
timezone: external_exports.string().optional(),
|
|
7575
|
+
timezoneOffset: external_exports.number().optional(),
|
|
7576
|
+
cookieEnabled: external_exports.boolean().optional(),
|
|
7577
|
+
localStorage: external_exports.boolean().optional(),
|
|
7578
|
+
sessionStorage: external_exports.boolean().optional(),
|
|
7579
|
+
doNotTrack: external_exports.string().nullable().optional(),
|
|
7580
|
+
hasTouch: external_exports.boolean().optional(),
|
|
7581
|
+
// Interaction metrics
|
|
7582
|
+
mouseMovements: external_exports.number().optional(),
|
|
7583
|
+
keyboardEvents: external_exports.number().optional(),
|
|
7584
|
+
scrollEvents: external_exports.number().optional(),
|
|
7585
|
+
clickEvents: external_exports.number().optional(),
|
|
7586
|
+
touchEvents: external_exports.number().optional(),
|
|
7587
|
+
hasInteraction: external_exports.boolean().optional(),
|
|
7588
|
+
// Connection info
|
|
7589
|
+
connection: external_exports.object({
|
|
7590
|
+
effectiveType: external_exports.string().optional(),
|
|
7591
|
+
rtt: external_exports.number().optional(),
|
|
7592
|
+
downlink: external_exports.number().optional(),
|
|
7593
|
+
saveData: external_exports.boolean().optional()
|
|
7594
|
+
}).nullable().optional(),
|
|
7595
|
+
// Performance metrics
|
|
7596
|
+
performance: external_exports.object({
|
|
7597
|
+
navigation: external_exports.number().nullable().optional(),
|
|
7598
|
+
memory: external_exports.object({
|
|
7599
|
+
usedJSHeapSize: external_exports.number().optional(),
|
|
7600
|
+
totalJSHeapSize: external_exports.number().optional(),
|
|
7601
|
+
jsHeapSizeLimit: external_exports.number().optional()
|
|
7602
|
+
}).optional()
|
|
7603
|
+
}).nullable().optional(),
|
|
7604
|
+
// Collection metadata
|
|
7605
|
+
collectionTime: external_exports.number().optional(),
|
|
7606
|
+
timestamp: external_exports.string().optional(),
|
|
7607
|
+
error: external_exports.string().optional()
|
|
7467
7608
|
});
|
|
7468
|
-
|
|
7469
|
-
//
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
|
|
7474
|
-
|
|
7475
|
-
|
|
7476
|
-
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
|
|
7609
|
+
var PixelTrackingRequestSchema = external_exports.object({
|
|
7610
|
+
// Pixel identification
|
|
7611
|
+
pixelId: external_exports.string(),
|
|
7612
|
+
// UUID of the pixel
|
|
7613
|
+
sessionId: external_exports.string(),
|
|
7614
|
+
// Session identifier
|
|
7615
|
+
// User identification
|
|
7616
|
+
userId: external_exports.string().nullable().optional(),
|
|
7617
|
+
// Identified user ID
|
|
7618
|
+
userTraits: external_exports.record(external_exports.unknown()).optional().refine((traits) => !traits || JSON.stringify(traits).length < 1e4, {
|
|
7619
|
+
message: "User traits too large (max 10KB)"
|
|
7620
|
+
}).refine((traits) => !traits || Object.keys(traits).length < 50, {
|
|
7621
|
+
message: "Too many user trait properties (max 50)"
|
|
7622
|
+
}).refine(
|
|
7623
|
+
(traits) => {
|
|
7624
|
+
if (!traits) return true;
|
|
7625
|
+
const validateDepth = (obj, depth = 0) => {
|
|
7626
|
+
if (depth > 3) return false;
|
|
7627
|
+
if (typeof obj !== "object" || obj === null) return true;
|
|
7628
|
+
return Object.values(obj).every((val) => validateDepth(val, depth + 1));
|
|
7629
|
+
};
|
|
7630
|
+
return validateDepth(traits);
|
|
7631
|
+
},
|
|
7632
|
+
{
|
|
7633
|
+
message: "User traits contain overly nested objects (max depth 3)"
|
|
7634
|
+
}
|
|
7635
|
+
),
|
|
7636
|
+
// Page context
|
|
7637
|
+
url: external_exports.string().url(),
|
|
7638
|
+
// Current page URL
|
|
7639
|
+
referrer: external_exports.string().optional(),
|
|
7640
|
+
// Referrer URL
|
|
7641
|
+
title: external_exports.string().optional(),
|
|
7642
|
+
// Page title
|
|
7643
|
+
// Detection data
|
|
7644
|
+
userAgent: external_exports.string(),
|
|
7645
|
+
// Browser user agent
|
|
7646
|
+
headers: external_exports.record(external_exports.string()).optional(),
|
|
7647
|
+
// Any additional headers
|
|
7648
|
+
// Client info
|
|
7649
|
+
screenResolution: external_exports.string().optional(),
|
|
7650
|
+
// "1920x1080"
|
|
7651
|
+
viewport: external_exports.string().optional(),
|
|
7652
|
+
// "1200x800"
|
|
7653
|
+
timezone: external_exports.string().optional(),
|
|
7654
|
+
// "America/New_York"
|
|
7655
|
+
language: external_exports.string().optional(),
|
|
7656
|
+
// "en-US"
|
|
7657
|
+
// Behavioral (if available)
|
|
7658
|
+
timeOnPage: external_exports.number().optional(),
|
|
7659
|
+
// Milliseconds
|
|
7660
|
+
mouseMovements: external_exports.number().optional(),
|
|
7661
|
+
// Count of mouse events
|
|
7662
|
+
clickCount: external_exports.number().optional(),
|
|
7663
|
+
// Number of clicks
|
|
7664
|
+
scrollDepth: external_exports.number().optional(),
|
|
7665
|
+
// Percentage 0-100
|
|
7666
|
+
// Client-side detection data (NEW)
|
|
7667
|
+
clientDetection: ClientDetectionSchema.optional(),
|
|
7668
|
+
// Request tracking (client-provided, will be validated server-side)
|
|
7669
|
+
requestId: external_exports.string().optional(),
|
|
7670
|
+
// Unique request ID for deduplication
|
|
7671
|
+
// Event type for special events
|
|
7672
|
+
eventType: external_exports.string().optional(),
|
|
7673
|
+
// 'pageview', 'identify', 'logout', etc.
|
|
7674
|
+
// Metadata
|
|
7675
|
+
timestamp: external_exports.string(),
|
|
7676
|
+
// ISO 8601
|
|
7677
|
+
version: external_exports.string().optional()
|
|
7678
|
+
// Pixel version
|
|
7480
7679
|
});
|
|
7481
|
-
var
|
|
7482
|
-
|
|
7483
|
-
|
|
7680
|
+
var InternalProcessingFlagsSchema = external_exports.object({
|
|
7681
|
+
edgeProcessed: external_exports.boolean().optional(),
|
|
7682
|
+
// Request was handled by Edge endpoint
|
|
7683
|
+
skipDatabaseWrite: external_exports.boolean().optional(),
|
|
7684
|
+
// Skip DB write for low-value detections
|
|
7685
|
+
serverRequestId: external_exports.string().optional()
|
|
7686
|
+
// Server-generated request ID
|
|
7484
7687
|
});
|
|
7485
|
-
var
|
|
7486
|
-
index: external_exports.number(),
|
|
7688
|
+
var PixelTrackingResponseSchema = external_exports.object({
|
|
7487
7689
|
success: external_exports.boolean(),
|
|
7488
|
-
|
|
7690
|
+
eventId: external_exports.string().uuid().optional(),
|
|
7691
|
+
sessionId: external_exports.string().optional(),
|
|
7692
|
+
detection: DetectionResultSchema.optional(),
|
|
7489
7693
|
error: external_exports.object({
|
|
7490
7694
|
code: external_exports.string(),
|
|
7491
|
-
message: external_exports.string()
|
|
7492
|
-
details: external_exports.unknown().optional()
|
|
7695
|
+
message: external_exports.string()
|
|
7493
7696
|
}).optional()
|
|
7494
7697
|
});
|
|
7495
|
-
var
|
|
7496
|
-
|
|
7497
|
-
|
|
7498
|
-
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
|
|
7503
|
-
|
|
7504
|
-
|
|
7698
|
+
var PixelAnalyticsSchema = external_exports.object({
|
|
7699
|
+
pixelId: external_exports.string(),
|
|
7700
|
+
period: external_exports.object({
|
|
7701
|
+
start: external_exports.date(),
|
|
7702
|
+
end: external_exports.date()
|
|
7703
|
+
}),
|
|
7704
|
+
metrics: external_exports.object({
|
|
7705
|
+
totalEvents: external_exports.number().int().min(0),
|
|
7706
|
+
uniqueSessions: external_exports.number().int().min(0),
|
|
7707
|
+
agentsDetected: external_exports.number().int().min(0),
|
|
7708
|
+
humanVisitors: external_exports.number().int().min(0),
|
|
7709
|
+
detectionRate: external_exports.number().min(0).max(1),
|
|
7710
|
+
averageConfidence: external_exports.number().min(0).max(1),
|
|
7711
|
+
averageSessionDuration: external_exports.number().min(0),
|
|
7712
|
+
bounceRate: external_exports.number().min(0).max(1)
|
|
7713
|
+
}),
|
|
7714
|
+
topAgents: external_exports.array(
|
|
7715
|
+
external_exports.object({
|
|
7716
|
+
type: external_exports.string(),
|
|
7717
|
+
count: external_exports.number().int().min(0),
|
|
7718
|
+
percentage: external_exports.number().min(0).max(1)
|
|
7719
|
+
})
|
|
7720
|
+
),
|
|
7721
|
+
topPages: external_exports.array(
|
|
7722
|
+
external_exports.object({
|
|
7723
|
+
path: external_exports.string(),
|
|
7724
|
+
views: external_exports.number().int().min(0),
|
|
7725
|
+
agentViews: external_exports.number().int().min(0)
|
|
7726
|
+
})
|
|
7727
|
+
),
|
|
7728
|
+
hourlyDistribution: external_exports.array(
|
|
7729
|
+
external_exports.object({
|
|
7730
|
+
hour: external_exports.number().int().min(0).max(23),
|
|
7731
|
+
events: external_exports.number().int().min(0)
|
|
7732
|
+
})
|
|
7733
|
+
)
|
|
7734
|
+
});
|
|
7735
|
+
var PixelSessionSchema = external_exports.object({
|
|
7736
|
+
id: external_exports.string(),
|
|
7737
|
+
pixelId: external_exports.string(),
|
|
7738
|
+
startTime: external_exports.date(),
|
|
7739
|
+
endTime: external_exports.date().optional(),
|
|
7740
|
+
duration: external_exports.number().min(0),
|
|
7741
|
+
pageViews: external_exports.number().int().min(0),
|
|
7742
|
+
events: external_exports.number().int().min(0),
|
|
7743
|
+
isAgent: external_exports.boolean(),
|
|
7744
|
+
confidence: external_exports.number().min(0).max(1).optional(),
|
|
7745
|
+
agentType: external_exports.string().optional(),
|
|
7746
|
+
ipAddress: external_exports.string().optional(),
|
|
7747
|
+
userAgent: external_exports.string().optional(),
|
|
7748
|
+
referrer: external_exports.string().optional(),
|
|
7749
|
+
entryPage: external_exports.string().optional(),
|
|
7750
|
+
exitPage: external_exports.string().optional(),
|
|
7751
|
+
behavioral: BehavioralSignalsSchema.optional()
|
|
7752
|
+
});
|
|
7753
|
+
var PixelVerificationStatusSchema = external_exports.object({
|
|
7754
|
+
status: external_exports.enum(["verified", "partial", "pending", "failed"]),
|
|
7755
|
+
message: external_exports.string(),
|
|
7756
|
+
verified: external_exports.boolean(),
|
|
7757
|
+
lastDetection: external_exports.date().nullable(),
|
|
7758
|
+
detectionCount: external_exports.number().int().min(0),
|
|
7505
7759
|
metadata: external_exports.object({
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
|
|
7760
|
+
recentDetections: external_exports.number().int().min(0),
|
|
7761
|
+
failedDetections: external_exports.number().int().min(0),
|
|
7762
|
+
timeWindow: external_exports.string()
|
|
7509
7763
|
}).optional()
|
|
7510
7764
|
});
|
|
7511
|
-
var
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
pixels: external_exports.number(),
|
|
7518
|
-
apiKeys: external_exports.number(),
|
|
7519
|
-
members: external_exports.number(),
|
|
7520
|
-
bouncerConfigs: external_exports.number(),
|
|
7521
|
-
delegations: external_exports.number(),
|
|
7522
|
-
bouncerProofs: external_exports.number(),
|
|
7523
|
-
bouncerSessions: external_exports.number(),
|
|
7524
|
-
userAccounts: external_exports.number(),
|
|
7525
|
-
userProfiles: external_exports.number()
|
|
7765
|
+
var PixelUserIdentificationSchema = external_exports.object({
|
|
7766
|
+
userId: external_exports.string(),
|
|
7767
|
+
traits: external_exports.record(external_exports.unknown()).optional().refine((traits) => !traits || JSON.stringify(traits).length < 1e4, {
|
|
7768
|
+
message: "User traits too large (max 10KB)"
|
|
7769
|
+
}).refine((traits) => !traits || Object.keys(traits).length < 50, {
|
|
7770
|
+
message: "Too many user trait properties (max 50)"
|
|
7526
7771
|
}),
|
|
7527
|
-
|
|
7772
|
+
email: external_exports.string().email().optional(),
|
|
7773
|
+
name: external_exports.string().optional(),
|
|
7774
|
+
plan: external_exports.string().optional(),
|
|
7775
|
+
company: external_exports.string().optional(),
|
|
7776
|
+
timestamp: external_exports.string()
|
|
7528
7777
|
});
|
|
7529
|
-
var
|
|
7530
|
-
|
|
7778
|
+
var DetectionViewTypeSchema = external_exports.enum(["verification", "list"]);
|
|
7779
|
+
var DetectionStatusSchema = external_exports.enum(["success", "partial", "failed", "error"]);
|
|
7780
|
+
var DetectionErrorDetailsSchema = external_exports.object({
|
|
7781
|
+
type: external_exports.enum(["wasm_failed", "fallback_failed", "both_failed"]),
|
|
7782
|
+
message: external_exports.string(),
|
|
7783
|
+
retryable: external_exports.boolean()
|
|
7531
7784
|
});
|
|
7532
|
-
|
|
7533
|
-
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
|
|
7537
|
-
|
|
7538
|
-
|
|
7539
|
-
|
|
7540
|
-
|
|
7541
|
-
|
|
7542
|
-
|
|
7543
|
-
|
|
7544
|
-
|
|
7545
|
-
|
|
7785
|
+
|
|
7786
|
+
// src/api/event.ts
|
|
7787
|
+
var EventTrackingRequestSchema = external_exports.object({
|
|
7788
|
+
// Required fields
|
|
7789
|
+
pixelId: external_exports.string().uuid(),
|
|
7790
|
+
sessionId: external_exports.string().min(1).max(255),
|
|
7791
|
+
url: external_exports.string().url(),
|
|
7792
|
+
userAgent: external_exports.string().min(1).max(1024),
|
|
7793
|
+
// Optional fields
|
|
7794
|
+
ip: external_exports.string().ip().optional(),
|
|
7795
|
+
timestamp: external_exports.string().datetime().optional(),
|
|
7796
|
+
referrer: external_exports.string().url().optional(),
|
|
7797
|
+
method: external_exports.enum(["GET", "POST", "PUT", "DELETE", "PATCH"]).optional(),
|
|
7798
|
+
// Headers for additional context
|
|
7799
|
+
headers: external_exports.record(external_exports.string()).optional(),
|
|
7800
|
+
// Behavioral tracking data
|
|
7801
|
+
behavioralData: BehavioralDataSchema.optional(),
|
|
7802
|
+
// Client-side browser fingerprint (headless/automation tells, interaction).
|
|
7803
|
+
// Optional + additive: legacy clients that omit it are unaffected.
|
|
7804
|
+
clientDetection: ClientDetectionSchema.optional(),
|
|
7805
|
+
// Page metrics
|
|
7806
|
+
timeOnPage: external_exports.number().min(0).optional(),
|
|
7807
|
+
scrollDepth: external_exports.number().min(0).max(100).optional(),
|
|
7808
|
+
clickCount: external_exports.number().min(0).optional(),
|
|
7809
|
+
mouseMovements: external_exports.number().min(0).optional(),
|
|
7810
|
+
keystrokes: external_exports.number().min(0).optional(),
|
|
7811
|
+
// Device/viewport info
|
|
7812
|
+
screenResolution: external_exports.string().optional(),
|
|
7813
|
+
viewport: external_exports.string().optional(),
|
|
7814
|
+
// Custom metadata
|
|
7815
|
+
metadata: external_exports.record(external_exports.unknown()).optional()
|
|
7546
7816
|
});
|
|
7547
|
-
var
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7817
|
+
var EventTrackingResponseSchema = external_exports.object({
|
|
7818
|
+
success: external_exports.boolean(),
|
|
7819
|
+
eventId: external_exports.string().uuid(),
|
|
7820
|
+
sessionId: external_exports.string(),
|
|
7821
|
+
detection: DetectionResultSchema,
|
|
7822
|
+
// Rate limit info
|
|
7823
|
+
rateLimit: external_exports.object({
|
|
7824
|
+
limit: external_exports.number(),
|
|
7825
|
+
remaining: external_exports.number(),
|
|
7826
|
+
reset: external_exports.number()
|
|
7827
|
+
}).optional(),
|
|
7828
|
+
// Debug info (only in development)
|
|
7829
|
+
debug: external_exports.object({
|
|
7830
|
+
processingTime: external_exports.number(),
|
|
7831
|
+
rulesVersion: external_exports.string(),
|
|
7832
|
+
serverRegion: external_exports.string().optional(),
|
|
7833
|
+
cacheHit: external_exports.boolean().optional()
|
|
7561
7834
|
}).optional()
|
|
7562
7835
|
});
|
|
7563
|
-
var
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7836
|
+
var BatchEventRequestSchema = external_exports.object({
|
|
7837
|
+
// API key for authentication (required for batch)
|
|
7838
|
+
apiKey: external_exports.string().min(32).optional(),
|
|
7839
|
+
// Can be in header instead
|
|
7840
|
+
// Array of events (max 100)
|
|
7841
|
+
events: external_exports.array(EventTrackingRequestSchema).min(1).max(100),
|
|
7842
|
+
// Processing options
|
|
7843
|
+
options: external_exports.object({
|
|
7844
|
+
parallel: external_exports.boolean().default(true),
|
|
7845
|
+
continueOnError: external_exports.boolean().default(true),
|
|
7846
|
+
includeDetailed: external_exports.boolean().default(false)
|
|
7847
|
+
}).optional()
|
|
7568
7848
|
});
|
|
7569
|
-
var
|
|
7570
|
-
external_exports.
|
|
7571
|
-
|
|
7572
|
-
|
|
7573
|
-
|
|
7574
|
-
}),
|
|
7575
|
-
external_exports.object({
|
|
7576
|
-
operation: external_exports.literal("update"),
|
|
7577
|
-
items: external_exports.array(ProjectsBulkUpdateItemSchema).min(1).max(100)
|
|
7578
|
-
}),
|
|
7849
|
+
var BatchEventResponseSchema = external_exports.object({
|
|
7850
|
+
success: external_exports.boolean(),
|
|
7851
|
+
batchId: external_exports.string().uuid(),
|
|
7852
|
+
// Processing results
|
|
7853
|
+
results: external_exports.array(
|
|
7579
7854
|
external_exports.object({
|
|
7580
|
-
|
|
7581
|
-
|
|
7855
|
+
index: external_exports.number(),
|
|
7856
|
+
eventId: external_exports.string().uuid().optional(),
|
|
7857
|
+
success: external_exports.boolean(),
|
|
7858
|
+
detection: DetectionResultSchema.optional(),
|
|
7859
|
+
error: external_exports.object({
|
|
7860
|
+
code: external_exports.string(),
|
|
7861
|
+
message: external_exports.string()
|
|
7862
|
+
}).optional()
|
|
7582
7863
|
})
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
|
|
7586
|
-
|
|
7587
|
-
|
|
7588
|
-
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
|
|
7592
|
-
|
|
7593
|
-
|
|
7594
|
-
|
|
7595
|
-
|
|
7864
|
+
),
|
|
7865
|
+
// Summary statistics
|
|
7866
|
+
summary: external_exports.object({
|
|
7867
|
+
total: external_exports.number(),
|
|
7868
|
+
successful: external_exports.number(),
|
|
7869
|
+
failed: external_exports.number(),
|
|
7870
|
+
agentsDetected: external_exports.number(),
|
|
7871
|
+
averageConfidence: external_exports.number().min(0).max(1),
|
|
7872
|
+
processingTime: external_exports.number()
|
|
7873
|
+
}),
|
|
7874
|
+
// Rate limit info
|
|
7875
|
+
rateLimit: external_exports.object({
|
|
7876
|
+
limit: external_exports.number(),
|
|
7877
|
+
remaining: external_exports.number(),
|
|
7878
|
+
reset: external_exports.number()
|
|
7596
7879
|
}).optional()
|
|
7597
7880
|
});
|
|
7598
|
-
var
|
|
7881
|
+
var EventStorageRecordSchema = external_exports.object({
|
|
7599
7882
|
id: external_exports.string().uuid(),
|
|
7600
|
-
|
|
7601
|
-
|
|
7602
|
-
|
|
7603
|
-
|
|
7604
|
-
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
|
|
7883
|
+
pixelId: external_exports.string().uuid(),
|
|
7884
|
+
projectId: external_exports.string().uuid(),
|
|
7885
|
+
sessionId: external_exports.string(),
|
|
7886
|
+
// Request data
|
|
7887
|
+
url: external_exports.string(),
|
|
7888
|
+
userAgent: external_exports.string(),
|
|
7889
|
+
ipAddress: external_exports.string().optional(),
|
|
7890
|
+
referrer: external_exports.string().optional(),
|
|
7891
|
+
// Detection results
|
|
7892
|
+
isAgent: external_exports.boolean(),
|
|
7893
|
+
confidence: external_exports.number().min(0).max(1),
|
|
7894
|
+
agentType: external_exports.string().optional(),
|
|
7895
|
+
detectionMethod: external_exports.array(external_exports.string()).optional(),
|
|
7896
|
+
// Behavioral metrics
|
|
7897
|
+
timeOnPage: external_exports.number().optional(),
|
|
7898
|
+
scrollDepth: external_exports.number().optional(),
|
|
7899
|
+
clickCount: external_exports.number().optional(),
|
|
7900
|
+
// Metadata
|
|
7901
|
+
metadata: external_exports.record(external_exports.unknown()).optional(),
|
|
7902
|
+
// Timestamps
|
|
7903
|
+
createdAt: external_exports.date(),
|
|
7904
|
+
processedAt: external_exports.date()
|
|
7905
|
+
});
|
|
7906
|
+
|
|
7907
|
+
// src/api/verification.ts
|
|
7908
|
+
var SignatureAlgorithmSchema = external_exports.enum([
|
|
7909
|
+
"RS256",
|
|
7910
|
+
"RS384",
|
|
7911
|
+
"RS512",
|
|
7912
|
+
"ES256",
|
|
7913
|
+
"ES384",
|
|
7914
|
+
"ES512",
|
|
7915
|
+
"HS256",
|
|
7916
|
+
"HS384",
|
|
7917
|
+
"HS512"
|
|
7918
|
+
]);
|
|
7919
|
+
var VerificationProviderSchema = external_exports.enum([
|
|
7920
|
+
"chatgpt",
|
|
7921
|
+
"claude",
|
|
7922
|
+
"gemini",
|
|
7923
|
+
"perplexity",
|
|
7924
|
+
"custom"
|
|
7925
|
+
]);
|
|
7926
|
+
var SignatureVerificationRequestSchema = external_exports.object({
|
|
7927
|
+
// Signature to verify (from header)
|
|
7928
|
+
signature: external_exports.string().min(1),
|
|
7929
|
+
// Payload that was signed
|
|
7930
|
+
payload: external_exports.string().optional(),
|
|
7931
|
+
// Timestamp of signature
|
|
7932
|
+
timestamp: external_exports.number().optional(),
|
|
7933
|
+
// Provider-specific fields
|
|
7934
|
+
provider: VerificationProviderSchema.default("chatgpt"),
|
|
7935
|
+
// Public key (if custom provider)
|
|
7936
|
+
publicKey: external_exports.string().optional(),
|
|
7937
|
+
// Algorithm hint
|
|
7938
|
+
algorithm: SignatureAlgorithmSchema.optional(),
|
|
7939
|
+
// Additional headers for context
|
|
7940
|
+
headers: external_exports.record(external_exports.string()).optional()
|
|
7941
|
+
});
|
|
7942
|
+
var SignatureVerificationResponseSchema = external_exports.object({
|
|
7943
|
+
success: external_exports.boolean(),
|
|
7944
|
+
// Verification result
|
|
7945
|
+
verified: external_exports.boolean(),
|
|
7946
|
+
// Verification details
|
|
7947
|
+
details: external_exports.object({
|
|
7948
|
+
provider: VerificationProviderSchema,
|
|
7949
|
+
algorithm: SignatureAlgorithmSchema.optional(),
|
|
7950
|
+
timestamp: external_exports.number().optional(),
|
|
7951
|
+
expiresAt: external_exports.number().optional(),
|
|
7952
|
+
// Agent information if verified
|
|
7953
|
+
agent: external_exports.object({
|
|
7954
|
+
type: external_exports.string(),
|
|
7955
|
+
name: external_exports.string(),
|
|
7956
|
+
version: external_exports.string().optional(),
|
|
7957
|
+
verified: external_exports.boolean()
|
|
7958
|
+
}).optional(),
|
|
7959
|
+
// Certificate info if available
|
|
7960
|
+
certificate: external_exports.object({
|
|
7961
|
+
subject: external_exports.string(),
|
|
7962
|
+
issuer: external_exports.string(),
|
|
7963
|
+
validFrom: external_exports.date(),
|
|
7964
|
+
validTo: external_exports.date(),
|
|
7965
|
+
fingerprint: external_exports.string()
|
|
7966
|
+
}).optional()
|
|
7967
|
+
}).optional(),
|
|
7968
|
+
// Error information if verification failed
|
|
7969
|
+
error: external_exports.object({
|
|
7970
|
+
code: external_exports.string(),
|
|
7971
|
+
message: external_exports.string(),
|
|
7972
|
+
reason: external_exports.enum([
|
|
7973
|
+
"invalid_signature",
|
|
7974
|
+
"expired_signature",
|
|
7975
|
+
"invalid_timestamp",
|
|
7976
|
+
"unknown_provider",
|
|
7977
|
+
"missing_public_key",
|
|
7978
|
+
"invalid_algorithm",
|
|
7979
|
+
"payload_mismatch"
|
|
7980
|
+
]).optional()
|
|
7981
|
+
}).optional(),
|
|
7982
|
+
// Metadata
|
|
7983
|
+
metadata: external_exports.object({
|
|
7984
|
+
requestId: external_exports.string().uuid(),
|
|
7985
|
+
verifiedAt: external_exports.date(),
|
|
7986
|
+
cached: external_exports.boolean().optional()
|
|
7609
7987
|
}).optional()
|
|
7610
7988
|
});
|
|
7611
|
-
var
|
|
7612
|
-
|
|
7989
|
+
var PublicKeyConfigSchema = external_exports.object({
|
|
7990
|
+
provider: VerificationProviderSchema,
|
|
7991
|
+
keyId: external_exports.string(),
|
|
7992
|
+
publicKey: external_exports.string(),
|
|
7993
|
+
algorithm: SignatureAlgorithmSchema,
|
|
7994
|
+
validFrom: external_exports.date(),
|
|
7995
|
+
validTo: external_exports.date().optional(),
|
|
7996
|
+
active: external_exports.boolean().default(true)
|
|
7613
7997
|
});
|
|
7614
|
-
var
|
|
7615
|
-
|
|
7998
|
+
var VerificationCacheEntrySchema = external_exports.object({
|
|
7999
|
+
signature: external_exports.string(),
|
|
8000
|
+
verified: external_exports.boolean(),
|
|
8001
|
+
provider: VerificationProviderSchema,
|
|
8002
|
+
timestamp: external_exports.number(),
|
|
8003
|
+
expiresAt: external_exports.number()
|
|
7616
8004
|
});
|
|
7617
|
-
|
|
8005
|
+
|
|
8006
|
+
// src/api/bulk.ts
|
|
8007
|
+
var BulkOperationTypeSchema = external_exports.enum(["create", "update", "delete"]);
|
|
8008
|
+
var BulkOperationOptionsSchema = external_exports.object({
|
|
8009
|
+
/** Continue processing remaining items on failure */
|
|
8010
|
+
continueOnError: external_exports.boolean().default(true).optional(),
|
|
8011
|
+
/** Execute all operations in a single transaction (all-or-nothing) */
|
|
8012
|
+
transactional: external_exports.boolean().default(false).optional(),
|
|
8013
|
+
/** Validate only without executing (dry run) */
|
|
8014
|
+
validateOnly: external_exports.boolean().default(false).optional(),
|
|
8015
|
+
/** Preview what would be deleted without executing (alias for validateOnly on delete) */
|
|
8016
|
+
dryRun: external_exports.boolean().default(false).optional()
|
|
8017
|
+
});
|
|
8018
|
+
var BaseBulkRequestSchema = external_exports.object({
|
|
8019
|
+
operation: BulkOperationTypeSchema,
|
|
8020
|
+
options: BulkOperationOptionsSchema.optional()
|
|
8021
|
+
});
|
|
8022
|
+
var BulkResultItemSchema = external_exports.object({
|
|
8023
|
+
index: external_exports.number(),
|
|
8024
|
+
success: external_exports.boolean(),
|
|
8025
|
+
data: external_exports.unknown().optional(),
|
|
8026
|
+
error: external_exports.object({
|
|
8027
|
+
code: external_exports.string(),
|
|
8028
|
+
message: external_exports.string(),
|
|
8029
|
+
details: external_exports.unknown().optional()
|
|
8030
|
+
}).optional()
|
|
8031
|
+
});
|
|
8032
|
+
var BulkResponseSchema = external_exports.object({
|
|
8033
|
+
success: external_exports.boolean(),
|
|
8034
|
+
batchId: external_exports.string().uuid(),
|
|
8035
|
+
summary: external_exports.object({
|
|
8036
|
+
total: external_exports.number(),
|
|
8037
|
+
succeeded: external_exports.number(),
|
|
8038
|
+
failed: external_exports.number(),
|
|
8039
|
+
skipped: external_exports.number()
|
|
8040
|
+
}),
|
|
8041
|
+
results: external_exports.array(BulkResultItemSchema),
|
|
8042
|
+
metadata: external_exports.object({
|
|
8043
|
+
processingTime: external_exports.number(),
|
|
8044
|
+
transactional: external_exports.boolean(),
|
|
8045
|
+
dryRun: external_exports.boolean().optional()
|
|
8046
|
+
}).optional()
|
|
8047
|
+
});
|
|
8048
|
+
var BulkDeletePreviewStatsSchema = external_exports.object({
|
|
8049
|
+
projectId: external_exports.string().uuid(),
|
|
8050
|
+
friendlyId: external_exports.string().nullable(),
|
|
8051
|
+
name: external_exports.string(),
|
|
8052
|
+
counts: external_exports.object({
|
|
8053
|
+
detections: external_exports.number(),
|
|
8054
|
+
pixels: external_exports.number(),
|
|
8055
|
+
apiKeys: external_exports.number(),
|
|
8056
|
+
members: external_exports.number(),
|
|
8057
|
+
bouncerConfigs: external_exports.number(),
|
|
8058
|
+
delegations: external_exports.number(),
|
|
8059
|
+
bouncerProofs: external_exports.number(),
|
|
8060
|
+
bouncerSessions: external_exports.number(),
|
|
8061
|
+
userAccounts: external_exports.number(),
|
|
8062
|
+
userProfiles: external_exports.number()
|
|
8063
|
+
}),
|
|
8064
|
+
totalRecords: external_exports.number()
|
|
8065
|
+
});
|
|
8066
|
+
var BulkDeleteResponseSchema = BulkResponseSchema.extend({
|
|
8067
|
+
preview: external_exports.array(BulkDeletePreviewStatsSchema).optional()
|
|
8068
|
+
});
|
|
8069
|
+
var ProjectsBulkCreateItemSchema = external_exports.object({
|
|
8070
|
+
name: external_exports.string().min(1).max(255),
|
|
8071
|
+
domain: external_exports.string().url().optional(),
|
|
8072
|
+
settings: external_exports.object({
|
|
8073
|
+
blockOnHighConfidence: external_exports.boolean().default(false),
|
|
8074
|
+
confidenceThreshold: external_exports.number().min(0).max(1).default(0.8),
|
|
8075
|
+
enableSessionTracking: external_exports.boolean().default(true),
|
|
8076
|
+
enableWasm: external_exports.boolean().default(true),
|
|
8077
|
+
customDomain: external_exports.string().optional(),
|
|
8078
|
+
allowedOrigins: external_exports.array(external_exports.string()).default([]),
|
|
8079
|
+
blockedAgents: external_exports.array(external_exports.string()).default([]),
|
|
8080
|
+
webhookUrl: external_exports.string().url().optional(),
|
|
8081
|
+
webhookSecret: external_exports.string().optional()
|
|
8082
|
+
}).optional()
|
|
8083
|
+
});
|
|
8084
|
+
var ProjectsBulkUpdateItemSchema = external_exports.object({
|
|
8085
|
+
id: external_exports.string().uuid(),
|
|
8086
|
+
name: external_exports.string().min(1).max(255).optional(),
|
|
8087
|
+
domain: external_exports.string().url().optional(),
|
|
8088
|
+
settings: external_exports.object({
|
|
8089
|
+
blockOnHighConfidence: external_exports.boolean().optional(),
|
|
8090
|
+
confidenceThreshold: external_exports.number().min(0).max(1).optional(),
|
|
8091
|
+
enableSessionTracking: external_exports.boolean().optional(),
|
|
8092
|
+
enableWasm: external_exports.boolean().optional(),
|
|
8093
|
+
customDomain: external_exports.string().optional(),
|
|
8094
|
+
allowedOrigins: external_exports.array(external_exports.string()).optional(),
|
|
8095
|
+
blockedAgents: external_exports.array(external_exports.string()).optional(),
|
|
8096
|
+
webhookUrl: external_exports.string().url().optional(),
|
|
8097
|
+
webhookSecret: external_exports.string().optional()
|
|
8098
|
+
}).optional()
|
|
8099
|
+
});
|
|
8100
|
+
var ProjectsBulkDeleteItemSchema = external_exports.object({
|
|
8101
|
+
/** Project UUID to delete */
|
|
8102
|
+
id: external_exports.string().uuid(),
|
|
8103
|
+
/** Skip confirmation for automated cleanup (admin only) */
|
|
8104
|
+
force: external_exports.boolean().optional()
|
|
8105
|
+
});
|
|
8106
|
+
var ProjectsBulkRequestSchema = BaseBulkRequestSchema.and(
|
|
7618
8107
|
external_exports.discriminatedUnion("operation", [
|
|
7619
8108
|
external_exports.object({
|
|
7620
8109
|
operation: external_exports.literal("create"),
|
|
7621
|
-
items: external_exports.array(
|
|
8110
|
+
items: external_exports.array(ProjectsBulkCreateItemSchema).min(1).max(100)
|
|
7622
8111
|
}),
|
|
7623
8112
|
external_exports.object({
|
|
7624
8113
|
operation: external_exports.literal("update"),
|
|
7625
|
-
items: external_exports.array(
|
|
8114
|
+
items: external_exports.array(ProjectsBulkUpdateItemSchema).min(1).max(100)
|
|
7626
8115
|
}),
|
|
7627
8116
|
external_exports.object({
|
|
7628
8117
|
operation: external_exports.literal("delete"),
|
|
7629
|
-
items: external_exports.array(
|
|
8118
|
+
items: external_exports.array(ProjectsBulkDeleteItemSchema).min(1).max(100)
|
|
7630
8119
|
})
|
|
7631
8120
|
])
|
|
7632
8121
|
);
|
|
7633
|
-
var
|
|
8122
|
+
var PixelsBulkCreateItemSchema = external_exports.object({
|
|
8123
|
+
projectId: external_exports.string().uuid(),
|
|
7634
8124
|
name: external_exports.string().min(1).max(255),
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
|
|
7643
|
-
|
|
7644
|
-
});
|
|
7645
|
-
var ApiKeysBulkRevokeItemSchema = external_exports.object({
|
|
7646
|
-
id: external_exports.string().uuid()
|
|
8125
|
+
domain: external_exports.string().url().optional(),
|
|
8126
|
+
isActive: external_exports.boolean().default(true),
|
|
8127
|
+
configuration: external_exports.object({
|
|
8128
|
+
allowedDomains: external_exports.array(external_exports.string()).default([]),
|
|
8129
|
+
collectBehavioral: external_exports.boolean().default(true),
|
|
8130
|
+
enableFingerprinting: external_exports.boolean().default(true),
|
|
8131
|
+
enableSessionTracking: external_exports.boolean().default(true),
|
|
8132
|
+
sampleRate: external_exports.number().min(0).max(1).default(1)
|
|
8133
|
+
}).optional()
|
|
7647
8134
|
});
|
|
7648
|
-
var
|
|
8135
|
+
var PixelsBulkUpdateItemSchema = external_exports.object({
|
|
8136
|
+
id: external_exports.string().uuid(),
|
|
8137
|
+
name: external_exports.string().min(1).max(255).optional(),
|
|
8138
|
+
domain: external_exports.string().url().optional(),
|
|
8139
|
+
isActive: external_exports.boolean().optional(),
|
|
8140
|
+
configuration: external_exports.object({
|
|
8141
|
+
allowedDomains: external_exports.array(external_exports.string()).optional(),
|
|
8142
|
+
collectBehavioral: external_exports.boolean().optional(),
|
|
8143
|
+
enableFingerprinting: external_exports.boolean().optional(),
|
|
8144
|
+
enableSessionTracking: external_exports.boolean().optional(),
|
|
8145
|
+
sampleRate: external_exports.number().min(0).max(1).optional()
|
|
8146
|
+
}).optional()
|
|
8147
|
+
});
|
|
8148
|
+
var PixelsBulkDeleteItemSchema = external_exports.object({
|
|
8149
|
+
id: external_exports.string().uuid()
|
|
8150
|
+
});
|
|
8151
|
+
var PixelsBulkRegenerateItemSchema = external_exports.object({
|
|
8152
|
+
id: external_exports.string().uuid()
|
|
8153
|
+
});
|
|
8154
|
+
var PixelsBulkRequestSchema = BaseBulkRequestSchema.and(
|
|
8155
|
+
external_exports.discriminatedUnion("operation", [
|
|
8156
|
+
external_exports.object({
|
|
8157
|
+
operation: external_exports.literal("create"),
|
|
8158
|
+
items: external_exports.array(PixelsBulkCreateItemSchema).min(1).max(100)
|
|
8159
|
+
}),
|
|
8160
|
+
external_exports.object({
|
|
8161
|
+
operation: external_exports.literal("update"),
|
|
8162
|
+
items: external_exports.array(PixelsBulkUpdateItemSchema).min(1).max(100)
|
|
8163
|
+
}),
|
|
8164
|
+
external_exports.object({
|
|
8165
|
+
operation: external_exports.literal("delete"),
|
|
8166
|
+
items: external_exports.array(PixelsBulkDeleteItemSchema).min(1).max(100)
|
|
8167
|
+
})
|
|
8168
|
+
])
|
|
8169
|
+
);
|
|
8170
|
+
var ApiKeysBulkCreateItemSchema = external_exports.object({
|
|
8171
|
+
name: external_exports.string().min(1).max(255),
|
|
8172
|
+
projectId: external_exports.string().uuid().optional(),
|
|
8173
|
+
permissions: external_exports.array(external_exports.enum(["read", "write", "admin"])).default(["read"]),
|
|
8174
|
+
rateLimits: external_exports.object({
|
|
8175
|
+
requestsPerSecond: external_exports.number().min(1).optional(),
|
|
8176
|
+
requestsPerMinute: external_exports.number().min(1).optional(),
|
|
8177
|
+
requestsPerHour: external_exports.number().min(1).optional(),
|
|
8178
|
+
requestsPerDay: external_exports.number().min(1).optional()
|
|
8179
|
+
}).optional(),
|
|
8180
|
+
expiresAt: external_exports.string().datetime().optional()
|
|
8181
|
+
});
|
|
8182
|
+
var ApiKeysBulkRevokeItemSchema = external_exports.object({
|
|
8183
|
+
id: external_exports.string().uuid()
|
|
8184
|
+
});
|
|
8185
|
+
var ApiKeysBulkUpdateItemSchema = external_exports.object({
|
|
7649
8186
|
id: external_exports.string().uuid(),
|
|
7650
8187
|
name: external_exports.string().min(1).max(255).optional(),
|
|
7651
8188
|
permissions: external_exports.array(external_exports.enum(["read", "write", "admin"])).optional(),
|
|
@@ -8082,7 +8619,13 @@ var ConsentConfigSchema = external_exports.object({
|
|
|
8082
8619
|
consentTheme: external_exports.enum(["light", "dark"]).optional(),
|
|
8083
8620
|
headlineVerb: external_exports.string().min(1).max(40).optional(),
|
|
8084
8621
|
revocationPath: external_exports.string().min(1).max(120).optional(),
|
|
8085
|
-
inactivityDays: external_exports.number().int().min(1).max(3650).optional()
|
|
8622
|
+
inactivityDays: external_exports.number().int().min(1).max(3650).optional(),
|
|
8623
|
+
// draft-kya-http-02 §7 Authorization Host (H1.1 #3244). The RESOLVED bare
|
|
8624
|
+
// host where this project's consent screen + delegation pickup live (null
|
|
8625
|
+
// column → platform default). Surfaced so the consent PEP and the gateway
|
|
8626
|
+
// challenge emitter build consent_uri / pickup_uri from config, never a
|
|
8627
|
+
// hardcoded host. Populated server-side by `loadConsentConfig`.
|
|
8628
|
+
authorizationHost: external_exports.string().min(1).max(255).optional()
|
|
8086
8629
|
});
|
|
8087
8630
|
var ToolConsentOverridesSchema = external_exports.object({
|
|
8088
8631
|
branding: ConsentBrandingSchema.partial().optional(),
|
|
@@ -8404,6 +8947,15 @@ var organizationDomainSchema = external_exports.string().trim().toLowerCase().mi
|
|
|
8404
8947
|
"Domain must be a valid hostname"
|
|
8405
8948
|
);
|
|
8406
8949
|
var clearableOptionalString = (schema) => schema.nullable().optional();
|
|
8950
|
+
var HOSTNAME_REGEX = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+$/;
|
|
8951
|
+
var organizationLogoSchema = external_exports.string().max(500).refine(
|
|
8952
|
+
(v) => {
|
|
8953
|
+
if (v === "") return true;
|
|
8954
|
+
if (v.startsWith("d:")) return HOSTNAME_REGEX.test(v.slice(2));
|
|
8955
|
+
return httpUrlSchema(500).safeParse(v).success;
|
|
8956
|
+
},
|
|
8957
|
+
{ message: "Logo must be an http(s) URL or a d:domain token" }
|
|
8958
|
+
);
|
|
8407
8959
|
var OrganizationSsoProviderSchema = external_exports.enum(["rippling", "saml"]);
|
|
8408
8960
|
var OrganizationSsoModeSchema = external_exports.enum(["optional", "required"]);
|
|
8409
8961
|
var OrganizationSsoSettingsSchema = external_exports.object({
|
|
@@ -8421,7 +8973,15 @@ var OrganizationSsoSettingsSchema = external_exports.object({
|
|
|
8421
8973
|
idpSsoUrl: clearableOptionalString(external_exports.string().url("IdP SSO URL must be a valid URL").max(1e3)),
|
|
8422
8974
|
domains: external_exports.array(organizationDomainSchema).max(50).optional(),
|
|
8423
8975
|
allowPasswordFallback: external_exports.boolean().optional(),
|
|
8424
|
-
autoProvisionMembers: external_exports.boolean().optional()
|
|
8976
|
+
autoProvisionMembers: external_exports.boolean().optional(),
|
|
8977
|
+
/**
|
|
8978
|
+
* ISO-8601 timestamp of the last successful "Test connection". Lets the
|
|
8979
|
+
* verified state survive navigation (it's persisted JSON, re-parsed on
|
|
8980
|
+
* read — must stay a string, not z.date()). Cleared (null) when a
|
|
8981
|
+
* connection-affecting field changes, so a stale verification can't show
|
|
8982
|
+
* as current.
|
|
8983
|
+
*/
|
|
8984
|
+
lastVerifiedAt: clearableOptionalString(external_exports.string().datetime())
|
|
8425
8985
|
}).superRefine((value, ctx) => {
|
|
8426
8986
|
const explicitlyRequiresSso = value.enabled === true && value.mode === "required" && value.allowPasswordFallback === false;
|
|
8427
8987
|
if (explicitlyRequiresSso && !value.loginUrl && !value.idpSsoUrl) {
|
|
@@ -8458,7 +9018,8 @@ var UpdateOrganizationInputSchema = external_exports.object({
|
|
|
8458
9018
|
/^[a-zA-Z0-9\s\-&.,]+$/,
|
|
8459
9019
|
"Organization name can only contain letters, numbers, spaces, hyphens, ampersands, periods, and commas"
|
|
8460
9020
|
).transform((val) => val.trim()).optional(),
|
|
8461
|
-
logoUrl:
|
|
9021
|
+
logoUrl: organizationLogoSchema.nullable().optional(),
|
|
9022
|
+
// REASON: single refined string (max 500) — http(s) URL, d:<hostname>, or '' to clear.
|
|
8462
9023
|
settings: OrganizationSettingsSchema.optional()
|
|
8463
9024
|
});
|
|
8464
9025
|
var OrganizationErrorCode = /* @__PURE__ */ ((OrganizationErrorCode2) => {
|
|
@@ -8486,6 +9047,37 @@ function validateOrganizationName(name) {
|
|
|
8486
9047
|
}
|
|
8487
9048
|
}
|
|
8488
9049
|
|
|
9050
|
+
// src/mcpi/authorization-host.ts
|
|
9051
|
+
var DEFAULT_AUTHORIZATION_HOST = "kya.vouched.id";
|
|
9052
|
+
function toBareHost(value) {
|
|
9053
|
+
const withoutScheme = value.trim().replace(/^https?:\/\//i, "");
|
|
9054
|
+
let end = withoutScheme.length;
|
|
9055
|
+
while (end > 0 && withoutScheme.charCodeAt(end - 1) === 47) {
|
|
9056
|
+
end--;
|
|
9057
|
+
}
|
|
9058
|
+
return withoutScheme.slice(0, end).toLowerCase();
|
|
9059
|
+
}
|
|
9060
|
+
function isValidAuthorizationHost(value) {
|
|
9061
|
+
const bare = toBareHost(value);
|
|
9062
|
+
if (!bare || bare.length > 255) return false;
|
|
9063
|
+
if (/[/\\?#@\s]/.test(bare)) return false;
|
|
9064
|
+
const parts = bare.split(":");
|
|
9065
|
+
if (parts.length > 2) return false;
|
|
9066
|
+
const [host, port] = parts;
|
|
9067
|
+
if (port !== void 0) {
|
|
9068
|
+
if (!/^\d{1,5}$/.test(port)) return false;
|
|
9069
|
+
const portNum = Number(port);
|
|
9070
|
+
if (portNum < 1 || portNum > 65535) return false;
|
|
9071
|
+
}
|
|
9072
|
+
if (host.length === 0 || host.length > 253) return false;
|
|
9073
|
+
const label = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
9074
|
+
return host.split(".").every((l) => label.test(l));
|
|
9075
|
+
}
|
|
9076
|
+
function resolveAuthorizationHost(authorizationHost, platformDefaultHost = DEFAULT_AUTHORIZATION_HOST) {
|
|
9077
|
+
const override = authorizationHost?.trim();
|
|
9078
|
+
return toBareHost(override && override.length > 0 ? override : platformDefaultHost);
|
|
9079
|
+
}
|
|
9080
|
+
|
|
8489
9081
|
// src/api/internal.ts
|
|
8490
9082
|
var ProjectIdSchema = external_exports.string().refine(
|
|
8491
9083
|
(val) => {
|
|
@@ -8537,6 +9129,15 @@ var UpdateProjectSchema = external_exports.object({
|
|
|
8537
9129
|
name: external_exports.string().min(1).max(255).optional(),
|
|
8538
9130
|
domain: external_exports.string().optional(),
|
|
8539
9131
|
// Changed: removed .url() validation to be more lenient
|
|
9132
|
+
// draft-kya-http-02 §7 Authorization Host (H1.1 #3244). The org-branded
|
|
9133
|
+
// bare host (e.g. `authenticate.acme.com`) that renders consent + serves
|
|
9134
|
+
// delegation pickup for this project. Empty string clears it → the web-app
|
|
9135
|
+
// platform default. This value becomes a challenge URI authority, so it's
|
|
9136
|
+
// validated strictly (no path / userinfo / whitespace / bad labels) rather
|
|
9137
|
+
// than left lenient like `domain` — see `isValidAuthorizationHost`.
|
|
9138
|
+
authorizationHost: external_exports.string().max(255).refine((v) => v === "" || isValidAuthorizationHost(v), {
|
|
9139
|
+
message: 'Authorization host must be a bare hostname (e.g. authenticate.acme.com), optionally with a :port \u2014 no scheme path, "@", or spaces'
|
|
9140
|
+
}).optional(),
|
|
8540
9141
|
settings: external_exports.object({
|
|
8541
9142
|
blockOnHighConfidence: external_exports.boolean().optional(),
|
|
8542
9143
|
confidenceThreshold: external_exports.number().min(0).max(1).optional(),
|
|
@@ -8811,7 +9412,7 @@ var PublicApiHeadersSchema = external_exports.object({
|
|
|
8811
9412
|
});
|
|
8812
9413
|
|
|
8813
9414
|
// src/api/fingerprint.ts
|
|
8814
|
-
var
|
|
9415
|
+
var ClientDetectionSchema2 = external_exports.object({
|
|
8815
9416
|
// Core detection
|
|
8816
9417
|
webdriver: external_exports.boolean().optional(),
|
|
8817
9418
|
plugins: external_exports.number().optional(),
|
|
@@ -8888,7 +9489,7 @@ var FingerprintAnalysisSchema = external_exports.object({
|
|
|
8888
9489
|
}).optional()
|
|
8889
9490
|
});
|
|
8890
9491
|
var FingerprintDetectRequestSchema = external_exports.object({
|
|
8891
|
-
clientDetection:
|
|
9492
|
+
clientDetection: ClientDetectionSchema2,
|
|
8892
9493
|
metadata: external_exports.record(external_exports.unknown()).optional()
|
|
8893
9494
|
});
|
|
8894
9495
|
var FingerprintResponseSchema = external_exports.object({
|
|
@@ -8943,7 +9544,7 @@ var EnhancedFingerprintResponseSchema = external_exports.object({
|
|
|
8943
9544
|
userAgent: external_exports.string()
|
|
8944
9545
|
}),
|
|
8945
9546
|
// JavaScript fingerprint
|
|
8946
|
-
javascript:
|
|
9547
|
+
javascript: ClientDetectionSchema2,
|
|
8947
9548
|
// Combined analysis
|
|
8948
9549
|
analysis: external_exports.object({
|
|
8949
9550
|
signals: external_exports.array(external_exports.string()),
|
|
@@ -8983,7 +9584,7 @@ var FingerprintRecordSchema = external_exports.object({
|
|
|
8983
9584
|
botType: external_exports.string().nullable(),
|
|
8984
9585
|
confidence: external_exports.number(),
|
|
8985
9586
|
// Client detection
|
|
8986
|
-
clientData:
|
|
9587
|
+
clientData: ClientDetectionSchema2.nullable(),
|
|
8987
9588
|
// Analysis
|
|
8988
9589
|
patterns: external_exports.array(external_exports.string()),
|
|
8989
9590
|
signals: external_exports.array(external_exports.string()),
|
|
@@ -9019,7 +9620,7 @@ function validateFingerprintRequest(data) {
|
|
|
9019
9620
|
return FingerprintDetectRequestSchema.parse(data);
|
|
9020
9621
|
}
|
|
9021
9622
|
function validateClientDetection(data) {
|
|
9022
|
-
return
|
|
9623
|
+
return ClientDetectionSchema2.parse(data);
|
|
9023
9624
|
}
|
|
9024
9625
|
function isValidFingerprintResponse(data) {
|
|
9025
9626
|
return FingerprintResponseSchema.safeParse(data).success;
|
|
@@ -9101,663 +9702,337 @@ var RealtimeEventTypeSchema = external_exports.enum([
|
|
|
9101
9702
|
"blocked",
|
|
9102
9703
|
"allowed",
|
|
9103
9704
|
"error",
|
|
9104
|
-
"pattern_update",
|
|
9105
|
-
"config_change",
|
|
9106
|
-
"stats_update"
|
|
9107
|
-
]);
|
|
9108
|
-
var RealtimeEventSchema = external_exports.object({
|
|
9109
|
-
type: RealtimeEventTypeSchema,
|
|
9110
|
-
timestamp: external_exports.number(),
|
|
9111
|
-
projectId: external_exports.string().optional(),
|
|
9112
|
-
data: external_exports.any()
|
|
9113
|
-
});
|
|
9114
|
-
var DetectionEventSchema = external_exports.object({
|
|
9115
|
-
type: external_exports.literal("detection"),
|
|
9116
|
-
timestamp: external_exports.number(),
|
|
9117
|
-
projectId: external_exports.string().optional(),
|
|
9118
|
-
data: external_exports.object({
|
|
9119
|
-
result: DetectionResultSchema,
|
|
9120
|
-
request: external_exports.object({
|
|
9121
|
-
userAgent: external_exports.string(),
|
|
9122
|
-
ipAddress: external_exports.string().optional(),
|
|
9123
|
-
url: external_exports.string().optional()
|
|
9124
|
-
})
|
|
9125
|
-
})
|
|
9126
|
-
});
|
|
9127
|
-
var BlockEventSchema = external_exports.object({
|
|
9128
|
-
type: external_exports.literal("blocked"),
|
|
9129
|
-
timestamp: external_exports.number(),
|
|
9130
|
-
projectId: external_exports.string().optional(),
|
|
9131
|
-
data: external_exports.object({
|
|
9132
|
-
reason: external_exports.string(),
|
|
9133
|
-
agentType: external_exports.string(),
|
|
9134
|
-
confidence: external_exports.number(),
|
|
9135
|
-
ipAddress: external_exports.string().optional(),
|
|
9136
|
-
url: external_exports.string().optional()
|
|
9137
|
-
})
|
|
9138
|
-
});
|
|
9139
|
-
var StatsUpdateEventSchema = external_exports.object({
|
|
9140
|
-
type: external_exports.literal("stats_update"),
|
|
9141
|
-
timestamp: external_exports.number(),
|
|
9142
|
-
projectId: external_exports.string().optional(),
|
|
9143
|
-
data: external_exports.object({
|
|
9144
|
-
period: external_exports.enum(["minute", "hour", "day"]),
|
|
9145
|
-
totalRequests: external_exports.number(),
|
|
9146
|
-
agentsDetected: external_exports.number(),
|
|
9147
|
-
averageConfidence: external_exports.number()
|
|
9148
|
-
})
|
|
9149
|
-
});
|
|
9150
|
-
|
|
9151
|
-
// src/events/deploy-progress.ts
|
|
9152
|
-
var DEPLOY_STEPS = [
|
|
9153
|
-
{ id: "github_verify", label: "Verifying GitHub connection", order: 1 },
|
|
9154
|
-
{ id: "repo_check", label: "Checking repository availability", order: 2 },
|
|
9155
|
-
{ id: "project_create", label: "Creating AgentShield project", order: 3 },
|
|
9156
|
-
{ id: "api_key", label: "Generating API key", order: 4 },
|
|
9157
|
-
{ id: "scaffold", label: "Scaffolding project files", order: 5 },
|
|
9158
|
-
{ id: "kta_register", label: "Registering agent for reputation", order: 6 },
|
|
9159
|
-
{ id: "repo_create", label: "Creating GitHub repository", order: 7 },
|
|
9160
|
-
{ id: "commit_files", label: "Committing files", order: 8 },
|
|
9161
|
-
{ id: "add_secrets", label: "Adding repository secrets", order: 9 },
|
|
9162
|
-
{ id: "cloudflare_deploy", label: "Deploying to Cloudflare", order: 10 },
|
|
9163
|
-
{ id: "complete", label: "Deployment complete!", order: 11 }
|
|
9164
|
-
];
|
|
9165
|
-
var DeployStepIdSchema = external_exports.enum([
|
|
9166
|
-
"github_verify",
|
|
9167
|
-
"repo_check",
|
|
9168
|
-
"project_create",
|
|
9169
|
-
"api_key",
|
|
9170
|
-
"scaffold",
|
|
9171
|
-
"kta_register",
|
|
9172
|
-
"repo_create",
|
|
9173
|
-
"commit_files",
|
|
9174
|
-
"add_secrets",
|
|
9175
|
-
"cloudflare_deploy",
|
|
9176
|
-
"complete"
|
|
9177
|
-
]);
|
|
9178
|
-
var DeployStepStatusSchema = external_exports.enum([
|
|
9179
|
-
"pending",
|
|
9180
|
-
"running",
|
|
9181
|
-
"complete",
|
|
9182
|
-
"error",
|
|
9183
|
-
"skipped"
|
|
9184
|
-
]);
|
|
9185
|
-
var DeployStepStateSchema = external_exports.object({
|
|
9186
|
-
id: DeployStepIdSchema,
|
|
9187
|
-
status: DeployStepStatusSchema,
|
|
9188
|
-
message: external_exports.string().optional(),
|
|
9189
|
-
startedAt: external_exports.number().optional(),
|
|
9190
|
-
completedAt: external_exports.number().optional(),
|
|
9191
|
-
error: external_exports.object({
|
|
9192
|
-
code: external_exports.string(),
|
|
9193
|
-
message: external_exports.string()
|
|
9194
|
-
}).optional()
|
|
9195
|
-
});
|
|
9196
|
-
var DeployProgressEventSchema = external_exports.object({
|
|
9197
|
-
type: external_exports.literal("deploy_progress"),
|
|
9198
|
-
deploymentId: external_exports.string(),
|
|
9199
|
-
timestamp: external_exports.number(),
|
|
9200
|
-
currentStep: DeployStepIdSchema,
|
|
9201
|
-
steps: external_exports.array(DeployStepStateSchema),
|
|
9202
|
-
result: external_exports.object({
|
|
9203
|
-
repoUrl: external_exports.string(),
|
|
9204
|
-
repoFullName: external_exports.string(),
|
|
9205
|
-
deployUrl: external_exports.string(),
|
|
9206
|
-
projectId: external_exports.string(),
|
|
9207
|
-
/** Human-readable project ID for URL construction */
|
|
9208
|
-
friendlyId: external_exports.string().nullable().optional(),
|
|
9209
|
-
/** Full API key - only shown once at completion! */
|
|
9210
|
-
apiKey: external_exports.string(),
|
|
9211
|
-
/** Preview (sk_...xxx) for display after initial view */
|
|
9212
|
-
apiKeyPreview: external_exports.string(),
|
|
9213
|
-
cloudflareUrl: external_exports.string().optional(),
|
|
9214
|
-
cloudflareDeployed: external_exports.boolean().optional(),
|
|
9215
|
-
/** Agent DID (decentralized identifier) - did:web for reputation enabled, did:key for disabled */
|
|
9216
|
-
agentDid: external_exports.string().optional(),
|
|
9217
|
-
/** Whether agent was registered with Know That AI for reputation tracking */
|
|
9218
|
-
ktaRegistered: external_exports.boolean().optional(),
|
|
9219
|
-
/** Claim URL for KTA registration (only when using cli-register with did:web) */
|
|
9220
|
-
ktaClaimUrl: external_exports.string().optional()
|
|
9221
|
-
}).optional(),
|
|
9222
|
-
error: external_exports.object({
|
|
9223
|
-
code: external_exports.string(),
|
|
9224
|
-
message: external_exports.string(),
|
|
9225
|
-
step: DeployStepIdSchema.optional()
|
|
9226
|
-
}).optional()
|
|
9227
|
-
});
|
|
9228
|
-
var DeploymentMetadataSchema = external_exports.object({
|
|
9229
|
-
id: external_exports.string(),
|
|
9230
|
-
userId: external_exports.string(),
|
|
9231
|
-
organizationId: external_exports.string(),
|
|
9232
|
-
repoName: external_exports.string(),
|
|
9233
|
-
template: external_exports.string(),
|
|
9234
|
-
platform: external_exports.string(),
|
|
9235
|
-
/** Hosting mode: 'managed' (AgentShield hosted) or 'byok' (Bring Your Own Cloudflare) */
|
|
9236
|
-
hostingMode: external_exports.enum(["managed", "byok"]).optional().default("byok"),
|
|
9237
|
-
status: external_exports.enum(["pending", "running", "complete", "error"]),
|
|
9238
|
-
/** Enable reputation tracking via Know That AI (defaults to true) */
|
|
9239
|
-
enableReputation: external_exports.boolean().optional(),
|
|
9240
|
-
/** Existing project ID to deploy to (if provided, skips project creation) - Unified Project Schema v1.3 */
|
|
9241
|
-
existingProjectId: external_exports.string().uuid().optional(),
|
|
9242
|
-
createdAt: external_exports.number(),
|
|
9243
|
-
updatedAt: external_exports.number(),
|
|
9244
|
-
/** Result data (populated on completion) */
|
|
9245
|
-
result: external_exports.object({
|
|
9246
|
-
/** GitHub repo URL (BYOK deploy only) */
|
|
9247
|
-
repoUrl: external_exports.string().optional(),
|
|
9248
|
-
/** GitHub repo full name e.g. "user/repo" (BYOK deploy only) */
|
|
9249
|
-
repoFullName: external_exports.string().optional(),
|
|
9250
|
-
/** GitHub Actions deploy URL (BYOK deploy only) */
|
|
9251
|
-
deployUrl: external_exports.string().optional(),
|
|
9252
|
-
projectId: external_exports.string(),
|
|
9253
|
-
/** Human-readable project ID for URL construction */
|
|
9254
|
-
friendlyId: external_exports.string().nullable().optional(),
|
|
9255
|
-
/** API key preview e.g. "sk_...xxx" (BYOK deploy only) */
|
|
9256
|
-
apiKeyPreview: external_exports.string().optional(),
|
|
9257
|
-
cloudflareUrl: external_exports.string().optional(),
|
|
9258
|
-
cloudflareDeployed: external_exports.boolean().optional(),
|
|
9259
|
-
agentDid: external_exports.string().optional(),
|
|
9260
|
-
ktaRegistered: external_exports.boolean().optional(),
|
|
9261
|
-
ktaClaimUrl: external_exports.string().optional()
|
|
9262
|
-
}).optional()
|
|
9263
|
-
});
|
|
9264
|
-
function getStepInfo(stepId) {
|
|
9265
|
-
return DEPLOY_STEPS.find((s) => s.id === stepId);
|
|
9266
|
-
}
|
|
9267
|
-
function getStepOrder(stepId) {
|
|
9268
|
-
const step = DEPLOY_STEPS.find((s) => s.id === stepId);
|
|
9269
|
-
return step?.order ?? 0;
|
|
9270
|
-
}
|
|
9271
|
-
function calculateDeployProgress(currentStep, status) {
|
|
9272
|
-
const totalSteps = DEPLOY_STEPS.length - 1;
|
|
9273
|
-
const currentOrder = getStepOrder(currentStep);
|
|
9274
|
-
if (currentStep === "complete") return 100;
|
|
9275
|
-
if (status === "running") {
|
|
9276
|
-
return Math.round((currentOrder - 0.5) / totalSteps * 100);
|
|
9277
|
-
}
|
|
9278
|
-
if (status === "complete") {
|
|
9279
|
-
return Math.round(currentOrder / totalSteps * 100);
|
|
9280
|
-
}
|
|
9281
|
-
return Math.round((currentOrder - 1) / totalSteps * 100);
|
|
9282
|
-
}
|
|
9283
|
-
function buildInitialStepsState() {
|
|
9284
|
-
return DEPLOY_STEPS.map((step) => ({
|
|
9285
|
-
id: step.id,
|
|
9286
|
-
status: "pending"
|
|
9287
|
-
}));
|
|
9288
|
-
}
|
|
9289
|
-
function updateStepsState(currentSteps, stepId, status, options) {
|
|
9290
|
-
const now = Date.now();
|
|
9291
|
-
return currentSteps.map((step) => {
|
|
9292
|
-
if (step.id === stepId) {
|
|
9293
|
-
return {
|
|
9294
|
-
...step,
|
|
9295
|
-
status,
|
|
9296
|
-
message: options?.message,
|
|
9297
|
-
error: options?.error,
|
|
9298
|
-
startedAt: status === "running" ? now : step.startedAt,
|
|
9299
|
-
completedAt: status === "complete" || status === "error" ? now : step.completedAt
|
|
9300
|
-
};
|
|
9301
|
-
}
|
|
9302
|
-
return step;
|
|
9303
|
-
});
|
|
9304
|
-
}
|
|
9305
|
-
|
|
9306
|
-
// src/types/wasm.ts
|
|
9307
|
-
var WasmAgentNameSchema = external_exports.union([
|
|
9308
|
-
AgentTypeSchema,
|
|
9309
|
-
external_exports.string().min(1).max(100)
|
|
9310
|
-
// Allow custom agent names but with constraints
|
|
9311
|
-
]);
|
|
9312
|
-
var WasmDetectionResultSchema = external_exports.object({
|
|
9313
|
-
is_agent: external_exports.boolean(),
|
|
9314
|
-
confidence: external_exports.number().min(0).max(1),
|
|
9315
|
-
agent: WasmAgentNameSchema.optional(),
|
|
9316
|
-
verification_method: external_exports.string(),
|
|
9317
|
-
risk_level: external_exports.string(),
|
|
9318
|
-
timestamp: external_exports.string()
|
|
9319
|
-
});
|
|
9320
|
-
var WasmRequestMetadataSchema = external_exports.object({
|
|
9321
|
-
user_agent: external_exports.string().optional(),
|
|
9322
|
-
ip_address: external_exports.string().optional(),
|
|
9323
|
-
headers: external_exports.string(),
|
|
9324
|
-
// JSON string of headers
|
|
9325
|
-
timestamp: external_exports.string(),
|
|
9326
|
-
url: external_exports.string().optional(),
|
|
9327
|
-
method: external_exports.string().optional(),
|
|
9328
|
-
client_fingerprint: external_exports.string().optional()
|
|
9329
|
-
// ✅ Added client fingerprint support
|
|
9330
|
-
});
|
|
9331
|
-
var WasmVerificationMethod = /* @__PURE__ */ ((WasmVerificationMethod2) => {
|
|
9332
|
-
WasmVerificationMethod2["UserAgent"] = "UserAgent";
|
|
9333
|
-
WasmVerificationMethod2["IPRange"] = "IPRange";
|
|
9334
|
-
WasmVerificationMethod2["Signature"] = "Signature";
|
|
9335
|
-
WasmVerificationMethod2["Headers"] = "Headers";
|
|
9336
|
-
WasmVerificationMethod2["Behavioral"] = "Behavioral";
|
|
9337
|
-
WasmVerificationMethod2["Combined"] = "Combined";
|
|
9338
|
-
return WasmVerificationMethod2;
|
|
9339
|
-
})(WasmVerificationMethod || {});
|
|
9340
|
-
var WasmRiskLevel = /* @__PURE__ */ ((WasmRiskLevel2) => {
|
|
9341
|
-
WasmRiskLevel2["Low"] = "Low";
|
|
9342
|
-
WasmRiskLevel2["Medium"] = "Medium";
|
|
9343
|
-
WasmRiskLevel2["High"] = "High";
|
|
9344
|
-
WasmRiskLevel2["Critical"] = "Critical";
|
|
9345
|
-
return WasmRiskLevel2;
|
|
9346
|
-
})(WasmRiskLevel || {});
|
|
9347
|
-
function wasmToDetectionResult(wasmResult) {
|
|
9348
|
-
return {
|
|
9349
|
-
isAgent: wasmResult.is_agent,
|
|
9350
|
-
confidence: wasmResult.confidence,
|
|
9351
|
-
agentType: wasmResult.agent,
|
|
9352
|
-
verificationMethod: wasmResult.verification_method,
|
|
9353
|
-
riskLevel: wasmResult.risk_level,
|
|
9354
|
-
timestamp: new Date(wasmResult.timestamp)
|
|
9355
|
-
};
|
|
9356
|
-
}
|
|
9357
|
-
function toWasmRequestMetadata(request) {
|
|
9358
|
-
return {
|
|
9359
|
-
user_agent: request.userAgent,
|
|
9360
|
-
ip_address: request.ipAddress,
|
|
9361
|
-
headers: JSON.stringify(request.headers || {}),
|
|
9362
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
9363
|
-
url: request.url,
|
|
9364
|
-
method: request.method,
|
|
9365
|
-
client_fingerprint: request.clientFingerprint
|
|
9366
|
-
// ✅ Map camelCase to snake_case
|
|
9367
|
-
};
|
|
9368
|
-
}
|
|
9369
|
-
function isKnownAgentType(value) {
|
|
9370
|
-
return AgentTypeSchema.safeParse(value).success;
|
|
9371
|
-
}
|
|
9372
|
-
function isValidWasmDetectionResult(value) {
|
|
9373
|
-
return WasmDetectionResultSchema.safeParse(value).success;
|
|
9374
|
-
}
|
|
9375
|
-
function isValidWasmRequestMetadata(value) {
|
|
9376
|
-
return WasmRequestMetadataSchema.safeParse(value).success;
|
|
9377
|
-
}
|
|
9378
|
-
function parseAgentName(value) {
|
|
9379
|
-
const result = AgentTypeSchema.safeParse(value);
|
|
9380
|
-
return result.success ? result.data : "unknown";
|
|
9381
|
-
}
|
|
9382
|
-
function normalizeAgentName(value) {
|
|
9383
|
-
const normalized = value.toLowerCase().trim();
|
|
9384
|
-
if (isKnownAgentType(normalized)) {
|
|
9385
|
-
return normalized;
|
|
9386
|
-
}
|
|
9387
|
-
const partialMatches = {
|
|
9388
|
-
chatgpt: "chatgpt",
|
|
9389
|
-
"gpt-": "openai",
|
|
9390
|
-
"claude-": "claude",
|
|
9391
|
-
"gemini-": "google",
|
|
9392
|
-
"llama-": "meta",
|
|
9393
|
-
"mistral-": "mistral",
|
|
9394
|
-
"mixtral-": "mistral"
|
|
9395
|
-
};
|
|
9396
|
-
for (const [pattern, agentType] of Object.entries(partialMatches)) {
|
|
9397
|
-
if (normalized.includes(pattern)) {
|
|
9398
|
-
return agentType;
|
|
9399
|
-
}
|
|
9400
|
-
}
|
|
9401
|
-
return "unknown";
|
|
9402
|
-
}
|
|
9403
|
-
function getAgentDisplayName(agentType) {
|
|
9404
|
-
const displayNames = {
|
|
9405
|
-
openai: "OpenAI",
|
|
9406
|
-
chatgpt: "ChatGPT",
|
|
9407
|
-
claude: "Claude",
|
|
9408
|
-
anthropic: "Anthropic",
|
|
9409
|
-
perplexity: "Perplexity",
|
|
9410
|
-
phind: "Phind",
|
|
9411
|
-
you: "You.com",
|
|
9412
|
-
neeva: "Neeva",
|
|
9413
|
-
google: "Google",
|
|
9414
|
-
microsoft: "Microsoft",
|
|
9415
|
-
meta: "Meta",
|
|
9416
|
-
alibaba: "Alibaba",
|
|
9417
|
-
mistral: "Mistral AI",
|
|
9418
|
-
cohere: "Cohere",
|
|
9419
|
-
huggingface: "HuggingFace",
|
|
9420
|
-
inflection: "Inflection AI",
|
|
9421
|
-
stability: "Stability AI",
|
|
9422
|
-
replicate: "Replicate",
|
|
9423
|
-
together: "Together AI",
|
|
9424
|
-
"01ai": "01.AI",
|
|
9425
|
-
writer: "Writer",
|
|
9426
|
-
jasper: "Jasper",
|
|
9427
|
-
unknown: "Unknown"
|
|
9428
|
-
};
|
|
9429
|
-
return displayNames[agentType] || agentType;
|
|
9430
|
-
}
|
|
9431
|
-
|
|
9432
|
-
// src/types/pixel.ts
|
|
9433
|
-
var PixelEventTypeSchema = external_exports.enum([
|
|
9434
|
-
"pageview",
|
|
9435
|
-
"detection",
|
|
9436
|
-
"interaction",
|
|
9437
|
-
"error",
|
|
9438
|
-
"session_start",
|
|
9439
|
-
"session_end",
|
|
9440
|
-
"custom"
|
|
9441
|
-
]);
|
|
9442
|
-
var BrowserInfoSchema = external_exports.object({
|
|
9443
|
-
name: external_exports.string().optional(),
|
|
9444
|
-
version: external_exports.string().optional(),
|
|
9445
|
-
platform: external_exports.string().optional(),
|
|
9446
|
-
mobile: external_exports.boolean().default(false),
|
|
9447
|
-
language: external_exports.string().optional(),
|
|
9448
|
-
cookiesEnabled: external_exports.boolean().optional(),
|
|
9449
|
-
doNotTrack: external_exports.boolean().optional(),
|
|
9450
|
-
plugins: external_exports.array(external_exports.string()).optional()
|
|
9451
|
-
});
|
|
9452
|
-
var PageContextSchema = external_exports.object({
|
|
9453
|
-
url: external_exports.string().url(),
|
|
9454
|
-
title: external_exports.string().optional(),
|
|
9455
|
-
referrer: external_exports.string().optional(),
|
|
9456
|
-
path: external_exports.string(),
|
|
9457
|
-
hostname: external_exports.string(),
|
|
9458
|
-
protocol: external_exports.string(),
|
|
9459
|
-
search: external_exports.string().optional(),
|
|
9460
|
-
hash: external_exports.string().optional()
|
|
9461
|
-
});
|
|
9462
|
-
var BehavioralSignalsSchema = external_exports.object({
|
|
9463
|
-
mouseMovements: external_exports.number().int().min(0).default(0),
|
|
9464
|
-
clicks: external_exports.number().int().min(0).default(0),
|
|
9465
|
-
scrollEvents: external_exports.number().int().min(0).default(0),
|
|
9466
|
-
keyPresses: external_exports.number().int().min(0).default(0),
|
|
9467
|
-
touchEvents: external_exports.number().int().min(0).default(0),
|
|
9468
|
-
timeOnPage: external_exports.number().min(0).default(0),
|
|
9469
|
-
interactionRate: external_exports.number().min(0).max(1).default(0),
|
|
9470
|
-
scrollDepth: external_exports.number().min(0).max(100).default(0),
|
|
9471
|
-
isAutomated: external_exports.boolean().optional()
|
|
9472
|
-
});
|
|
9473
|
-
var PixelEventSchema = external_exports.object({
|
|
9474
|
-
// Event Identification
|
|
9475
|
-
id: external_exports.string().uuid(),
|
|
9476
|
-
pixelId: external_exports.string(),
|
|
9477
|
-
sessionId: external_exports.string(),
|
|
9478
|
-
eventType: PixelEventTypeSchema,
|
|
9479
|
-
// Timing
|
|
9480
|
-
timestamp: external_exports.union([external_exports.string(), external_exports.date()]),
|
|
9481
|
-
clientTimestamp: external_exports.union([external_exports.string(), external_exports.date()]).optional(),
|
|
9482
|
-
// Context
|
|
9483
|
-
page: PageContextSchema,
|
|
9484
|
-
browser: BrowserInfoSchema.optional(),
|
|
9485
|
-
// Request Information
|
|
9486
|
-
userAgent: external_exports.string(),
|
|
9487
|
-
ipAddress: external_exports.string().optional(),
|
|
9488
|
-
headers: external_exports.record(external_exports.string()).optional(),
|
|
9489
|
-
// Detection Results
|
|
9490
|
-
detection: DetectionResultSchema.optional(),
|
|
9491
|
-
// Behavioral Data
|
|
9492
|
-
behavioral: BehavioralSignalsSchema.optional(),
|
|
9493
|
-
// Custom Data
|
|
9494
|
-
metadata: external_exports.record(external_exports.unknown()).optional(),
|
|
9495
|
-
customEventName: external_exports.string().optional()
|
|
9496
|
-
});
|
|
9497
|
-
var BatchPixelEventRequestSchema = external_exports.object({
|
|
9498
|
-
pixelId: external_exports.string(),
|
|
9499
|
-
secretKey: external_exports.string().optional(),
|
|
9500
|
-
events: external_exports.array(PixelEventSchema).min(1).max(100),
|
|
9501
|
-
compressed: external_exports.boolean().default(false)
|
|
9502
|
-
});
|
|
9503
|
-
var PixelInstallConfigSchema = external_exports.object({
|
|
9504
|
-
pixelId: external_exports.string(),
|
|
9505
|
-
endpoint: external_exports.string().url().default("https://api.agentshield.ai/v1/pixel"),
|
|
9506
|
-
// Tracking Options
|
|
9507
|
-
autoTrack: external_exports.boolean().default(true),
|
|
9508
|
-
trackPageviews: external_exports.boolean().default(true),
|
|
9509
|
-
trackDetections: external_exports.boolean().default(true),
|
|
9510
|
-
trackBehavior: external_exports.boolean().default(false),
|
|
9511
|
-
// Performance Options
|
|
9512
|
-
batchEvents: external_exports.boolean().default(true),
|
|
9513
|
-
batchSize: external_exports.number().min(1).max(100).default(10),
|
|
9514
|
-
flushInterval: external_exports.number().min(1e3).max(6e4).default(5e3),
|
|
9515
|
-
// Privacy Options
|
|
9516
|
-
respectDoNotTrack: external_exports.boolean().default(true),
|
|
9517
|
-
anonymizeIp: external_exports.boolean().default(false),
|
|
9518
|
-
// Session Options
|
|
9519
|
-
sessionTimeout: external_exports.number().min(6e4).default(18e5),
|
|
9520
|
-
// 30 minutes
|
|
9521
|
-
sessionCookieName: external_exports.string().default("_as_session"),
|
|
9522
|
-
// Debug Options
|
|
9523
|
-
debug: external_exports.boolean().default(false),
|
|
9524
|
-
logLevel: external_exports.enum(["error", "warn", "info", "debug"]).default("error")
|
|
9525
|
-
});
|
|
9526
|
-
var PixelInitSchema = external_exports.object({
|
|
9527
|
-
config: PixelInstallConfigSchema,
|
|
9528
|
-
onReady: external_exports.function().optional(),
|
|
9529
|
-
onError: external_exports.function().optional(),
|
|
9530
|
-
onDetection: external_exports.function().optional()
|
|
9531
|
-
});
|
|
9532
|
-
var ClientDetectionSchema2 = external_exports.object({
|
|
9533
|
-
// Critical Perplexity detection signals
|
|
9534
|
-
headless: external_exports.boolean().optional(),
|
|
9535
|
-
canvas: external_exports.string().optional(),
|
|
9536
|
-
webrtc: external_exports.string().optional(),
|
|
9537
|
-
plugins: external_exports.number().optional(),
|
|
9538
|
-
automation: external_exports.string().nullable().optional(),
|
|
9539
|
-
// Browser characteristics
|
|
9540
|
-
chrome: external_exports.boolean().optional(),
|
|
9541
|
-
languages: external_exports.array(external_exports.string()).optional(),
|
|
9542
|
-
hardwareConcurrency: external_exports.number().nullable().optional(),
|
|
9543
|
-
deviceMemory: external_exports.number().nullable().optional(),
|
|
9544
|
-
maxTouchPoints: external_exports.number().optional(),
|
|
9545
|
-
platform: external_exports.string().optional(),
|
|
9546
|
-
vendor: external_exports.string().optional(),
|
|
9547
|
-
screenResolution: external_exports.string().optional(),
|
|
9548
|
-
colorDepth: external_exports.number().optional(),
|
|
9549
|
-
pixelRatio: external_exports.number().optional(),
|
|
9550
|
-
timezone: external_exports.string().optional(),
|
|
9551
|
-
timezoneOffset: external_exports.number().optional(),
|
|
9552
|
-
cookieEnabled: external_exports.boolean().optional(),
|
|
9553
|
-
localStorage: external_exports.boolean().optional(),
|
|
9554
|
-
sessionStorage: external_exports.boolean().optional(),
|
|
9555
|
-
doNotTrack: external_exports.string().nullable().optional(),
|
|
9556
|
-
hasTouch: external_exports.boolean().optional(),
|
|
9557
|
-
// Interaction metrics
|
|
9558
|
-
mouseMovements: external_exports.number().optional(),
|
|
9559
|
-
keyboardEvents: external_exports.number().optional(),
|
|
9560
|
-
scrollEvents: external_exports.number().optional(),
|
|
9561
|
-
clickEvents: external_exports.number().optional(),
|
|
9562
|
-
touchEvents: external_exports.number().optional(),
|
|
9563
|
-
hasInteraction: external_exports.boolean().optional(),
|
|
9564
|
-
// Connection info
|
|
9565
|
-
connection: external_exports.object({
|
|
9566
|
-
effectiveType: external_exports.string().optional(),
|
|
9567
|
-
rtt: external_exports.number().optional(),
|
|
9568
|
-
downlink: external_exports.number().optional(),
|
|
9569
|
-
saveData: external_exports.boolean().optional()
|
|
9570
|
-
}).nullable().optional(),
|
|
9571
|
-
// Performance metrics
|
|
9572
|
-
performance: external_exports.object({
|
|
9573
|
-
navigation: external_exports.number().nullable().optional(),
|
|
9574
|
-
memory: external_exports.object({
|
|
9575
|
-
usedJSHeapSize: external_exports.number().optional(),
|
|
9576
|
-
totalJSHeapSize: external_exports.number().optional(),
|
|
9577
|
-
jsHeapSizeLimit: external_exports.number().optional()
|
|
9578
|
-
}).optional()
|
|
9579
|
-
}).nullable().optional(),
|
|
9580
|
-
// Collection metadata
|
|
9581
|
-
collectionTime: external_exports.number().optional(),
|
|
9582
|
-
timestamp: external_exports.string().optional(),
|
|
9583
|
-
error: external_exports.string().optional()
|
|
9584
|
-
});
|
|
9585
|
-
var PixelTrackingRequestSchema = external_exports.object({
|
|
9586
|
-
// Pixel identification
|
|
9587
|
-
pixelId: external_exports.string(),
|
|
9588
|
-
// UUID of the pixel
|
|
9589
|
-
sessionId: external_exports.string(),
|
|
9590
|
-
// Session identifier
|
|
9591
|
-
// User identification
|
|
9592
|
-
userId: external_exports.string().nullable().optional(),
|
|
9593
|
-
// Identified user ID
|
|
9594
|
-
userTraits: external_exports.record(external_exports.unknown()).optional().refine((traits) => !traits || JSON.stringify(traits).length < 1e4, {
|
|
9595
|
-
message: "User traits too large (max 10KB)"
|
|
9596
|
-
}).refine((traits) => !traits || Object.keys(traits).length < 50, {
|
|
9597
|
-
message: "Too many user trait properties (max 50)"
|
|
9598
|
-
}).refine(
|
|
9599
|
-
(traits) => {
|
|
9600
|
-
if (!traits) return true;
|
|
9601
|
-
const validateDepth = (obj, depth = 0) => {
|
|
9602
|
-
if (depth > 3) return false;
|
|
9603
|
-
if (typeof obj !== "object" || obj === null) return true;
|
|
9604
|
-
return Object.values(obj).every((val) => validateDepth(val, depth + 1));
|
|
9605
|
-
};
|
|
9606
|
-
return validateDepth(traits);
|
|
9607
|
-
},
|
|
9608
|
-
{
|
|
9609
|
-
message: "User traits contain overly nested objects (max depth 3)"
|
|
9610
|
-
}
|
|
9611
|
-
),
|
|
9612
|
-
// Page context
|
|
9613
|
-
url: external_exports.string().url(),
|
|
9614
|
-
// Current page URL
|
|
9615
|
-
referrer: external_exports.string().optional(),
|
|
9616
|
-
// Referrer URL
|
|
9617
|
-
title: external_exports.string().optional(),
|
|
9618
|
-
// Page title
|
|
9619
|
-
// Detection data
|
|
9620
|
-
userAgent: external_exports.string(),
|
|
9621
|
-
// Browser user agent
|
|
9622
|
-
headers: external_exports.record(external_exports.string()).optional(),
|
|
9623
|
-
// Any additional headers
|
|
9624
|
-
// Client info
|
|
9625
|
-
screenResolution: external_exports.string().optional(),
|
|
9626
|
-
// "1920x1080"
|
|
9627
|
-
viewport: external_exports.string().optional(),
|
|
9628
|
-
// "1200x800"
|
|
9629
|
-
timezone: external_exports.string().optional(),
|
|
9630
|
-
// "America/New_York"
|
|
9631
|
-
language: external_exports.string().optional(),
|
|
9632
|
-
// "en-US"
|
|
9633
|
-
// Behavioral (if available)
|
|
9634
|
-
timeOnPage: external_exports.number().optional(),
|
|
9635
|
-
// Milliseconds
|
|
9636
|
-
mouseMovements: external_exports.number().optional(),
|
|
9637
|
-
// Count of mouse events
|
|
9638
|
-
clickCount: external_exports.number().optional(),
|
|
9639
|
-
// Number of clicks
|
|
9640
|
-
scrollDepth: external_exports.number().optional(),
|
|
9641
|
-
// Percentage 0-100
|
|
9642
|
-
// Client-side detection data (NEW)
|
|
9643
|
-
clientDetection: ClientDetectionSchema2.optional(),
|
|
9644
|
-
// Request tracking (client-provided, will be validated server-side)
|
|
9645
|
-
requestId: external_exports.string().optional(),
|
|
9646
|
-
// Unique request ID for deduplication
|
|
9647
|
-
// Event type for special events
|
|
9648
|
-
eventType: external_exports.string().optional(),
|
|
9649
|
-
// 'pageview', 'identify', 'logout', etc.
|
|
9650
|
-
// Metadata
|
|
9651
|
-
timestamp: external_exports.string(),
|
|
9652
|
-
// ISO 8601
|
|
9653
|
-
version: external_exports.string().optional()
|
|
9654
|
-
// Pixel version
|
|
9705
|
+
"pattern_update",
|
|
9706
|
+
"config_change",
|
|
9707
|
+
"stats_update"
|
|
9708
|
+
]);
|
|
9709
|
+
var RealtimeEventSchema = external_exports.object({
|
|
9710
|
+
type: RealtimeEventTypeSchema,
|
|
9711
|
+
timestamp: external_exports.number(),
|
|
9712
|
+
projectId: external_exports.string().optional(),
|
|
9713
|
+
data: external_exports.any()
|
|
9655
9714
|
});
|
|
9656
|
-
var
|
|
9657
|
-
|
|
9658
|
-
|
|
9659
|
-
|
|
9660
|
-
|
|
9661
|
-
|
|
9662
|
-
|
|
9715
|
+
var DetectionEventSchema = external_exports.object({
|
|
9716
|
+
type: external_exports.literal("detection"),
|
|
9717
|
+
timestamp: external_exports.number(),
|
|
9718
|
+
projectId: external_exports.string().optional(),
|
|
9719
|
+
data: external_exports.object({
|
|
9720
|
+
result: DetectionResultSchema,
|
|
9721
|
+
request: external_exports.object({
|
|
9722
|
+
userAgent: external_exports.string(),
|
|
9723
|
+
ipAddress: external_exports.string().optional(),
|
|
9724
|
+
url: external_exports.string().optional()
|
|
9725
|
+
})
|
|
9726
|
+
})
|
|
9663
9727
|
});
|
|
9664
|
-
var
|
|
9665
|
-
|
|
9666
|
-
|
|
9667
|
-
|
|
9668
|
-
|
|
9728
|
+
var BlockEventSchema = external_exports.object({
|
|
9729
|
+
type: external_exports.literal("blocked"),
|
|
9730
|
+
timestamp: external_exports.number(),
|
|
9731
|
+
projectId: external_exports.string().optional(),
|
|
9732
|
+
data: external_exports.object({
|
|
9733
|
+
reason: external_exports.string(),
|
|
9734
|
+
agentType: external_exports.string(),
|
|
9735
|
+
confidence: external_exports.number(),
|
|
9736
|
+
ipAddress: external_exports.string().optional(),
|
|
9737
|
+
url: external_exports.string().optional()
|
|
9738
|
+
})
|
|
9739
|
+
});
|
|
9740
|
+
var StatsUpdateEventSchema = external_exports.object({
|
|
9741
|
+
type: external_exports.literal("stats_update"),
|
|
9742
|
+
timestamp: external_exports.number(),
|
|
9743
|
+
projectId: external_exports.string().optional(),
|
|
9744
|
+
data: external_exports.object({
|
|
9745
|
+
period: external_exports.enum(["minute", "hour", "day"]),
|
|
9746
|
+
totalRequests: external_exports.number(),
|
|
9747
|
+
agentsDetected: external_exports.number(),
|
|
9748
|
+
averageConfidence: external_exports.number()
|
|
9749
|
+
})
|
|
9750
|
+
});
|
|
9751
|
+
|
|
9752
|
+
// src/events/deploy-progress.ts
|
|
9753
|
+
var DEPLOY_STEPS = [
|
|
9754
|
+
{ id: "github_verify", label: "Verifying GitHub connection", order: 1 },
|
|
9755
|
+
{ id: "repo_check", label: "Checking repository availability", order: 2 },
|
|
9756
|
+
{ id: "project_create", label: "Creating AgentShield project", order: 3 },
|
|
9757
|
+
{ id: "api_key", label: "Generating API key", order: 4 },
|
|
9758
|
+
{ id: "scaffold", label: "Scaffolding project files", order: 5 },
|
|
9759
|
+
{ id: "kta_register", label: "Registering agent for reputation", order: 6 },
|
|
9760
|
+
{ id: "repo_create", label: "Creating GitHub repository", order: 7 },
|
|
9761
|
+
{ id: "commit_files", label: "Committing files", order: 8 },
|
|
9762
|
+
{ id: "add_secrets", label: "Adding repository secrets", order: 9 },
|
|
9763
|
+
{ id: "cloudflare_deploy", label: "Deploying to Cloudflare", order: 10 },
|
|
9764
|
+
{ id: "complete", label: "Deployment complete!", order: 11 }
|
|
9765
|
+
];
|
|
9766
|
+
var DeployStepIdSchema = external_exports.enum([
|
|
9767
|
+
"github_verify",
|
|
9768
|
+
"repo_check",
|
|
9769
|
+
"project_create",
|
|
9770
|
+
"api_key",
|
|
9771
|
+
"scaffold",
|
|
9772
|
+
"kta_register",
|
|
9773
|
+
"repo_create",
|
|
9774
|
+
"commit_files",
|
|
9775
|
+
"add_secrets",
|
|
9776
|
+
"cloudflare_deploy",
|
|
9777
|
+
"complete"
|
|
9778
|
+
]);
|
|
9779
|
+
var DeployStepStatusSchema = external_exports.enum([
|
|
9780
|
+
"pending",
|
|
9781
|
+
"running",
|
|
9782
|
+
"complete",
|
|
9783
|
+
"error",
|
|
9784
|
+
"skipped"
|
|
9785
|
+
]);
|
|
9786
|
+
var DeployStepStateSchema = external_exports.object({
|
|
9787
|
+
id: DeployStepIdSchema,
|
|
9788
|
+
status: DeployStepStatusSchema,
|
|
9789
|
+
message: external_exports.string().optional(),
|
|
9790
|
+
startedAt: external_exports.number().optional(),
|
|
9791
|
+
completedAt: external_exports.number().optional(),
|
|
9669
9792
|
error: external_exports.object({
|
|
9670
9793
|
code: external_exports.string(),
|
|
9671
9794
|
message: external_exports.string()
|
|
9672
9795
|
}).optional()
|
|
9673
9796
|
});
|
|
9674
|
-
var
|
|
9675
|
-
|
|
9676
|
-
|
|
9677
|
-
|
|
9678
|
-
|
|
9679
|
-
|
|
9680
|
-
|
|
9681
|
-
|
|
9682
|
-
|
|
9683
|
-
|
|
9684
|
-
|
|
9685
|
-
|
|
9686
|
-
|
|
9687
|
-
|
|
9688
|
-
|
|
9689
|
-
|
|
9690
|
-
|
|
9691
|
-
external_exports.
|
|
9692
|
-
|
|
9693
|
-
|
|
9694
|
-
|
|
9695
|
-
|
|
9696
|
-
|
|
9697
|
-
|
|
9698
|
-
external_exports.
|
|
9699
|
-
|
|
9700
|
-
|
|
9701
|
-
|
|
9702
|
-
|
|
9703
|
-
|
|
9704
|
-
|
|
9705
|
-
external_exports.object({
|
|
9706
|
-
hour: external_exports.number().int().min(0).max(23),
|
|
9707
|
-
events: external_exports.number().int().min(0)
|
|
9708
|
-
})
|
|
9709
|
-
)
|
|
9797
|
+
var DeployProgressEventSchema = external_exports.object({
|
|
9798
|
+
type: external_exports.literal("deploy_progress"),
|
|
9799
|
+
deploymentId: external_exports.string(),
|
|
9800
|
+
timestamp: external_exports.number(),
|
|
9801
|
+
currentStep: DeployStepIdSchema,
|
|
9802
|
+
steps: external_exports.array(DeployStepStateSchema),
|
|
9803
|
+
result: external_exports.object({
|
|
9804
|
+
repoUrl: external_exports.string(),
|
|
9805
|
+
repoFullName: external_exports.string(),
|
|
9806
|
+
deployUrl: external_exports.string(),
|
|
9807
|
+
projectId: external_exports.string(),
|
|
9808
|
+
/** Human-readable project ID for URL construction */
|
|
9809
|
+
friendlyId: external_exports.string().nullable().optional(),
|
|
9810
|
+
/** Full API key - only shown once at completion! */
|
|
9811
|
+
apiKey: external_exports.string(),
|
|
9812
|
+
/** Preview (sk_...xxx) for display after initial view */
|
|
9813
|
+
apiKeyPreview: external_exports.string(),
|
|
9814
|
+
cloudflareUrl: external_exports.string().optional(),
|
|
9815
|
+
cloudflareDeployed: external_exports.boolean().optional(),
|
|
9816
|
+
/** Agent DID (decentralized identifier) - did:web for reputation enabled, did:key for disabled */
|
|
9817
|
+
agentDid: external_exports.string().optional(),
|
|
9818
|
+
/** Whether agent was registered with Know That AI for reputation tracking */
|
|
9819
|
+
ktaRegistered: external_exports.boolean().optional(),
|
|
9820
|
+
/** Claim URL for KTA registration (only when using cli-register with did:web) */
|
|
9821
|
+
ktaClaimUrl: external_exports.string().optional()
|
|
9822
|
+
}).optional(),
|
|
9823
|
+
error: external_exports.object({
|
|
9824
|
+
code: external_exports.string(),
|
|
9825
|
+
message: external_exports.string(),
|
|
9826
|
+
step: DeployStepIdSchema.optional()
|
|
9827
|
+
}).optional()
|
|
9710
9828
|
});
|
|
9711
|
-
var
|
|
9829
|
+
var DeploymentMetadataSchema = external_exports.object({
|
|
9712
9830
|
id: external_exports.string(),
|
|
9713
|
-
|
|
9714
|
-
|
|
9715
|
-
|
|
9716
|
-
|
|
9717
|
-
|
|
9718
|
-
|
|
9719
|
-
|
|
9720
|
-
|
|
9721
|
-
|
|
9722
|
-
|
|
9723
|
-
|
|
9724
|
-
|
|
9725
|
-
|
|
9726
|
-
|
|
9727
|
-
|
|
9728
|
-
|
|
9729
|
-
|
|
9730
|
-
|
|
9731
|
-
|
|
9732
|
-
|
|
9733
|
-
|
|
9734
|
-
|
|
9735
|
-
|
|
9736
|
-
|
|
9737
|
-
|
|
9738
|
-
|
|
9831
|
+
userId: external_exports.string(),
|
|
9832
|
+
organizationId: external_exports.string(),
|
|
9833
|
+
repoName: external_exports.string(),
|
|
9834
|
+
template: external_exports.string(),
|
|
9835
|
+
platform: external_exports.string(),
|
|
9836
|
+
/** Hosting mode: 'managed' (AgentShield hosted) or 'byok' (Bring Your Own Cloudflare) */
|
|
9837
|
+
hostingMode: external_exports.enum(["managed", "byok"]).optional().default("byok"),
|
|
9838
|
+
status: external_exports.enum(["pending", "running", "complete", "error"]),
|
|
9839
|
+
/** Enable reputation tracking via Know That AI (defaults to true) */
|
|
9840
|
+
enableReputation: external_exports.boolean().optional(),
|
|
9841
|
+
/** Existing project ID to deploy to (if provided, skips project creation) - Unified Project Schema v1.3 */
|
|
9842
|
+
existingProjectId: external_exports.string().uuid().optional(),
|
|
9843
|
+
createdAt: external_exports.number(),
|
|
9844
|
+
updatedAt: external_exports.number(),
|
|
9845
|
+
/** Result data (populated on completion) */
|
|
9846
|
+
result: external_exports.object({
|
|
9847
|
+
/** GitHub repo URL (BYOK deploy only) */
|
|
9848
|
+
repoUrl: external_exports.string().optional(),
|
|
9849
|
+
/** GitHub repo full name e.g. "user/repo" (BYOK deploy only) */
|
|
9850
|
+
repoFullName: external_exports.string().optional(),
|
|
9851
|
+
/** GitHub Actions deploy URL (BYOK deploy only) */
|
|
9852
|
+
deployUrl: external_exports.string().optional(),
|
|
9853
|
+
projectId: external_exports.string(),
|
|
9854
|
+
/** Human-readable project ID for URL construction */
|
|
9855
|
+
friendlyId: external_exports.string().nullable().optional(),
|
|
9856
|
+
/** API key preview e.g. "sk_...xxx" (BYOK deploy only) */
|
|
9857
|
+
apiKeyPreview: external_exports.string().optional(),
|
|
9858
|
+
cloudflareUrl: external_exports.string().optional(),
|
|
9859
|
+
cloudflareDeployed: external_exports.boolean().optional(),
|
|
9860
|
+
agentDid: external_exports.string().optional(),
|
|
9861
|
+
ktaRegistered: external_exports.boolean().optional(),
|
|
9862
|
+
ktaClaimUrl: external_exports.string().optional()
|
|
9739
9863
|
}).optional()
|
|
9740
9864
|
});
|
|
9741
|
-
|
|
9742
|
-
|
|
9743
|
-
|
|
9744
|
-
|
|
9745
|
-
|
|
9746
|
-
|
|
9747
|
-
|
|
9748
|
-
|
|
9749
|
-
|
|
9750
|
-
|
|
9751
|
-
|
|
9865
|
+
function getStepInfo(stepId) {
|
|
9866
|
+
return DEPLOY_STEPS.find((s) => s.id === stepId);
|
|
9867
|
+
}
|
|
9868
|
+
function getStepOrder(stepId) {
|
|
9869
|
+
const step = DEPLOY_STEPS.find((s) => s.id === stepId);
|
|
9870
|
+
return step?.order ?? 0;
|
|
9871
|
+
}
|
|
9872
|
+
function calculateDeployProgress(currentStep, status) {
|
|
9873
|
+
const totalSteps = DEPLOY_STEPS.length - 1;
|
|
9874
|
+
const currentOrder = getStepOrder(currentStep);
|
|
9875
|
+
if (currentStep === "complete") return 100;
|
|
9876
|
+
if (status === "running") {
|
|
9877
|
+
return Math.round((currentOrder - 0.5) / totalSteps * 100);
|
|
9878
|
+
}
|
|
9879
|
+
if (status === "complete") {
|
|
9880
|
+
return Math.round(currentOrder / totalSteps * 100);
|
|
9881
|
+
}
|
|
9882
|
+
return Math.round((currentOrder - 1) / totalSteps * 100);
|
|
9883
|
+
}
|
|
9884
|
+
function buildInitialStepsState() {
|
|
9885
|
+
return DEPLOY_STEPS.map((step) => ({
|
|
9886
|
+
id: step.id,
|
|
9887
|
+
status: "pending"
|
|
9888
|
+
}));
|
|
9889
|
+
}
|
|
9890
|
+
function updateStepsState(currentSteps, stepId, status, options) {
|
|
9891
|
+
const now = Date.now();
|
|
9892
|
+
return currentSteps.map((step) => {
|
|
9893
|
+
if (step.id === stepId) {
|
|
9894
|
+
return {
|
|
9895
|
+
...step,
|
|
9896
|
+
status,
|
|
9897
|
+
message: options?.message,
|
|
9898
|
+
error: options?.error,
|
|
9899
|
+
startedAt: status === "running" ? now : step.startedAt,
|
|
9900
|
+
completedAt: status === "complete" || status === "error" ? now : step.completedAt
|
|
9901
|
+
};
|
|
9902
|
+
}
|
|
9903
|
+
return step;
|
|
9904
|
+
});
|
|
9905
|
+
}
|
|
9906
|
+
|
|
9907
|
+
// src/types/wasm.ts
|
|
9908
|
+
var WasmAgentNameSchema = external_exports.union([
|
|
9909
|
+
AgentTypeSchema,
|
|
9910
|
+
external_exports.string().min(1).max(100)
|
|
9911
|
+
// Allow custom agent names but with constraints
|
|
9912
|
+
]);
|
|
9913
|
+
var WasmDetectionResultSchema = external_exports.object({
|
|
9914
|
+
is_agent: external_exports.boolean(),
|
|
9915
|
+
confidence: external_exports.number().min(0).max(1),
|
|
9916
|
+
agent: WasmAgentNameSchema.optional(),
|
|
9917
|
+
verification_method: external_exports.string(),
|
|
9918
|
+
risk_level: external_exports.string(),
|
|
9752
9919
|
timestamp: external_exports.string()
|
|
9753
9920
|
});
|
|
9754
|
-
var
|
|
9755
|
-
|
|
9756
|
-
|
|
9757
|
-
|
|
9758
|
-
|
|
9759
|
-
|
|
9921
|
+
var WasmRequestMetadataSchema = external_exports.object({
|
|
9922
|
+
user_agent: external_exports.string().optional(),
|
|
9923
|
+
ip_address: external_exports.string().optional(),
|
|
9924
|
+
headers: external_exports.string(),
|
|
9925
|
+
// JSON string of headers
|
|
9926
|
+
timestamp: external_exports.string(),
|
|
9927
|
+
url: external_exports.string().optional(),
|
|
9928
|
+
method: external_exports.string().optional(),
|
|
9929
|
+
client_fingerprint: external_exports.string().optional()
|
|
9930
|
+
// ✅ Added client fingerprint support
|
|
9760
9931
|
});
|
|
9932
|
+
var WasmVerificationMethod = /* @__PURE__ */ ((WasmVerificationMethod2) => {
|
|
9933
|
+
WasmVerificationMethod2["UserAgent"] = "UserAgent";
|
|
9934
|
+
WasmVerificationMethod2["IPRange"] = "IPRange";
|
|
9935
|
+
WasmVerificationMethod2["Signature"] = "Signature";
|
|
9936
|
+
WasmVerificationMethod2["Headers"] = "Headers";
|
|
9937
|
+
WasmVerificationMethod2["Behavioral"] = "Behavioral";
|
|
9938
|
+
WasmVerificationMethod2["Combined"] = "Combined";
|
|
9939
|
+
return WasmVerificationMethod2;
|
|
9940
|
+
})(WasmVerificationMethod || {});
|
|
9941
|
+
var WasmRiskLevel = /* @__PURE__ */ ((WasmRiskLevel2) => {
|
|
9942
|
+
WasmRiskLevel2["Low"] = "Low";
|
|
9943
|
+
WasmRiskLevel2["Medium"] = "Medium";
|
|
9944
|
+
WasmRiskLevel2["High"] = "High";
|
|
9945
|
+
WasmRiskLevel2["Critical"] = "Critical";
|
|
9946
|
+
return WasmRiskLevel2;
|
|
9947
|
+
})(WasmRiskLevel || {});
|
|
9948
|
+
function wasmToDetectionResult(wasmResult) {
|
|
9949
|
+
return {
|
|
9950
|
+
isAgent: wasmResult.is_agent,
|
|
9951
|
+
confidence: wasmResult.confidence,
|
|
9952
|
+
agentType: wasmResult.agent,
|
|
9953
|
+
verificationMethod: wasmResult.verification_method,
|
|
9954
|
+
riskLevel: wasmResult.risk_level,
|
|
9955
|
+
timestamp: new Date(wasmResult.timestamp)
|
|
9956
|
+
};
|
|
9957
|
+
}
|
|
9958
|
+
function toWasmRequestMetadata(request) {
|
|
9959
|
+
return {
|
|
9960
|
+
user_agent: request.userAgent,
|
|
9961
|
+
ip_address: request.ipAddress,
|
|
9962
|
+
headers: JSON.stringify(request.headers || {}),
|
|
9963
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
9964
|
+
url: request.url,
|
|
9965
|
+
method: request.method,
|
|
9966
|
+
client_fingerprint: request.clientFingerprint
|
|
9967
|
+
// ✅ Map camelCase to snake_case
|
|
9968
|
+
};
|
|
9969
|
+
}
|
|
9970
|
+
function isKnownAgentType(value) {
|
|
9971
|
+
return AgentTypeSchema.safeParse(value).success;
|
|
9972
|
+
}
|
|
9973
|
+
function isValidWasmDetectionResult(value) {
|
|
9974
|
+
return WasmDetectionResultSchema.safeParse(value).success;
|
|
9975
|
+
}
|
|
9976
|
+
function isValidWasmRequestMetadata(value) {
|
|
9977
|
+
return WasmRequestMetadataSchema.safeParse(value).success;
|
|
9978
|
+
}
|
|
9979
|
+
function parseAgentName(value) {
|
|
9980
|
+
const result = AgentTypeSchema.safeParse(value);
|
|
9981
|
+
return result.success ? result.data : "unknown";
|
|
9982
|
+
}
|
|
9983
|
+
function normalizeAgentName(value) {
|
|
9984
|
+
const normalized = value.toLowerCase().trim();
|
|
9985
|
+
if (isKnownAgentType(normalized)) {
|
|
9986
|
+
return normalized;
|
|
9987
|
+
}
|
|
9988
|
+
const partialMatches = {
|
|
9989
|
+
chatgpt: "chatgpt",
|
|
9990
|
+
"gpt-": "openai",
|
|
9991
|
+
"claude-": "claude",
|
|
9992
|
+
"gemini-": "google",
|
|
9993
|
+
"llama-": "meta",
|
|
9994
|
+
"mistral-": "mistral",
|
|
9995
|
+
"mixtral-": "mistral"
|
|
9996
|
+
};
|
|
9997
|
+
for (const [pattern, agentType] of Object.entries(partialMatches)) {
|
|
9998
|
+
if (normalized.includes(pattern)) {
|
|
9999
|
+
return agentType;
|
|
10000
|
+
}
|
|
10001
|
+
}
|
|
10002
|
+
return "unknown";
|
|
10003
|
+
}
|
|
10004
|
+
function getAgentDisplayName(agentType) {
|
|
10005
|
+
const displayNames = {
|
|
10006
|
+
openai: "OpenAI",
|
|
10007
|
+
chatgpt: "ChatGPT",
|
|
10008
|
+
claude: "Claude",
|
|
10009
|
+
anthropic: "Anthropic",
|
|
10010
|
+
perplexity: "Perplexity",
|
|
10011
|
+
phind: "Phind",
|
|
10012
|
+
you: "You.com",
|
|
10013
|
+
neeva: "Neeva",
|
|
10014
|
+
google: "Google",
|
|
10015
|
+
microsoft: "Microsoft",
|
|
10016
|
+
meta: "Meta",
|
|
10017
|
+
alibaba: "Alibaba",
|
|
10018
|
+
mistral: "Mistral AI",
|
|
10019
|
+
cohere: "Cohere",
|
|
10020
|
+
huggingface: "HuggingFace",
|
|
10021
|
+
inflection: "Inflection AI",
|
|
10022
|
+
stability: "Stability AI",
|
|
10023
|
+
replicate: "Replicate",
|
|
10024
|
+
together: "Together AI",
|
|
10025
|
+
"01ai": "01.AI",
|
|
10026
|
+
writer: "Writer",
|
|
10027
|
+
jasper: "Jasper",
|
|
10028
|
+
xai: "xAI",
|
|
10029
|
+
deepseek: "DeepSeek",
|
|
10030
|
+
amazon: "Amazon",
|
|
10031
|
+
kya: "KYA",
|
|
10032
|
+
unknown: "Unknown"
|
|
10033
|
+
};
|
|
10034
|
+
return displayNames[agentType] || agentType;
|
|
10035
|
+
}
|
|
9761
10036
|
|
|
9762
10037
|
// src/types/session.ts
|
|
9763
10038
|
var SessionStateSchema = external_exports.enum(["active", "idle", "expired", "terminated"]);
|
|
@@ -11375,6 +11650,24 @@ function createValidationErrorResponse(message, details, meta) {
|
|
|
11375
11650
|
}
|
|
11376
11651
|
|
|
11377
11652
|
// src/utils/verification.ts
|
|
11653
|
+
var KYA_OS_HANDSHAKE_METHODS = {
|
|
11654
|
+
/** New canonical engine value. Not emitted yet — accepted on read. */
|
|
11655
|
+
CANONICAL: "kyaos_handshake",
|
|
11656
|
+
/** @deprecated Legacy engine value. Still emitted by the Rust engine. */
|
|
11657
|
+
LEGACY: "mcp_i_handshake"
|
|
11658
|
+
};
|
|
11659
|
+
var KYA_OS_WIRE_METHODS = {
|
|
11660
|
+
/** New canonical wire value. Not emitted yet — accepted on read. */
|
|
11661
|
+
CANONICAL: "kya-os",
|
|
11662
|
+
/** @deprecated Legacy wire value. Still emitted by the gateway worker. */
|
|
11663
|
+
LEGACY: "mcp-i"
|
|
11664
|
+
};
|
|
11665
|
+
function isKyaOsHandshakeMethod(value) {
|
|
11666
|
+
return value === KYA_OS_HANDSHAKE_METHODS.LEGACY || value === KYA_OS_HANDSHAKE_METHODS.CANONICAL;
|
|
11667
|
+
}
|
|
11668
|
+
function isKyaOsWireMethod(value) {
|
|
11669
|
+
return value === KYA_OS_WIRE_METHODS.LEGACY || value === KYA_OS_WIRE_METHODS.CANONICAL;
|
|
11670
|
+
}
|
|
11378
11671
|
function getVerificationMethodDescription(method) {
|
|
11379
11672
|
switch (method) {
|
|
11380
11673
|
case "signature":
|
|
@@ -11385,7 +11678,9 @@ function getVerificationMethodDescription(method) {
|
|
|
11385
11678
|
return "Behavioral Analysis";
|
|
11386
11679
|
case "network":
|
|
11387
11680
|
return "Network-based Detection";
|
|
11681
|
+
// Dual-accept: legacy `mcp_i_handshake` + canonical `kyaos_handshake`.
|
|
11388
11682
|
case "mcp_i_handshake":
|
|
11683
|
+
case "kyaos_handshake":
|
|
11389
11684
|
return "MCP Handshake Detection";
|
|
11390
11685
|
case "error":
|
|
11391
11686
|
return "Detection Error";
|
|
@@ -11399,7 +11694,9 @@ function getVerificationReliability(method) {
|
|
|
11399
11694
|
case "signature":
|
|
11400
11695
|
return 1;
|
|
11401
11696
|
// Highest reliability
|
|
11697
|
+
// Dual-accept: legacy `mcp_i_handshake` + canonical `kyaos_handshake`.
|
|
11402
11698
|
case "mcp_i_handshake":
|
|
11699
|
+
case "kyaos_handshake":
|
|
11403
11700
|
return 0.95;
|
|
11404
11701
|
case "behavioral":
|
|
11405
11702
|
return 0.8;
|
|
@@ -11415,13 +11712,13 @@ function getVerificationReliability(method) {
|
|
|
11415
11712
|
}
|
|
11416
11713
|
}
|
|
11417
11714
|
function isHighConfidenceVerification(method) {
|
|
11418
|
-
return ["signature", "mcp_i_handshake"].includes(method);
|
|
11715
|
+
return ["signature", "mcp_i_handshake", "kyaos_handshake"].includes(method);
|
|
11419
11716
|
}
|
|
11420
11717
|
function getVerificationRiskLevel(method, confidence) {
|
|
11421
11718
|
if (method === "signature") {
|
|
11422
11719
|
return "low";
|
|
11423
11720
|
}
|
|
11424
|
-
if (method
|
|
11721
|
+
if (isKyaOsHandshakeMethod(method)) {
|
|
11425
11722
|
return "low";
|
|
11426
11723
|
}
|
|
11427
11724
|
if (confidence >= 0.9) {
|
|
@@ -11838,7 +12135,18 @@ var upstreamServerSchema = external_exports.object({
|
|
|
11838
12135
|
// Links this upstream to a dedicated AgentShield project for
|
|
11839
12136
|
// per-upstream detection, policy, and audit isolation.
|
|
11840
12137
|
// ─────────────────────────────────────────────────────────────────
|
|
11841
|
-
projectId: external_exports.string().uuid().nullable().optional()
|
|
12138
|
+
projectId: external_exports.string().uuid().nullable().optional(),
|
|
12139
|
+
// draft-kya-http-02 §7 Authorization Host (H1.1 #3244). The RESOLVED bare
|
|
12140
|
+
// host for this upstream's project — where the Hono gateway points a
|
|
12141
|
+
// Delegation challenge's consent_uri / pickup_uri. Forward contract: the
|
|
12142
|
+
// wire shape is established here in H1.1; the gateway populates it per
|
|
12143
|
+
// upstream from `projects.authorization_host` when its challenge emitter
|
|
12144
|
+
// lands (H2.1-WF), resolved out-of-band from `DbGatewayConfigProvider` so
|
|
12145
|
+
// that provider keeps its single-query invariant. Never authored by the
|
|
12146
|
+
// dashboard. The same resolved value is already live on the per-project
|
|
12147
|
+
// policy config the gateway worker fetches (`/api/internal/policies`), which
|
|
12148
|
+
// is AUTHORITATIVE — consumers prefer it and treat this copy as a hint.
|
|
12149
|
+
authorizationHost: external_exports.string().max(255).nullable().optional()
|
|
11842
12150
|
});
|
|
11843
12151
|
var upstreamServerInputSchema = upstreamServerSchema.extend({
|
|
11844
12152
|
id: external_exports.string().uuid().optional(),
|
|
@@ -11883,7 +12191,13 @@ var gatewayConfigSchema = external_exports.object({
|
|
|
11883
12191
|
enabled: external_exports.boolean().default(DEFAULT_EXTERNAL_ACCESS.enabled),
|
|
11884
12192
|
allowedDids: external_exports.array(external_exports.string()).default(DEFAULT_EXTERNAL_ACCESS.allowedDids),
|
|
11885
12193
|
externalScopes: external_exports.record(external_exports.array(external_exports.string())).default(DEFAULT_EXTERNAL_ACCESS.externalScopes)
|
|
11886
|
-
}).default(DEFAULT_EXTERNAL_ACCESS)
|
|
12194
|
+
}).default(DEFAULT_EXTERNAL_ACCESS),
|
|
12195
|
+
// T6 #2899 M2 — per-org fleet-server endpoint. When set, the gateway's
|
|
12196
|
+
// DiscoveryUpstreamProvider injects a synthetic `fleet` upstream so
|
|
12197
|
+
// callers can dispatch tools by capability or name (not just raw DID).
|
|
12198
|
+
// Validated via `safeUrl` so a misconfigured endpoint targeting
|
|
12199
|
+
// private-network IPs cannot become an SSRF pivot.
|
|
12200
|
+
fleetEndpoint: safeUrl.optional()
|
|
11887
12201
|
});
|
|
11888
12202
|
var gatewayConfigInputSchema = gatewayConfigSchema.extend({
|
|
11889
12203
|
upstreamServers: external_exports.array(upstreamServerInputSchema).default([])
|
|
@@ -11913,6 +12227,24 @@ var gatewayToolCallSchema = external_exports.object({
|
|
|
11913
12227
|
verificationMethod: external_exports.string().max(50).nullable().optional(),
|
|
11914
12228
|
createdAt: external_exports.coerce.date().default(() => /* @__PURE__ */ new Date())
|
|
11915
12229
|
});
|
|
12230
|
+
var gatewayConnectedAgentSchema = external_exports.object({
|
|
12231
|
+
clientDid: external_exports.string().nullable(),
|
|
12232
|
+
clientName: external_exports.string().nullable(),
|
|
12233
|
+
agentName: external_exports.string().nullable(),
|
|
12234
|
+
lastSeenAt: external_exports.coerce.date(),
|
|
12235
|
+
callCount: external_exports.number().int().min(1),
|
|
12236
|
+
/** Calls carrying an attestation hash — the cryptographically signed subset. */
|
|
12237
|
+
verifiedCalls: external_exports.number().int().min(0)
|
|
12238
|
+
});
|
|
12239
|
+
var gatewayConnectionsSummarySchema = external_exports.object({
|
|
12240
|
+
orgId: external_exports.string().uuid(),
|
|
12241
|
+
windowHours: external_exports.number().int().positive(),
|
|
12242
|
+
/** Distinct agents (by clientDid|agentName) active in the window. */
|
|
12243
|
+
distinctAgents: external_exports.number().int().min(0),
|
|
12244
|
+
/** Total gateway tool calls in the window. */
|
|
12245
|
+
totalCalls: external_exports.number().int().min(0),
|
|
12246
|
+
agents: external_exports.array(gatewayConnectedAgentSchema)
|
|
12247
|
+
});
|
|
11916
12248
|
|
|
11917
12249
|
// src/schemas/index.ts
|
|
11918
12250
|
function validate(schema, data) {
|
|
@@ -12690,20 +13022,43 @@ var BlockReasonSchema = external_exports.discriminatedUnion("kind", [
|
|
|
12690
13022
|
score: external_exports.number(),
|
|
12691
13023
|
threshold: external_exports.number()
|
|
12692
13024
|
}),
|
|
12693
|
-
external_exports.object({
|
|
13025
|
+
external_exports.object({
|
|
13026
|
+
kind: external_exports.literal("PolicyDenied"),
|
|
13027
|
+
detail: external_exports.string(),
|
|
13028
|
+
// #3272 PR2: the determining policy's authored Cedar @id (the policies
|
|
13029
|
+
// index join key). Optional + additive — absent on pre-PR2 payloads.
|
|
13030
|
+
policyId: external_exports.string().optional()
|
|
13031
|
+
}),
|
|
12694
13032
|
external_exports.object({ kind: external_exports.literal("ParseError"), detail: external_exports.string() })
|
|
12695
13033
|
]);
|
|
13034
|
+
var AssuranceTierSchema = external_exports.enum([
|
|
13035
|
+
"anonymous",
|
|
13036
|
+
"attested-bearer",
|
|
13037
|
+
"key-bound",
|
|
13038
|
+
"registered",
|
|
13039
|
+
"delegated"
|
|
13040
|
+
]);
|
|
12696
13041
|
var ChallengeParamsSchema = external_exports.object({
|
|
12697
13042
|
nonce: external_exports.string(),
|
|
12698
13043
|
audience: external_exports.string(),
|
|
12699
13044
|
expiresAt: external_exports.number(),
|
|
12700
13045
|
// unix seconds
|
|
12701
|
-
algorithmsAccepted: external_exports.array(external_exports.string())
|
|
13046
|
+
algorithmsAccepted: external_exports.array(external_exports.string()),
|
|
13047
|
+
// draft-kya-http-02 §1/§8 — the minimum assurance tier the policy demands
|
|
13048
|
+
// of the retry, set by a Cedar `@min_assurance(...)` annotation and
|
|
13049
|
+
// advertised by the PEP as `min_assurance` in the WWW-Authenticate
|
|
13050
|
+
// Delegation challenge. Optional + additive: absent for MCP-I L2+ handshake
|
|
13051
|
+
// challenges, so the DIF interop shape is unchanged when unset.
|
|
13052
|
+
minAssurance: AssuranceTierSchema.optional(),
|
|
13053
|
+
// #3272 PR2: the determining policy's authored Cedar @id. Optional + additive.
|
|
13054
|
+
policyId: external_exports.string().optional()
|
|
12702
13055
|
});
|
|
12703
13056
|
var RedirectTargetSchema = external_exports.object({
|
|
12704
13057
|
url: external_exports.string().url(),
|
|
12705
13058
|
reason: external_exports.string(),
|
|
12706
|
-
state: external_exports.string().optional()
|
|
13059
|
+
state: external_exports.string().optional(),
|
|
13060
|
+
// #3272 PR2: the determining policy's authored Cedar @id. Optional + additive.
|
|
13061
|
+
policyId: external_exports.string().optional()
|
|
12707
13062
|
});
|
|
12708
13063
|
var SuggestedActionSchema = external_exports.discriminatedUnion("kind", [
|
|
12709
13064
|
external_exports.object({ kind: external_exports.literal("UseDifferentScope"), scope: external_exports.string() }),
|
|
@@ -12718,10 +13073,15 @@ var SuggestedActionSchema = external_exports.discriminatedUnion("kind", [
|
|
|
12718
13073
|
var InstructPayloadSchema = external_exports.object({
|
|
12719
13074
|
problem: external_exports.string(),
|
|
12720
13075
|
title: external_exports.string(),
|
|
12721
|
-
suggestedActions: external_exports.array(SuggestedActionSchema)
|
|
13076
|
+
suggestedActions: external_exports.array(SuggestedActionSchema),
|
|
13077
|
+
// #3272 PR2: the determining policy's authored Cedar @id. Optional + additive.
|
|
13078
|
+
policyId: external_exports.string().optional()
|
|
12722
13079
|
});
|
|
12723
13080
|
var DecisionSchema = external_exports.discriminatedUnion("kind", [
|
|
12724
|
-
|
|
13081
|
+
// #3272 PR2: optional policyId = the authored Cedar @id of the determining
|
|
13082
|
+
// permit policy ("which rule admitted this"). Absent on pre-PR2 payloads and
|
|
13083
|
+
// non-policy-determined permits.
|
|
13084
|
+
external_exports.object({ kind: external_exports.literal("Permit"), policyId: external_exports.string().optional() }),
|
|
12725
13085
|
external_exports.object({ kind: external_exports.literal("Block"), reason: BlockReasonSchema }),
|
|
12726
13086
|
external_exports.object({ kind: external_exports.literal("Challenge"), params: ChallengeParamsSchema }),
|
|
12727
13087
|
external_exports.object({ kind: external_exports.literal("Redirect"), target: RedirectTargetSchema }),
|
|
@@ -12885,7 +13245,54 @@ var PolicyConfigSchema = external_exports.object({
|
|
|
12885
13245
|
/** Paths to include (if set, only these paths are enforced) */
|
|
12886
13246
|
includedPaths: external_exports.array(external_exports.string()).optional(),
|
|
12887
13247
|
/** Metadata for the policy configuration */
|
|
12888
|
-
metadata: PolicyMetadataSchema.optional()
|
|
13248
|
+
metadata: PolicyMetadataSchema.optional(),
|
|
13249
|
+
// ── Composed-policy (kya-os-engine) fields ──────────────────────────────
|
|
13250
|
+
// The policy API (`/api/internal/policies/[projectId]`) serves these so a
|
|
13251
|
+
// runtime that embeds the engine's Cedar evaluator can enforce the composed
|
|
13252
|
+
// `/policy-compose` output — identically to the DNS gateway worker — instead
|
|
13253
|
+
// of (or alongside) the structured fields above. They are carried through the
|
|
13254
|
+
// fetch contract here so the middleware (Express / Next.js / .NET) receives
|
|
13255
|
+
// them; runtimes that don't run the engine simply ignore them. Optional +
|
|
13256
|
+
// safe defaults: a policy without a composed bundle is unaffected.
|
|
13257
|
+
/**
|
|
13258
|
+
* Composed policy source (Cedar today). `null`/absent → no composed policy
|
|
13259
|
+
* (the runtime uses the structured fields). Empty/blank is treated as "no
|
|
13260
|
+
* policy" by the engine path (an empty bundle compiles to deny-all), so the
|
|
13261
|
+
* runtime MUST normalize blank → absent before handing it to the evaluator.
|
|
13262
|
+
*/
|
|
13263
|
+
policySourceText: external_exports.string().nullish(),
|
|
13264
|
+
/**
|
|
13265
|
+
* Language of `policySourceText`. `cedar` today; kept as a free string (not an
|
|
13266
|
+
* enum) so a future Rego/OPA bundle flows through the same contract without a
|
|
13267
|
+
* schema-version bump. A runtime enforces only languages it actually embeds.
|
|
13268
|
+
*/
|
|
13269
|
+
policyLanguage: external_exports.string().nullish(),
|
|
13270
|
+
/**
|
|
13271
|
+
* Hex sha256 of `policySourceText` as served by the SSOT — byte-identical to
|
|
13272
|
+
* `policy_revisions.composed_blob_hash` (#3246 PR5). Runtimes ECHO it onto
|
|
13273
|
+
* acted decisions (`enforcement.composedBlobHash`) and Delegation challenges
|
|
13274
|
+
* (`challenge.composed_blob_hash`) as the point-in-time revision pin; they
|
|
13275
|
+
* never hash locally. Absent/null → plane omits the pin (older dashboards).
|
|
13276
|
+
*/
|
|
13277
|
+
policySourceHash: external_exports.string().nullish(),
|
|
13278
|
+
/**
|
|
13279
|
+
* Whether the engine should ACT on the composed policy (deployed-to-enforce).
|
|
13280
|
+
* False → the composed policy is at most shadow-evaluated; the structured
|
|
13281
|
+
* path / bespoke decision governs. Mirrors the gateway worker's act-gate
|
|
13282
|
+
* (`engineEnforcementEnabled === true && enabled !== false`).
|
|
13283
|
+
*/
|
|
13284
|
+
engineEnforcementEnabled: external_exports.boolean().optional().default(false),
|
|
13285
|
+
/**
|
|
13286
|
+
* Trusted Layer-2 delegation root DIDs for the project's org (P2 / DR-1),
|
|
13287
|
+
* server-resolved by the policy API. A consuming middleware forwards these
|
|
13288
|
+
* into the engine's `ContextSpec.trustedDelegationRoots` so L2 delegation
|
|
13289
|
+
* chains are pinned to the org DID. Absent ⇒ omitted (root pinning disabled —
|
|
13290
|
+
* the engine's open default, byte-identical to pre-P2). Optional (no default)
|
|
13291
|
+
* so a policy without the field round-trips as `undefined`, matching the
|
|
13292
|
+
* policy API's `PolicyResponse` shape and the orchestrator's omit-when-unset
|
|
13293
|
+
* contract.
|
|
13294
|
+
*/
|
|
13295
|
+
trustedDelegationRoots: external_exports.array(external_exports.string()).optional()
|
|
12889
13296
|
});
|
|
12890
13297
|
var PolicyEvaluationContextSchema = external_exports.object({
|
|
12891
13298
|
// Agent identification
|
|
@@ -13290,6 +13697,146 @@ function createResult(action, reason, matchType, extras) {
|
|
|
13290
13697
|
};
|
|
13291
13698
|
}
|
|
13292
13699
|
|
|
13700
|
+
// src/policy/cedar-string.ts
|
|
13701
|
+
function escapeCedarString(value) {
|
|
13702
|
+
return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t");
|
|
13703
|
+
}
|
|
13704
|
+
function unescapeCedarString(value) {
|
|
13705
|
+
return value.replace(
|
|
13706
|
+
/\\([\\"nrt])/g,
|
|
13707
|
+
(_m, ch) => ch === "n" ? "\n" : ch === "r" ? "\r" : ch === "t" ? " " : ch
|
|
13708
|
+
);
|
|
13709
|
+
}
|
|
13710
|
+
function cedarQuotedValueRegExp(prefixSource, flags = "") {
|
|
13711
|
+
return new RegExp(`${prefixSource}"((?:\\\\.|[^"\\\\])*)"`, flags);
|
|
13712
|
+
}
|
|
13713
|
+
|
|
13714
|
+
// src/policy/cedar-rule-match.ts
|
|
13715
|
+
function blockApplies(block, request) {
|
|
13716
|
+
if (request?.path !== void 0 && !blockMatchesPath(block, request.path)) return false;
|
|
13717
|
+
if (request?.name !== void 0 && !blockMatchesEquality(block, "principal.name", request.name)) {
|
|
13718
|
+
return false;
|
|
13719
|
+
}
|
|
13720
|
+
if (request?.category !== void 0 && !blockMatchesEquality(block, "principal.category", request.category)) {
|
|
13721
|
+
return false;
|
|
13722
|
+
}
|
|
13723
|
+
return true;
|
|
13724
|
+
}
|
|
13725
|
+
function blockMatchesPath(block, path) {
|
|
13726
|
+
const literals = Array.from(
|
|
13727
|
+
block.matchAll(cedarQuotedValueRegExp("resource\\.path (?:like|==) ", "g")),
|
|
13728
|
+
(m) => unescapeCedarString(m[1])
|
|
13729
|
+
);
|
|
13730
|
+
if (literals.length === 0) return true;
|
|
13731
|
+
return literals.some((literal) => pathLiteralMatches(literal, path));
|
|
13732
|
+
}
|
|
13733
|
+
function escapeRegExp(s) {
|
|
13734
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
13735
|
+
}
|
|
13736
|
+
function blockMatchesEquality(block, attr, value) {
|
|
13737
|
+
const a = escapeRegExp(attr);
|
|
13738
|
+
const eq = Array.from(
|
|
13739
|
+
block.matchAll(cedarQuotedValueRegExp(`${a} == `, "g")),
|
|
13740
|
+
(m) => unescapeCedarString(m[1])
|
|
13741
|
+
);
|
|
13742
|
+
const neq = Array.from(
|
|
13743
|
+
block.matchAll(cedarQuotedValueRegExp(`${a} != `, "g")),
|
|
13744
|
+
(m) => unescapeCedarString(m[1])
|
|
13745
|
+
);
|
|
13746
|
+
if (neq.includes(value)) return false;
|
|
13747
|
+
if (eq.length > 0) return eq.includes(value);
|
|
13748
|
+
return true;
|
|
13749
|
+
}
|
|
13750
|
+
function pathLiteralMatches(literal, path) {
|
|
13751
|
+
if (!literal.includes("*")) return path === literal;
|
|
13752
|
+
const pattern = escapeRegExp(literal).replace(/\\\*/g, ".*");
|
|
13753
|
+
try {
|
|
13754
|
+
return new RegExp(`^${pattern}$`).test(path);
|
|
13755
|
+
} catch {
|
|
13756
|
+
return false;
|
|
13757
|
+
}
|
|
13758
|
+
}
|
|
13759
|
+
|
|
13760
|
+
// src/policy/required-scopes.ts
|
|
13761
|
+
function requiredScopesForRequest(policySource, request) {
|
|
13762
|
+
if (!policySource || !policySource.trim()) return [];
|
|
13763
|
+
const out = /* @__PURE__ */ new Set();
|
|
13764
|
+
for (const block of policySource.split(/\n\s*\n/)) {
|
|
13765
|
+
if (!/@verdict\("CHALLENGE"\)/.test(block)) continue;
|
|
13766
|
+
const scopesMatch = block.match(cedarQuotedValueRegExp("@scopes\\("));
|
|
13767
|
+
if (!scopesMatch) continue;
|
|
13768
|
+
const scopes = scopesMatch[1].split(/\s+/).filter(Boolean).map(unescapeCedarString);
|
|
13769
|
+
if (scopes.length === 0) continue;
|
|
13770
|
+
if (!blockApplies(block, request)) continue;
|
|
13771
|
+
for (const scope of scopes) out.add(scope);
|
|
13772
|
+
}
|
|
13773
|
+
return [...out];
|
|
13774
|
+
}
|
|
13775
|
+
|
|
13776
|
+
// src/policy/decision-policy-id.ts
|
|
13777
|
+
function decisionPolicyId(decision) {
|
|
13778
|
+
switch (decision.kind) {
|
|
13779
|
+
case "Permit":
|
|
13780
|
+
return decision.policyId;
|
|
13781
|
+
case "Block":
|
|
13782
|
+
return decision.reason?.kind === "PolicyDenied" ? decision.reason.policyId : void 0;
|
|
13783
|
+
case "Challenge":
|
|
13784
|
+
return decision.params?.policyId;
|
|
13785
|
+
case "Redirect":
|
|
13786
|
+
return decision.target?.policyId;
|
|
13787
|
+
case "Instruct":
|
|
13788
|
+
return decision.payload?.policyId;
|
|
13789
|
+
default:
|
|
13790
|
+
return void 0;
|
|
13791
|
+
}
|
|
13792
|
+
}
|
|
13793
|
+
|
|
13794
|
+
// src/policy/approval-quorum.ts
|
|
13795
|
+
function approvalQuorumForRequest(policySource, request) {
|
|
13796
|
+
if (!policySource || !policySource.trim()) return null;
|
|
13797
|
+
let chosen = null;
|
|
13798
|
+
for (const block of policySource.split(/\n\s*\n/)) {
|
|
13799
|
+
if (!/@verdict\("CHALLENGE"\)/.test(block)) continue;
|
|
13800
|
+
if (!blockApplies(block, request)) continue;
|
|
13801
|
+
const approvers = parseApprovers(block);
|
|
13802
|
+
if (!approvers) {
|
|
13803
|
+
return null;
|
|
13804
|
+
}
|
|
13805
|
+
const candidate = { n: parseQuorumN(block), approvers };
|
|
13806
|
+
if (chosen && !sameQuorum(chosen, candidate)) {
|
|
13807
|
+
return null;
|
|
13808
|
+
}
|
|
13809
|
+
chosen = candidate;
|
|
13810
|
+
}
|
|
13811
|
+
return chosen;
|
|
13812
|
+
}
|
|
13813
|
+
function parseApprovers(block) {
|
|
13814
|
+
const m = block.match(/@approvers\("([^"]*)"\)/);
|
|
13815
|
+
if (!m) return null;
|
|
13816
|
+
const approvers = m[1].split(/\s+/).filter(Boolean);
|
|
13817
|
+
return approvers.length > 0 ? approvers : null;
|
|
13818
|
+
}
|
|
13819
|
+
function sameQuorum(a, b) {
|
|
13820
|
+
return a.n === b.n && a.approvers.length === b.approvers.length && a.approvers.every((did, i) => did === b.approvers[i]);
|
|
13821
|
+
}
|
|
13822
|
+
function parseQuorumN(block) {
|
|
13823
|
+
const m = block.match(/@quorum\("([^"]*)"\)/);
|
|
13824
|
+
if (!m) return 1;
|
|
13825
|
+
const n = Number(m[1]);
|
|
13826
|
+
return Number.isInteger(n) && n >= 1 ? n : 1;
|
|
13827
|
+
}
|
|
13828
|
+
|
|
13829
|
+
// src/policy/step-up.ts
|
|
13830
|
+
function validateStepUpQuorum(quorum) {
|
|
13831
|
+
if (!Number.isInteger(quorum.n) || quorum.n < 1) {
|
|
13832
|
+
return { ok: false, reason: "invalid_step_up_quorum" };
|
|
13833
|
+
}
|
|
13834
|
+
if (!Array.isArray(quorum.approvers) || quorum.approvers.length === 0) {
|
|
13835
|
+
return { ok: false, reason: "step_up_no_approvers" };
|
|
13836
|
+
}
|
|
13837
|
+
return { ok: true };
|
|
13838
|
+
}
|
|
13839
|
+
|
|
13293
13840
|
// src/policy/fetcher.ts
|
|
13294
13841
|
var MemoryCache = class {
|
|
13295
13842
|
cache = /* @__PURE__ */ new Map();
|
|
@@ -13564,6 +14111,37 @@ function classifyResponseShape(rendered, clientAcceptsHtml) {
|
|
|
13564
14111
|
return "json-block";
|
|
13565
14112
|
}
|
|
13566
14113
|
|
|
14114
|
+
// src/host-adapter/fetcher-envelope.ts
|
|
14115
|
+
var ACCEPT_CHALLENGE_HEADER = "kya-accept-challenge";
|
|
14116
|
+
function readHeader(input, name) {
|
|
14117
|
+
if (!input) return void 0;
|
|
14118
|
+
if (typeof input.get === "function") {
|
|
14119
|
+
return input.get(name) ?? void 0;
|
|
14120
|
+
}
|
|
14121
|
+
const rec = input;
|
|
14122
|
+
const lower = name.toLowerCase();
|
|
14123
|
+
for (const key of Object.keys(rec)) {
|
|
14124
|
+
if (key.toLowerCase() === lower) {
|
|
14125
|
+
const v = rec[key];
|
|
14126
|
+
return Array.isArray(v) ? v[0] : v ?? void 0;
|
|
14127
|
+
}
|
|
14128
|
+
}
|
|
14129
|
+
return void 0;
|
|
14130
|
+
}
|
|
14131
|
+
function serveBodyReadable200(headers, detectionClass) {
|
|
14132
|
+
const optIn = readHeader(headers, ACCEPT_CHALLENGE_HEADER);
|
|
14133
|
+
if (optIn && optIn.trim().length > 0) return true;
|
|
14134
|
+
if (detectionClass !== void 0 && detectionClass !== null) {
|
|
14135
|
+
if (normalizeDetectionClassEnum(detectionClass) === "ai_agent") return true;
|
|
14136
|
+
}
|
|
14137
|
+
return false;
|
|
14138
|
+
}
|
|
14139
|
+
function selectBodyReadable200(mode, headers, detectionClass) {
|
|
14140
|
+
if (mode === "always-200") return true;
|
|
14141
|
+
if (mode === "negotiated") return serveBodyReadable200(headers, detectionClass);
|
|
14142
|
+
return false;
|
|
14143
|
+
}
|
|
14144
|
+
|
|
13567
14145
|
// src/wire/vault.ts
|
|
13568
14146
|
var vaultResolveMetaSchema = external_exports.object({
|
|
13569
14147
|
orgSlug: external_exports.string().optional(),
|
|
@@ -13762,6 +14340,226 @@ function base64UrlDecodeToString(s) {
|
|
|
13762
14340
|
return Buffer.from(base64UrlDecodeToBytes(s)).toString("utf-8");
|
|
13763
14341
|
}
|
|
13764
14342
|
|
|
14343
|
+
// src/mcpi/org-did.ts
|
|
14344
|
+
var MCPI_ORG_DID_HOST = "kya.vouched.id";
|
|
14345
|
+
var ORG_SLUG_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,253}[A-Za-z0-9])?$/;
|
|
14346
|
+
function isValidMcpiOrgSlug(slug) {
|
|
14347
|
+
return ORG_SLUG_PATTERN.test(slug);
|
|
14348
|
+
}
|
|
14349
|
+
function deriveMcpiOrgDid(slug) {
|
|
14350
|
+
if (!ORG_SLUG_PATTERN.test(slug)) {
|
|
14351
|
+
throw new Error(`Invalid org slug for did:web derivation: ${JSON.stringify(slug)}`);
|
|
14352
|
+
}
|
|
14353
|
+
return `did:web:${MCPI_ORG_DID_HOST}:orgs:${slug}`;
|
|
14354
|
+
}
|
|
14355
|
+
function deriveMcpiOrgKid(slug) {
|
|
14356
|
+
return `${deriveMcpiOrgDid(slug)}#key-1`;
|
|
14357
|
+
}
|
|
14358
|
+
function resolveTrustedDelegationRoots(org) {
|
|
14359
|
+
return [deriveMcpiOrgDid(org.slug)];
|
|
14360
|
+
}
|
|
14361
|
+
var USER_ID_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,253}[A-Za-z0-9])?$/;
|
|
14362
|
+
function deriveMcpiUserDid(slug, userId) {
|
|
14363
|
+
if (!USER_ID_PATTERN.test(userId)) {
|
|
14364
|
+
throw new Error(`Invalid user id for did:web derivation: ${JSON.stringify(userId)}`);
|
|
14365
|
+
}
|
|
14366
|
+
return `${deriveMcpiOrgDid(slug)}:users:${userId}`;
|
|
14367
|
+
}
|
|
14368
|
+
|
|
14369
|
+
// src/mcpi/delegation-headers.ts
|
|
14370
|
+
var DELEGATION_PROOF_HEADERS = ["kya-os-delegation-credential", "kya-delegation"];
|
|
14371
|
+
function isPresent(value) {
|
|
14372
|
+
if (Array.isArray(value)) return value.length > 0;
|
|
14373
|
+
return typeof value === "string" && value.length > 0;
|
|
14374
|
+
}
|
|
14375
|
+
function requestCarriesDelegationProof(headers) {
|
|
14376
|
+
if (!headers) return false;
|
|
14377
|
+
if (typeof headers.get === "function") {
|
|
14378
|
+
const h = headers;
|
|
14379
|
+
return DELEGATION_PROOF_HEADERS.some((name) => isPresent(h.get(name)));
|
|
14380
|
+
}
|
|
14381
|
+
const record = headers;
|
|
14382
|
+
const lowerKeyed = /* @__PURE__ */ new Map();
|
|
14383
|
+
for (const key of Object.keys(record)) {
|
|
14384
|
+
lowerKeyed.set(key.toLowerCase(), record[key]);
|
|
14385
|
+
}
|
|
14386
|
+
return DELEGATION_PROOF_HEADERS.some((name) => isPresent(lowerKeyed.get(name)));
|
|
14387
|
+
}
|
|
14388
|
+
|
|
14389
|
+
// src/mcpi/principal.ts
|
|
14390
|
+
var ANONYMOUS_PRINCIPAL_DID = "did:web:kya.vouched.id:principals:anonymous";
|
|
14391
|
+
var MCP_CLIENT_DID_HOST = "knowthat.ai";
|
|
14392
|
+
var CLIENT_ID_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,253}[A-Za-z0-9])?$/;
|
|
14393
|
+
function deriveMcpClientDid(clientId) {
|
|
14394
|
+
if (!CLIENT_ID_PATTERN.test(clientId)) {
|
|
14395
|
+
throw new Error(`Invalid client id for did:web derivation: ${JSON.stringify(clientId)}`);
|
|
14396
|
+
}
|
|
14397
|
+
return `did:web:${MCP_CLIENT_DID_HOST}:clients:${clientId}`;
|
|
14398
|
+
}
|
|
14399
|
+
|
|
14400
|
+
// src/mcpi/reported-identity.ts
|
|
14401
|
+
var DidStringSchema = external_exports.string().trim().min(1).regex(/^did:/, "must be a DID (did:web / did:key)");
|
|
14402
|
+
var NonEmptyTrimmed = external_exports.string().trim().min(1);
|
|
14403
|
+
var ReportedAgentSchema = external_exports.object({
|
|
14404
|
+
/** The agent's own DID, when it has one (enterprise A2A / provisioned). */
|
|
14405
|
+
did: DidStringSchema.optional(),
|
|
14406
|
+
/**
|
|
14407
|
+
* OAuth `client_id` of an authenticated MCP client. Checkpoint derives the
|
|
14408
|
+
* canonical `did:web` from this (DR-9 `deriveMcpClientDid`); the reporter
|
|
14409
|
+
* sends the raw id, not the derived DID.
|
|
14410
|
+
*/
|
|
14411
|
+
oauthClientId: NonEmptyTrimmed.optional(),
|
|
14412
|
+
/**
|
|
14413
|
+
* MCP `initialize` `clientInfo.name` (e.g. `claude-ai`, `cursor`). DECLARED,
|
|
14414
|
+
* unauthenticated — recorded as a hint, never resolved as identity above
|
|
14415
|
+
* `attested-bearer` assurance.
|
|
14416
|
+
*/
|
|
14417
|
+
clientInfoName: NonEmptyTrimmed.optional(),
|
|
14418
|
+
/** MCP `initialize` `clientInfo.version`. Declared. */
|
|
14419
|
+
clientInfoVersion: NonEmptyTrimmed.optional()
|
|
14420
|
+
}).describe("Asserted identity of the acting agent");
|
|
14421
|
+
var ReportedPrincipalSchema = external_exports.object({
|
|
14422
|
+
/** The principal's DID (the delegation issuer, typically). */
|
|
14423
|
+
did: DidStringSchema.optional(),
|
|
14424
|
+
/** Issuer-local subject identifier, when the principal has no DID. */
|
|
14425
|
+
sub: NonEmptyTrimmed.optional(),
|
|
14426
|
+
/** Optional display email. Never the identity key — `did`/`sub` are. */
|
|
14427
|
+
email: NonEmptyTrimmed.email().optional()
|
|
14428
|
+
}).describe("Asserted identity of the principal the agent acted for");
|
|
14429
|
+
var DelegationResultSchema = external_exports.enum(["verified", "failed", "not_presented"]);
|
|
14430
|
+
var DelegationVerifiedBySchema = external_exports.enum(["reporter", "gateway", "checkpoint"]);
|
|
14431
|
+
var ReportedDelegationSchema = external_exports.object({
|
|
14432
|
+
/** Delegation credential id — the join key into `delegations`. */
|
|
14433
|
+
jti: NonEmptyTrimmed.optional(),
|
|
14434
|
+
/** Issuer DID (usually the principal). */
|
|
14435
|
+
iss: DidStringSchema.optional(),
|
|
14436
|
+
/** Audience DID (the intended verifier / resource). */
|
|
14437
|
+
aud: DidStringSchema.optional(),
|
|
14438
|
+
/** Granted capabilities, e.g. `['vault:read']`. */
|
|
14439
|
+
capabilities: external_exports.array(NonEmptyTrimmed).optional(),
|
|
14440
|
+
/** Expiry, unix seconds. */
|
|
14441
|
+
exp: external_exports.number().int().positive().optional(),
|
|
14442
|
+
/** Verification outcome — required. */
|
|
14443
|
+
result: DelegationResultSchema,
|
|
14444
|
+
/** Who verified — required. */
|
|
14445
|
+
verifiedBy: DelegationVerifiedBySchema
|
|
14446
|
+
}).describe("Presented delegation: reference + verification outcome");
|
|
14447
|
+
var ReportedIdentitySchema = external_exports.object({
|
|
14448
|
+
agent: ReportedAgentSchema.optional(),
|
|
14449
|
+
principal: ReportedPrincipalSchema.optional(),
|
|
14450
|
+
delegation: ReportedDelegationSchema.optional()
|
|
14451
|
+
}).describe("MCP-I reported identity (verifier \u2192 observability plane)");
|
|
14452
|
+
|
|
14453
|
+
// src/mcpi/did-key.ts
|
|
14454
|
+
var BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
14455
|
+
var BASE58_INDEX = (() => {
|
|
14456
|
+
const idx = {};
|
|
14457
|
+
for (let i = 0; i < BASE58_ALPHABET.length; i++) idx[BASE58_ALPHABET[i]] = i;
|
|
14458
|
+
return idx;
|
|
14459
|
+
})();
|
|
14460
|
+
var DID_KEY_PREFIX = "did:key:";
|
|
14461
|
+
var ED25519_MULTICODEC = [237, 1];
|
|
14462
|
+
var ED25519_PUBKEY_LENGTH = 32;
|
|
14463
|
+
var ED25519_MULTIKEY_LENGTH = ED25519_MULTICODEC.length + ED25519_PUBKEY_LENGTH;
|
|
14464
|
+
function base58btcDecode(str) {
|
|
14465
|
+
if (str.length === 0) return new Uint8Array(0);
|
|
14466
|
+
let zeros = 0;
|
|
14467
|
+
while (zeros < str.length && str[zeros] === BASE58_ALPHABET[0]) zeros++;
|
|
14468
|
+
const bytes = [0];
|
|
14469
|
+
for (let i = 0; i < str.length; i++) {
|
|
14470
|
+
const value = BASE58_INDEX[str[i]];
|
|
14471
|
+
if (value === void 0) return null;
|
|
14472
|
+
let carry = value;
|
|
14473
|
+
for (let j = 0; j < bytes.length; j++) {
|
|
14474
|
+
carry += bytes[j] * 58;
|
|
14475
|
+
bytes[j] = carry & 255;
|
|
14476
|
+
carry >>= 8;
|
|
14477
|
+
}
|
|
14478
|
+
while (carry > 0) {
|
|
14479
|
+
bytes.push(carry & 255);
|
|
14480
|
+
carry >>= 8;
|
|
14481
|
+
}
|
|
14482
|
+
}
|
|
14483
|
+
let high = bytes.length;
|
|
14484
|
+
while (high > 0 && bytes[high - 1] === 0) high--;
|
|
14485
|
+
const out = new Uint8Array(zeros + high);
|
|
14486
|
+
for (let i = 0; i < high; i++) {
|
|
14487
|
+
out[zeros + high - 1 - i] = bytes[i];
|
|
14488
|
+
}
|
|
14489
|
+
return out;
|
|
14490
|
+
}
|
|
14491
|
+
function base58btcEncode(bytes) {
|
|
14492
|
+
if (bytes.length === 0) return "";
|
|
14493
|
+
let zeros = 0;
|
|
14494
|
+
while (zeros < bytes.length && bytes[zeros] === 0) zeros++;
|
|
14495
|
+
const digits = [0];
|
|
14496
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
14497
|
+
let carry = bytes[i];
|
|
14498
|
+
for (let j = 0; j < digits.length; j++) {
|
|
14499
|
+
carry += digits[j] * 256;
|
|
14500
|
+
digits[j] = carry % 58;
|
|
14501
|
+
carry = Math.floor(carry / 58);
|
|
14502
|
+
}
|
|
14503
|
+
while (carry > 0) {
|
|
14504
|
+
digits.push(carry % 58);
|
|
14505
|
+
carry = Math.floor(carry / 58);
|
|
14506
|
+
}
|
|
14507
|
+
}
|
|
14508
|
+
let high = digits.length;
|
|
14509
|
+
while (high > 0 && digits[high - 1] === 0) high--;
|
|
14510
|
+
let out = BASE58_ALPHABET[0].repeat(zeros);
|
|
14511
|
+
for (let i = high - 1; i >= 0; i--) {
|
|
14512
|
+
out += BASE58_ALPHABET[digits[i]];
|
|
14513
|
+
}
|
|
14514
|
+
return out;
|
|
14515
|
+
}
|
|
14516
|
+
function decodeDidKeyEd25519(did) {
|
|
14517
|
+
if (typeof did !== "string" || !did.startsWith(DID_KEY_PREFIX)) return null;
|
|
14518
|
+
const suffix = did.slice(DID_KEY_PREFIX.length);
|
|
14519
|
+
if (!suffix.startsWith("z")) return null;
|
|
14520
|
+
const body = suffix.slice(1);
|
|
14521
|
+
if (body.length > 64) return null;
|
|
14522
|
+
const decoded = base58btcDecode(body);
|
|
14523
|
+
if (!decoded || decoded.length !== ED25519_MULTIKEY_LENGTH) return null;
|
|
14524
|
+
if (decoded[0] !== ED25519_MULTICODEC[0] || decoded[1] !== ED25519_MULTICODEC[1]) return null;
|
|
14525
|
+
return decoded.slice(ED25519_MULTICODEC.length);
|
|
14526
|
+
}
|
|
14527
|
+
function encodeDidKeyEd25519(publicKey) {
|
|
14528
|
+
if (!(publicKey instanceof Uint8Array) || publicKey.length !== ED25519_PUBKEY_LENGTH) {
|
|
14529
|
+
throw new Error(
|
|
14530
|
+
`encodeDidKeyEd25519: expected a ${ED25519_PUBKEY_LENGTH}-byte Ed25519 public key, got ${publicKey instanceof Uint8Array ? `${publicKey.length} bytes` : typeof publicKey}`
|
|
14531
|
+
);
|
|
14532
|
+
}
|
|
14533
|
+
const multikey = new Uint8Array(ED25519_MULTIKEY_LENGTH);
|
|
14534
|
+
multikey[0] = ED25519_MULTICODEC[0];
|
|
14535
|
+
multikey[1] = ED25519_MULTICODEC[1];
|
|
14536
|
+
multikey.set(publicKey, ED25519_MULTICODEC.length);
|
|
14537
|
+
return `${DID_KEY_PREFIX}z${base58btcEncode(multikey)}`;
|
|
14538
|
+
}
|
|
14539
|
+
|
|
14540
|
+
// src/mcpi/kya-http-error-codes.ts
|
|
14541
|
+
var KYA_HTTP_ERROR = {
|
|
14542
|
+
// ── 401 (identity / signature) ──────────────────────────────────────────
|
|
14543
|
+
MISSING_SIGNATURE: "kyaos/missing-signature",
|
|
14544
|
+
INVALID_SIGNATURE: "kyaos/invalid-signature",
|
|
14545
|
+
EXPIRED: "kyaos/expired",
|
|
14546
|
+
REPLAY: "kyaos/replay",
|
|
14547
|
+
DID_UNRESOLVABLE: "kyaos/did-unresolvable",
|
|
14548
|
+
AUTHORIZATION_REQUIRED: "kyaos/authorization-required",
|
|
14549
|
+
// ── 403 (delegation / profile) ──────────────────────────────────────────
|
|
14550
|
+
PROFILE_VIOLATION: "kyaos/profile-violation",
|
|
14551
|
+
DELEGATION_REVOKED: "kyaos/delegation-revoked",
|
|
14552
|
+
SCOPE_INSUFFICIENT: "kyaos/scope-insufficient",
|
|
14553
|
+
CHAIN_BROKEN: "kyaos/chain-broken",
|
|
14554
|
+
HOLDER_MISMATCH: "kyaos/holder-mismatch",
|
|
14555
|
+
AUDIENCE_MISMATCH: "kyaos/audience-mismatch",
|
|
14556
|
+
SESSION_MISMATCH: "kyaos/session-mismatch",
|
|
14557
|
+
PICKUP_PINNED: "kyaos/pickup-pinned",
|
|
14558
|
+
// ── pickup flow (404 / 410) ─────────────────────────────────────────────
|
|
14559
|
+
INVALID_SESSION: "kyaos/invalid-session",
|
|
14560
|
+
PICKUP_EXPIRED: "kyaos/pickup-expired"
|
|
14561
|
+
};
|
|
14562
|
+
|
|
13765
14563
|
// src/parsers/jafar.ts
|
|
13766
14564
|
var IPV4_CIDR_RE = /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\/(?:3[0-2]|[12]?\d)$/;
|
|
13767
14565
|
var IPV6_CIDR_RE = /^[0-9a-fA-F:]+\/(?:12[0-8]|1[01]\d|\d{1,2})$/;
|
|
@@ -13850,7 +14648,9 @@ Object.defineProperty(exports, "validateProviderDefinition", {
|
|
|
13850
14648
|
enumerable: true,
|
|
13851
14649
|
get: function () { return providerRegistry.validateProviderDefinition; }
|
|
13852
14650
|
});
|
|
14651
|
+
exports.ACCEPT_CHALLENGE_HEADER = ACCEPT_CHALLENGE_HEADER;
|
|
13853
14652
|
exports.AI_AGENT_HEADERS = AI_AGENT_HEADERS;
|
|
14653
|
+
exports.ANONYMOUS_PRINCIPAL_DID = ANONYMOUS_PRINCIPAL_DID;
|
|
13854
14654
|
exports.API_ERRORS = API_ERRORS;
|
|
13855
14655
|
exports.API_ERROR_CODES = API_ERROR_CODES;
|
|
13856
14656
|
exports.API_REQUEST_LIMITS = API_REQUEST_LIMITS;
|
|
@@ -13898,6 +14698,7 @@ exports.ApiKeysBulkRevokeItemSchema = ApiKeysBulkRevokeItemSchema;
|
|
|
13898
14698
|
exports.ApiKeysBulkUpdateItemSchema = ApiKeysBulkUpdateItemSchema;
|
|
13899
14699
|
exports.ApiKeysQuerySchema = ApiKeysQuerySchema;
|
|
13900
14700
|
exports.ApiResponseSchema = ApiResponseSchema;
|
|
14701
|
+
exports.AssuranceTierSchema = AssuranceTierSchema;
|
|
13901
14702
|
exports.AuthErrorType = AuthErrorType;
|
|
13902
14703
|
exports.AuthProviderTypeSchema = AuthProviderTypeSchema;
|
|
13903
14704
|
exports.BLOCKED_PATH = BLOCKED_PATH;
|
|
@@ -13955,7 +14756,7 @@ exports.ChallengeParamsSchema = ChallengeParamsSchema;
|
|
|
13955
14756
|
exports.CircuitBreakerConfigSchema = CircuitBreakerConfigSchema;
|
|
13956
14757
|
exports.CircuitBreakerStateSchema = CircuitBreakerStateSchema;
|
|
13957
14758
|
exports.ClickEventSchema = ClickEventSchema;
|
|
13958
|
-
exports.ClientDetectionSchema =
|
|
14759
|
+
exports.ClientDetectionSchema = ClientDetectionSchema;
|
|
13959
14760
|
exports.CollectFingerprintRequestSchema = CollectFingerprintRequestSchema;
|
|
13960
14761
|
exports.CollectFingerprintResponseSchema = CollectFingerprintResponseSchema;
|
|
13961
14762
|
exports.CollectedDataSchema = CollectedDataSchema;
|
|
@@ -13989,6 +14790,7 @@ exports.DATABASE_LIMITS = DATABASE_LIMITS;
|
|
|
13989
14790
|
exports.DEFAULT_AGENTSHIELD_CONFIG = DEFAULT_AGENTSHIELD_CONFIG;
|
|
13990
14791
|
exports.DEFAULT_AGENT_TYPES = DEFAULT_AGENT_TYPES;
|
|
13991
14792
|
exports.DEFAULT_API_KEY_RATE_LIMITS = DEFAULT_API_KEY_RATE_LIMITS;
|
|
14793
|
+
exports.DEFAULT_AUTHORIZATION_HOST = DEFAULT_AUTHORIZATION_HOST;
|
|
13992
14794
|
exports.DEFAULT_BEHAVIORAL_THRESHOLDS = DEFAULT_BEHAVIORAL_THRESHOLDS;
|
|
13993
14795
|
exports.DEFAULT_CACHE_CONFIG = DEFAULT_CACHE_CONFIG;
|
|
13994
14796
|
exports.DEFAULT_CONFIDENCE_THRESHOLDS = DEFAULT_CONFIDENCE_THRESHOLDS;
|
|
@@ -14007,6 +14809,7 @@ exports.DEFAULT_SESSION_CONFIG = DEFAULT_SESSION_CONFIG;
|
|
|
14007
14809
|
exports.DEFAULT_THRESHOLDS = DEFAULT_THRESHOLDS;
|
|
14008
14810
|
exports.DEFAULT_TIMEOUTS = DEFAULT_TIMEOUTS;
|
|
14009
14811
|
exports.DEFAULT_WEBHOOK_EVENTS = DEFAULT_WEBHOOK_EVENTS;
|
|
14812
|
+
exports.DELEGATION_PROOF_HEADERS = DELEGATION_PROOF_HEADERS;
|
|
14010
14813
|
exports.DEPLOY_STEPS = DEPLOY_STEPS;
|
|
14011
14814
|
exports.DETECTION_ERRORS = DETECTION_ERRORS;
|
|
14012
14815
|
exports.DETECTION_LIMITS = DETECTION_LIMITS;
|
|
@@ -14015,8 +14818,10 @@ exports.DatabaseDetectionMetadataSchema = DatabaseDetectionMetadataSchema;
|
|
|
14015
14818
|
exports.DatabaseStatusSchema = DatabaseStatusSchema;
|
|
14016
14819
|
exports.DecisionSchema = DecisionSchema;
|
|
14017
14820
|
exports.DelegationPollingStatusSchema = DelegationPollingStatusSchema;
|
|
14821
|
+
exports.DelegationResultSchema = DelegationResultSchema;
|
|
14018
14822
|
exports.DelegationSchema = DelegationSchema;
|
|
14019
14823
|
exports.DelegationStatusSchema = DelegationStatusSchema;
|
|
14824
|
+
exports.DelegationVerifiedBySchema = DelegationVerifiedBySchema;
|
|
14020
14825
|
exports.DeleteAccountSchema = DeleteAccountSchema;
|
|
14021
14826
|
exports.DenyListEntrySchema = DenyListEntrySchema;
|
|
14022
14827
|
exports.DeployProgressEventSchema = DeployProgressEventSchema;
|
|
@@ -14064,7 +14869,7 @@ exports.ExpressMiddlewareOptionsSchema = ExpressMiddlewareOptionsSchema;
|
|
|
14064
14869
|
exports.FallbackOptionsSchema = FallbackOptionsSchema;
|
|
14065
14870
|
exports.FilterOperatorSchema = FilterOperatorSchema;
|
|
14066
14871
|
exports.FingerprintAnalysisSchema = FingerprintAnalysisSchema;
|
|
14067
|
-
exports.FingerprintClientDetectionSchema =
|
|
14872
|
+
exports.FingerprintClientDetectionSchema = ClientDetectionSchema2;
|
|
14068
14873
|
exports.FingerprintDetectRequestSchema = FingerprintDetectRequestSchema;
|
|
14069
14874
|
exports.FingerprintRecordSchema = FingerprintRecordSchema;
|
|
14070
14875
|
exports.FingerprintResponseSchema = FingerprintResponseSchema;
|
|
@@ -14091,10 +14896,15 @@ exports.IpRangeRuleSchema = IpRangeRuleSchema;
|
|
|
14091
14896
|
exports.JafarParseError = JafarParseError;
|
|
14092
14897
|
exports.JwsParseError = JwsParseError;
|
|
14093
14898
|
exports.KNOWN_AGENT_PATTERNS = KNOWN_AGENT_PATTERNS;
|
|
14899
|
+
exports.KYA_HTTP_ERROR = KYA_HTTP_ERROR;
|
|
14900
|
+
exports.KYA_OS_HANDSHAKE_METHODS = KYA_OS_HANDSHAKE_METHODS;
|
|
14901
|
+
exports.KYA_OS_WIRE_METHODS = KYA_OS_WIRE_METHODS;
|
|
14094
14902
|
exports.KeyboardEventSchema = KeyboardEventSchema;
|
|
14095
14903
|
exports.LoggingConfigSchema = LoggingConfigSchema;
|
|
14096
14904
|
exports.MATCH_ACTIONS = MATCH_ACTIONS;
|
|
14097
14905
|
exports.MAX_BULK_BATCH_SIZE = MAX_BULK_BATCH_SIZE;
|
|
14906
|
+
exports.MCPI_ORG_DID_HOST = MCPI_ORG_DID_HOST;
|
|
14907
|
+
exports.MCP_CLIENT_DID_HOST = MCP_CLIENT_DID_HOST;
|
|
14098
14908
|
exports.MOBILE_PATTERNS = MOBILE_PATTERNS;
|
|
14099
14909
|
exports.MessagePrioritySchema = MessagePrioritySchema;
|
|
14100
14910
|
exports.MiddlewareActionSchema = MiddlewareActionSchema;
|
|
@@ -14209,6 +15019,10 @@ exports.RedirectTargetSchema = RedirectTargetSchema;
|
|
|
14209
15019
|
exports.RedisSessionDataSchema = RedisSessionDataSchema;
|
|
14210
15020
|
exports.RedisStatsSchema = RedisStatsSchema;
|
|
14211
15021
|
exports.RefreshScopesRequestSchema = RefreshScopesRequestSchema;
|
|
15022
|
+
exports.ReportedAgentSchema = ReportedAgentSchema;
|
|
15023
|
+
exports.ReportedDelegationSchema = ReportedDelegationSchema;
|
|
15024
|
+
exports.ReportedIdentitySchema = ReportedIdentitySchema;
|
|
15025
|
+
exports.ReportedPrincipalSchema = ReportedPrincipalSchema;
|
|
14212
15026
|
exports.RequestContextSchema = RequestContextSchema;
|
|
14213
15027
|
exports.ResourceUsageSchema = ResourceUsageSchema;
|
|
14214
15028
|
exports.ResponseActionSchema = ResponseActionSchema;
|
|
@@ -14267,6 +15081,7 @@ exports.TestDetectionRequestSchema = TestDetectionRequestSchema;
|
|
|
14267
15081
|
exports.ThresholdConfigSchema = ThresholdConfigSchema;
|
|
14268
15082
|
exports.ToolConsentOverridesSchema = ToolConsentOverridesSchema;
|
|
14269
15083
|
exports.TouchEventSchema = TouchEventSchema;
|
|
15084
|
+
exports.TraceStepSchema = TraceStepSchema;
|
|
14270
15085
|
exports.TransportConfigSchema = TransportConfigSchema;
|
|
14271
15086
|
exports.TransportMetricsSchema = TransportMetricsSchema;
|
|
14272
15087
|
exports.TransportOptionsSchema = TransportOptionsSchema;
|
|
@@ -14317,12 +15132,14 @@ exports.WorkerPoolConfigSchema = WorkerPoolConfigSchema;
|
|
|
14317
15132
|
exports.WorkerStateSchema = WorkerStateSchema;
|
|
14318
15133
|
exports.WorkerTaskSchema = WorkerTaskSchema;
|
|
14319
15134
|
exports.acceptsHtml = acceptsHtml;
|
|
15135
|
+
exports.approvalQuorumForRequest = approvalQuorumForRequest;
|
|
14320
15136
|
exports.assignmentChangeRequestSchema = assignmentChangeRequestSchema;
|
|
14321
15137
|
exports.auditLogQuerySchema = auditLogQuerySchema;
|
|
14322
15138
|
exports.batchAssignmentRequestSchema = batchAssignmentRequestSchema;
|
|
14323
15139
|
exports.buildInitialStepsState = buildInitialStepsState;
|
|
14324
15140
|
exports.calculateDeployProgress = calculateDeployProgress;
|
|
14325
15141
|
exports.canonicalSigningPayload = canonicalSigningPayload;
|
|
15142
|
+
exports.cedarQuotedValueRegExp = cedarQuotedValueRegExp;
|
|
14326
15143
|
exports.changePasswordSchema = changePasswordSchema;
|
|
14327
15144
|
exports.classifyResponseShape = classifyResponseShape;
|
|
14328
15145
|
exports.createError = createError;
|
|
@@ -14336,12 +15153,20 @@ exports.createPublicPaginatedResponse = createPublicPaginatedResponse;
|
|
|
14336
15153
|
exports.createPublicSuccessResponse = createPublicSuccessResponse;
|
|
14337
15154
|
exports.createSuccessResponse = createSuccessResponse;
|
|
14338
15155
|
exports.createValidationErrorResponse = createValidationErrorResponse;
|
|
15156
|
+
exports.decisionPolicyId = decisionPolicyId;
|
|
15157
|
+
exports.decodeDidKeyEd25519 = decodeDidKeyEd25519;
|
|
14339
15158
|
exports.defaultConfig = defaultConfig;
|
|
15159
|
+
exports.deriveMcpClientDid = deriveMcpClientDid;
|
|
15160
|
+
exports.deriveMcpiOrgDid = deriveMcpiOrgDid;
|
|
15161
|
+
exports.deriveMcpiOrgKid = deriveMcpiOrgKid;
|
|
15162
|
+
exports.deriveMcpiUserDid = deriveMcpiUserDid;
|
|
14340
15163
|
exports.deriveVerdict = deriveVerdict;
|
|
14341
15164
|
exports.detectionClassToEnum = detectionClassToEnum;
|
|
14342
15165
|
exports.discoveredToolSchema = discoveredToolSchema;
|
|
15166
|
+
exports.encodeDidKeyEd25519 = encodeDidKeyEd25519;
|
|
14343
15167
|
exports.encodeVerdictCookie = encodeVerdictCookie;
|
|
14344
15168
|
exports.enumToDetectionClass = enumToDetectionClass;
|
|
15169
|
+
exports.escapeCedarString = escapeCedarString;
|
|
14345
15170
|
exports.evaluatePolicy = evaluatePolicy;
|
|
14346
15171
|
exports.extractMatch = extractMatch;
|
|
14347
15172
|
exports.fetchPolicy = fetchPolicy;
|
|
@@ -14352,6 +15177,8 @@ exports.fromProviderRegistryFormat = fromProviderRegistryFormat;
|
|
|
14352
15177
|
exports.fromProviderRegistryFormatSafe = fromProviderRegistryFormatSafe;
|
|
14353
15178
|
exports.gatewayConfigInputSchema = gatewayConfigInputSchema;
|
|
14354
15179
|
exports.gatewayConfigSchema = gatewayConfigSchema;
|
|
15180
|
+
exports.gatewayConnectedAgentSchema = gatewayConnectedAgentSchema;
|
|
15181
|
+
exports.gatewayConnectionsSummarySchema = gatewayConnectionsSummarySchema;
|
|
14355
15182
|
exports.gatewayInternalDiscoverErrorSchema = gatewayInternalDiscoverErrorSchema;
|
|
14356
15183
|
exports.gatewayInternalDiscoverSuccessSchema = gatewayInternalDiscoverSuccessSchema;
|
|
14357
15184
|
exports.gatewayInternalToolsListSchema = gatewayInternalToolsListSchema;
|
|
@@ -14376,6 +15203,8 @@ exports.isBlockingAction = isBlockingAction;
|
|
|
14376
15203
|
exports.isHighConfidenceVerification = isHighConfidenceVerification;
|
|
14377
15204
|
exports.isKnownAgentType = isKnownAgentType;
|
|
14378
15205
|
exports.isKnownAiCrawler = isKnownAiCrawler;
|
|
15206
|
+
exports.isKyaOsHandshakeMethod = isKyaOsHandshakeMethod;
|
|
15207
|
+
exports.isKyaOsWireMethod = isKyaOsWireMethod;
|
|
14379
15208
|
exports.isLegacyDetectionClass = isLegacyDetectionClass;
|
|
14380
15209
|
exports.isLegitimateCategory = isLegitimateCategory;
|
|
14381
15210
|
exports.isLimitExceeded = isLimitExceeded;
|
|
@@ -14383,7 +15212,9 @@ exports.isPassThroughAction = isPassThroughAction;
|
|
|
14383
15212
|
exports.isPrivateOrReservedHost = isPrivateOrReservedHost;
|
|
14384
15213
|
exports.isSupportedAuthType = isSupportedAuthType;
|
|
14385
15214
|
exports.isTraditionalBot = isTraditionalBot;
|
|
15215
|
+
exports.isValidAuthorizationHost = isValidAuthorizationHost;
|
|
14386
15216
|
exports.isValidFingerprintResponse = isValidFingerprintResponse;
|
|
15217
|
+
exports.isValidMcpiOrgSlug = isValidMcpiOrgSlug;
|
|
14387
15218
|
exports.isValidWasmDetectionResult = isValidWasmDetectionResult;
|
|
14388
15219
|
exports.isValidWasmRequestMetadata = isValidWasmRequestMetadata;
|
|
14389
15220
|
exports.loadRulesAsync = loadRulesAsync;
|
|
@@ -14408,10 +15239,16 @@ exports.parseSigningKey = parseSigningKey;
|
|
|
14408
15239
|
exports.partial = partial;
|
|
14409
15240
|
exports.passwordSchema = passwordSchema;
|
|
14410
15241
|
exports.projectResetRequestSchema = projectResetRequestSchema;
|
|
15242
|
+
exports.requestCarriesDelegationProof = requestCarriesDelegationProof;
|
|
15243
|
+
exports.requiredScopesForRequest = requiredScopesForRequest;
|
|
14411
15244
|
exports.resetPasswordSchema = resetPasswordSchema;
|
|
14412
15245
|
exports.resetPolicyFetcher = resetPolicyFetcher;
|
|
15246
|
+
exports.resolveAuthorizationHost = resolveAuthorizationHost;
|
|
15247
|
+
exports.resolveTrustedDelegationRoots = resolveTrustedDelegationRoots;
|
|
14413
15248
|
exports.safeParsePolicyConfig = safeParsePolicyConfig;
|
|
14414
15249
|
exports.safeUrl = safeUrl;
|
|
15250
|
+
exports.selectBodyReadable200 = selectBodyReadable200;
|
|
15251
|
+
exports.serveBodyReadable200 = serveBodyReadable200;
|
|
14415
15252
|
exports.signInSchema = signInSchema;
|
|
14416
15253
|
exports.signMcpiEnvelope = signMcpiEnvelope;
|
|
14417
15254
|
exports.signUpSchema = signUpSchema;
|
|
@@ -14421,9 +15258,11 @@ exports.supportsHeaders = supportsHeaders;
|
|
|
14421
15258
|
exports.supportsServerEnhanced = supportsServerEnhanced;
|
|
14422
15259
|
exports.testPattern = testPattern;
|
|
14423
15260
|
exports.testPatterns = testPatterns;
|
|
15261
|
+
exports.toBareHost = toBareHost;
|
|
14424
15262
|
exports.toPercent = toPercent;
|
|
14425
15263
|
exports.toProviderRegistryFormat = toProviderRegistryFormat;
|
|
14426
15264
|
exports.toWasmRequestMetadata = toWasmRequestMetadata;
|
|
15265
|
+
exports.unescapeCedarString = unescapeCedarString;
|
|
14427
15266
|
exports.updateStepsState = updateStepsState;
|
|
14428
15267
|
exports.upstreamDiscoveryErrorSchema = upstreamDiscoveryErrorSchema;
|
|
14429
15268
|
exports.upstreamServerInputSchema = upstreamServerInputSchema;
|
|
@@ -14436,6 +15275,7 @@ exports.validateOrThrow = validateOrThrow;
|
|
|
14436
15275
|
exports.validateOrganizationName = validateOrganizationName;
|
|
14437
15276
|
exports.validateRules = validateRules;
|
|
14438
15277
|
exports.validateRulesLoose = validateRulesLoose;
|
|
15278
|
+
exports.validateStepUpQuorum = validateStepUpQuorum;
|
|
14439
15279
|
exports.vaultResolveDataSchema = vaultResolveDataSchema;
|
|
14440
15280
|
exports.vaultResolveErrorSchema = vaultResolveErrorSchema;
|
|
14441
15281
|
exports.vaultResolveMetaSchema = vaultResolveMetaSchema;
|