@weaveintel/core 0.0.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/README.md +91 -0
- package/dist/a2a.d.ts +304 -0
- package/dist/a2a.d.ts.map +1 -0
- package/dist/a2a.js +68 -0
- package/dist/a2a.js.map +1 -0
- package/dist/admin-capabilities.d.ts +60 -0
- package/dist/admin-capabilities.d.ts.map +1 -0
- package/dist/admin-capabilities.js +31 -0
- package/dist/admin-capabilities.js.map +1 -0
- package/dist/agents.d.ts +214 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/agents.js +12 -0
- package/dist/agents.js.map +1 -0
- package/dist/artifacts.d.ts +70 -0
- package/dist/artifacts.d.ts.map +1 -0
- package/dist/artifacts.js +5 -0
- package/dist/artifacts.js.map +1 -0
- package/dist/cache.d.ts +177 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +9 -0
- package/dist/cache.js.map +1 -0
- package/dist/callables.d.ts +34 -0
- package/dist/callables.d.ts.map +1 -0
- package/dist/callables.js +35 -0
- package/dist/callables.js.map +1 -0
- package/dist/capabilities.d.ts +77 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +82 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/capability-policy.d.ts +41 -0
- package/dist/capability-policy.d.ts.map +1 -0
- package/dist/capability-policy.js +34 -0
- package/dist/capability-policy.js.map +1 -0
- package/dist/collaboration.d.ts +45 -0
- package/dist/collaboration.d.ts.map +1 -0
- package/dist/collaboration.js +5 -0
- package/dist/collaboration.js.map +1 -0
- package/dist/compliance.d.ts +71 -0
- package/dist/compliance.d.ts.map +1 -0
- package/dist/compliance.js +5 -0
- package/dist/compliance.js.map +1 -0
- package/dist/connectors.d.ts +109 -0
- package/dist/connectors.d.ts.map +1 -0
- package/dist/connectors.js +24 -0
- package/dist/connectors.js.map +1 -0
- package/dist/context.d.ts +52 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +70 -0
- package/dist/context.js.map +1 -0
- package/dist/contracts.d.ts +70 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +5 -0
- package/dist/contracts.js.map +1 -0
- package/dist/documents.d.ts +55 -0
- package/dist/documents.d.ts.map +1 -0
- package/dist/documents.js +9 -0
- package/dist/documents.js.map +1 -0
- package/dist/error-classifier.d.ts +67 -0
- package/dist/error-classifier.d.ts.map +1 -0
- package/dist/error-classifier.js +129 -0
- package/dist/error-classifier.js.map +1 -0
- package/dist/errors.d.ts +27 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +63 -0
- package/dist/errors.js.map +1 -0
- package/dist/evals.d.ts +55 -0
- package/dist/evals.d.ts.map +1 -0
- package/dist/evals.js +9 -0
- package/dist/evals.js.map +1 -0
- package/dist/events.d.ts +60 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +108 -0
- package/dist/events.js.map +1 -0
- package/dist/extraction.d.ts +71 -0
- package/dist/extraction.d.ts.map +1 -0
- package/dist/extraction.js +5 -0
- package/dist/extraction.js.map +1 -0
- package/dist/files.d.ts +39 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +9 -0
- package/dist/files.js.map +1 -0
- package/dist/finetuning.d.ts +58 -0
- package/dist/finetuning.d.ts.map +1 -0
- package/dist/finetuning.js +9 -0
- package/dist/finetuning.js.map +1 -0
- package/dist/graph.d.ts +70 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +5 -0
- package/dist/graph.js.map +1 -0
- package/dist/guardrails.d.ts +221 -0
- package/dist/guardrails.d.ts.map +1 -0
- package/dist/guardrails.js +2 -0
- package/dist/guardrails.js.map +1 -0
- package/dist/hardened-fetch.d.ts +80 -0
- package/dist/hardened-fetch.d.ts.map +1 -0
- package/dist/hardened-fetch.js +251 -0
- package/dist/hardened-fetch.js.map +1 -0
- package/dist/human-tasks.d.ts +141 -0
- package/dist/human-tasks.d.ts.map +1 -0
- package/dist/human-tasks.js +5 -0
- package/dist/human-tasks.js.map +1 -0
- package/dist/identity.d.ts +53 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +5 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +66 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +163 -0
- package/dist/index.js.map +1 -0
- package/dist/json-patch.d.ts +72 -0
- package/dist/json-patch.d.ts.map +1 -0
- package/dist/json-patch.js +239 -0
- package/dist/json-patch.js.map +1 -0
- package/dist/logger.d.ts +29 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +74 -0
- package/dist/logger.js.map +1 -0
- package/dist/managed-vectorstore.d.ts +88 -0
- package/dist/managed-vectorstore.d.ts.map +1 -0
- package/dist/managed-vectorstore.js +10 -0
- package/dist/managed-vectorstore.js.map +1 -0
- package/dist/mcp.d.ts +195 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +9 -0
- package/dist/mcp.js.map +1 -0
- package/dist/memory.d.ts +152 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +10 -0
- package/dist/memory.js.map +1 -0
- package/dist/middleware.d.ts +40 -0
- package/dist/middleware.d.ts.map +1 -0
- package/dist/middleware.js +79 -0
- package/dist/middleware.js.map +1 -0
- package/dist/models.d.ts +279 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +12 -0
- package/dist/models.js.map +1 -0
- package/dist/moderation.d.ts +39 -0
- package/dist/moderation.d.ts.map +1 -0
- package/dist/moderation.js +10 -0
- package/dist/moderation.js.map +1 -0
- package/dist/net-guard.d.ts +60 -0
- package/dist/net-guard.d.ts.map +1 -0
- package/dist/net-guard.js +250 -0
- package/dist/net-guard.js.map +1 -0
- package/dist/notifications.d.ts +121 -0
- package/dist/notifications.d.ts.map +1 -0
- package/dist/notifications.js +12 -0
- package/dist/notifications.js.map +1 -0
- package/dist/observability-runtime.d.ts +16 -0
- package/dist/observability-runtime.d.ts.map +1 -0
- package/dist/observability-runtime.js +34 -0
- package/dist/observability-runtime.js.map +1 -0
- package/dist/observability.d.ts +130 -0
- package/dist/observability.d.ts.map +1 -0
- package/dist/observability.js +9 -0
- package/dist/observability.js.map +1 -0
- package/dist/plugins.d.ts +46 -0
- package/dist/plugins.d.ts.map +1 -0
- package/dist/plugins.js +5 -0
- package/dist/plugins.js.map +1 -0
- package/dist/prompts.d.ts +219 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +5 -0
- package/dist/prompts.js.map +1 -0
- package/dist/registry.d.ts +31 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +34 -0
- package/dist/registry.js.map +1 -0
- package/dist/reliability.d.ts +68 -0
- package/dist/reliability.d.ts.map +1 -0
- package/dist/reliability.js +5 -0
- package/dist/reliability.js.map +1 -0
- package/dist/replay.d.ts +91 -0
- package/dist/replay.d.ts.map +1 -0
- package/dist/replay.js +5 -0
- package/dist/replay.js.map +1 -0
- package/dist/responses.d.ts +273 -0
- package/dist/responses.d.ts.map +1 -0
- package/dist/responses.js +11 -0
- package/dist/responses.js.map +1 -0
- package/dist/routing.d.ts +171 -0
- package/dist/routing.d.ts.map +1 -0
- package/dist/routing.js +5 -0
- package/dist/routing.js.map +1 -0
- package/dist/run-events.d.ts +199 -0
- package/dist/run-events.d.ts.map +1 -0
- package/dist/run-events.js +88 -0
- package/dist/run-events.js.map +1 -0
- package/dist/run-journal.d.ts +66 -0
- package/dist/run-journal.d.ts.map +1 -0
- package/dist/run-journal.js +153 -0
- package/dist/run-journal.js.map +1 -0
- package/dist/run-registry.d.ts +49 -0
- package/dist/run-registry.d.ts.map +1 -0
- package/dist/run-registry.js +154 -0
- package/dist/run-registry.js.map +1 -0
- package/dist/run-substrate-contract.d.ts +48 -0
- package/dist/run-substrate-contract.d.ts.map +1 -0
- package/dist/run-substrate-contract.js +124 -0
- package/dist/run-substrate-contract.js.map +1 -0
- package/dist/runs.d.ts +94 -0
- package/dist/runs.d.ts.map +1 -0
- package/dist/runs.js +12 -0
- package/dist/runs.js.map +1 -0
- package/dist/runtime.d.ts +665 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +436 -0
- package/dist/runtime.js.map +1 -0
- package/dist/sandbox.d.ts +50 -0
- package/dist/sandbox.d.ts.map +1 -0
- package/dist/sandbox.js +5 -0
- package/dist/sandbox.js.map +1 -0
- package/dist/secrets.d.ts +34 -0
- package/dist/secrets.d.ts.map +1 -0
- package/dist/secrets.js +68 -0
- package/dist/secrets.js.map +1 -0
- package/dist/security.d.ts +97 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/security.js +9 -0
- package/dist/security.js.map +1 -0
- package/dist/sse-parser.d.ts +67 -0
- package/dist/sse-parser.d.ts.map +1 -0
- package/dist/sse-parser.js +156 -0
- package/dist/sse-parser.js.map +1 -0
- package/dist/sse-writer.d.ts +63 -0
- package/dist/sse-writer.d.ts.map +1 -0
- package/dist/sse-writer.js +87 -0
- package/dist/sse-writer.js.map +1 -0
- package/dist/surface-catalog.d.ts +68 -0
- package/dist/surface-catalog.d.ts.map +1 -0
- package/dist/surface-catalog.js +13 -0
- package/dist/surface-catalog.js.map +1 -0
- package/dist/tenancy.d.ts +67 -0
- package/dist/tenancy.d.ts.map +1 -0
- package/dist/tenancy.js +5 -0
- package/dist/tenancy.js.map +1 -0
- package/dist/tool-lifecycle.d.ts +118 -0
- package/dist/tool-lifecycle.d.ts.map +1 -0
- package/dist/tool-lifecycle.js +5 -0
- package/dist/tool-lifecycle.js.map +1 -0
- package/dist/tools.d.ts +96 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +71 -0
- package/dist/tools.js.map +1 -0
- package/dist/triggers.d.ts +48 -0
- package/dist/triggers.d.ts.map +1 -0
- package/dist/triggers.js +5 -0
- package/dist/triggers.js.map +1 -0
- package/dist/ui-events.d.ts +96 -0
- package/dist/ui-events.d.ts.map +1 -0
- package/dist/ui-events.js +5 -0
- package/dist/ui-events.js.map +1 -0
- package/dist/uuid.d.ts +27 -0
- package/dist/uuid.d.ts.map +1 -0
- package/dist/uuid.js +54 -0
- package/dist/uuid.js.map +1 -0
- package/dist/vectorstore.d.ts +76 -0
- package/dist/vectorstore.d.ts.map +1 -0
- package/dist/vectorstore.js +9 -0
- package/dist/vectorstore.js.map +1 -0
- package/dist/workflows.d.ts +554 -0
- package/dist/workflows.d.ts.map +1 -0
- package/dist/workflows.js +29 -0
- package/dist/workflows.js.map +1 -0
- package/package.json +33 -0
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @weaveintel/core — Guardrail & governance contracts
|
|
3
|
+
*/
|
|
4
|
+
import type { Model, EmbeddingModel } from './models.js';
|
|
5
|
+
import type { ModerationModel } from './moderation.js';
|
|
6
|
+
/**
|
|
7
|
+
* M-8: `'skipped'` is a distinct outcome for guardrails that were bypassed
|
|
8
|
+
* (budget exhausted, condition not met) rather than actively evaluated.
|
|
9
|
+
* Callers with a strict security posture should treat `'skipped'` as `'deny'`
|
|
10
|
+
* via the `budgetExhaustedPolicy` pipeline option; lenient callers can treat it
|
|
11
|
+
* as `'allow'`. Never conflate `'skipped'` with `'allow'` in audit logs — the
|
|
12
|
+
* guardrail did not actually pass, it was never run.
|
|
13
|
+
*/
|
|
14
|
+
export type GuardrailDecision = 'allow' | 'deny' | 'warn' | 'skipped';
|
|
15
|
+
export type GuardrailStage = 'pre-execution' | 'mid-execution' | 'post-execution';
|
|
16
|
+
export type GuardrailType = 'regex' | 'blocklist' | 'length' | 'schema' | 'model-graded' | 'custom';
|
|
17
|
+
export interface GuardrailResult {
|
|
18
|
+
decision: GuardrailDecision;
|
|
19
|
+
guardrailId: string;
|
|
20
|
+
explanation?: string;
|
|
21
|
+
confidence?: number;
|
|
22
|
+
metadata?: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
export interface GuardrailEvaluationContext {
|
|
25
|
+
userInput?: string;
|
|
26
|
+
assistantOutput?: string;
|
|
27
|
+
/** Tool call / delegation results that ground the assistant's response. When present,
|
|
28
|
+
* the grounding-overlap check uses this as the reference instead of the raw userInput,
|
|
29
|
+
* since a tool-backed answer is factually grounded regardless of lexical similarity to the query. */
|
|
30
|
+
toolEvidence?: string;
|
|
31
|
+
action?: string;
|
|
32
|
+
previousResults?: GuardrailResult[];
|
|
33
|
+
metadata?: Record<string, unknown>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* JSON-serialisable condition tree that controls when a guardrail fires.
|
|
37
|
+
* null / absent means "always run" (backward-compatible default).
|
|
38
|
+
* Composition nodes short-circuit: `any` stops on first true, `all` stops on first false.
|
|
39
|
+
*/
|
|
40
|
+
export type ConditionNode = {
|
|
41
|
+
all: ConditionNode[];
|
|
42
|
+
} | {
|
|
43
|
+
any: ConditionNode[];
|
|
44
|
+
} | {
|
|
45
|
+
not: ConditionNode;
|
|
46
|
+
} | {
|
|
47
|
+
chat_mode: string[];
|
|
48
|
+
} | {
|
|
49
|
+
persona: string[];
|
|
50
|
+
} | {
|
|
51
|
+
risk_level: string[];
|
|
52
|
+
} | {
|
|
53
|
+
prior_has_warn: boolean;
|
|
54
|
+
} | {
|
|
55
|
+
prior_has_cognitive_warn: boolean;
|
|
56
|
+
} | {
|
|
57
|
+
prior_has_injection_warn: boolean;
|
|
58
|
+
} | {
|
|
59
|
+
turn_has_tool_calls: boolean;
|
|
60
|
+
} | {
|
|
61
|
+
turn_number_gt: number;
|
|
62
|
+
} | {
|
|
63
|
+
input_length_gt: number;
|
|
64
|
+
} | {
|
|
65
|
+
input_has_code: boolean;
|
|
66
|
+
} | {
|
|
67
|
+
input_has_urls: boolean;
|
|
68
|
+
} | {
|
|
69
|
+
input_has_base64: boolean;
|
|
70
|
+
} | {
|
|
71
|
+
input_has_structured_data: boolean;
|
|
72
|
+
} | {
|
|
73
|
+
input_has_decision_language: boolean;
|
|
74
|
+
} | {
|
|
75
|
+
input_has_validation_seeking: boolean;
|
|
76
|
+
} | {
|
|
77
|
+
input_has_factual_question: boolean;
|
|
78
|
+
} | {
|
|
79
|
+
input_has_instruction_override: boolean;
|
|
80
|
+
} | {
|
|
81
|
+
input_has_sensitive_pattern: boolean;
|
|
82
|
+
} | {
|
|
83
|
+
output_length_gt: number;
|
|
84
|
+
} | {
|
|
85
|
+
output_has_code_blocks: boolean;
|
|
86
|
+
} | {
|
|
87
|
+
output_has_factual_claims: boolean;
|
|
88
|
+
} | {
|
|
89
|
+
output_has_advice: boolean;
|
|
90
|
+
} | {
|
|
91
|
+
output_has_credential_patterns: boolean;
|
|
92
|
+
} | {
|
|
93
|
+
output_has_tool_evidence: boolean;
|
|
94
|
+
} | {
|
|
95
|
+
output_has_urls: boolean;
|
|
96
|
+
} | {
|
|
97
|
+
tool_category_in: string[];
|
|
98
|
+
};
|
|
99
|
+
export interface Guardrail {
|
|
100
|
+
id: string;
|
|
101
|
+
name: string;
|
|
102
|
+
description?: string;
|
|
103
|
+
type: GuardrailType;
|
|
104
|
+
stage: GuardrailStage;
|
|
105
|
+
enabled: boolean;
|
|
106
|
+
config: Record<string, unknown>;
|
|
107
|
+
priority?: number;
|
|
108
|
+
/** JSON condition tree. null/absent = always run. */
|
|
109
|
+
triggerConditions?: ConditionNode | null;
|
|
110
|
+
/** Human-readable summary of the condition shown in the admin panel. */
|
|
111
|
+
triggerDescription?: string | null;
|
|
112
|
+
createdAt?: string;
|
|
113
|
+
updatedAt?: string;
|
|
114
|
+
}
|
|
115
|
+
export interface GuardrailPipeline {
|
|
116
|
+
id: string;
|
|
117
|
+
name: string;
|
|
118
|
+
guardrails: Guardrail[];
|
|
119
|
+
shortCircuitOnDeny: boolean;
|
|
120
|
+
evaluate(input: unknown, stage: GuardrailStage, context?: GuardrailEvaluationContext): Promise<GuardrailResult[]>;
|
|
121
|
+
}
|
|
122
|
+
export type RiskLevel = 'low' | 'medium' | 'high' | 'critical';
|
|
123
|
+
export interface RiskClassifier {
|
|
124
|
+
classify(action: string, context?: Record<string, unknown>): Promise<{
|
|
125
|
+
level: RiskLevel;
|
|
126
|
+
explanation: string;
|
|
127
|
+
}>;
|
|
128
|
+
}
|
|
129
|
+
export interface ConfidenceGate {
|
|
130
|
+
threshold: number;
|
|
131
|
+
action: 'block' | 'escalate' | 'warn' | 'log';
|
|
132
|
+
evaluate(confidence: number): GuardrailDecision;
|
|
133
|
+
}
|
|
134
|
+
export interface ActionGate {
|
|
135
|
+
allowedActions: string[];
|
|
136
|
+
deniedActions: string[];
|
|
137
|
+
evaluate(action: string): GuardrailDecision;
|
|
138
|
+
}
|
|
139
|
+
export interface GovernanceRule {
|
|
140
|
+
id: string;
|
|
141
|
+
name: string;
|
|
142
|
+
description?: string;
|
|
143
|
+
condition: string;
|
|
144
|
+
action: GuardrailDecision;
|
|
145
|
+
enabled: boolean;
|
|
146
|
+
priority: number;
|
|
147
|
+
}
|
|
148
|
+
export interface GovernanceContext {
|
|
149
|
+
tenantId?: string;
|
|
150
|
+
userId?: string;
|
|
151
|
+
agentId?: string;
|
|
152
|
+
rules: GovernanceRule[];
|
|
153
|
+
evaluate(input: unknown): Promise<GuardrailResult[]>;
|
|
154
|
+
}
|
|
155
|
+
export interface RuntimePolicy {
|
|
156
|
+
id: string;
|
|
157
|
+
name: string;
|
|
158
|
+
type: 'cost-ceiling' | 'token-limit' | 'rate-limit' | 'content-filter' | 'tool-restriction';
|
|
159
|
+
config: Record<string, unknown>;
|
|
160
|
+
enabled: boolean;
|
|
161
|
+
}
|
|
162
|
+
/** Extended evaluation context that carries optional model references for
|
|
163
|
+
* async (model-graded) guardrail evaluators. Backward-compatible superset of
|
|
164
|
+
* `GuardrailEvaluationContext`; sync evaluators ignore the extra fields. */
|
|
165
|
+
export interface AsyncGuardrailContext extends GuardrailEvaluationContext {
|
|
166
|
+
/** LLM used for llm-judge and similar verdict-generation evaluators. */
|
|
167
|
+
readonly model?: Model;
|
|
168
|
+
/** Moderation API client for content-safety classification. */
|
|
169
|
+
readonly moderationModel?: ModerationModel;
|
|
170
|
+
/** Embedding model for semantic-grounding similarity checks. */
|
|
171
|
+
readonly embeddingModel?: EmbeddingModel;
|
|
172
|
+
}
|
|
173
|
+
export interface EscalationTrigger {
|
|
174
|
+
/** Minimum accumulated warn-decision count to trigger escalation. */
|
|
175
|
+
readonly minWarnCount?: number;
|
|
176
|
+
/** Guardrail category names (e.g. 'cognitive') that count toward the threshold. */
|
|
177
|
+
readonly categories?: readonly string[];
|
|
178
|
+
/** Risk levels that trigger escalation regardless of warn count. */
|
|
179
|
+
readonly riskLevels?: readonly RiskLevel[];
|
|
180
|
+
}
|
|
181
|
+
export interface EscalationPolicy {
|
|
182
|
+
readonly id: string;
|
|
183
|
+
readonly name: string;
|
|
184
|
+
readonly description?: string;
|
|
185
|
+
readonly enabled: boolean;
|
|
186
|
+
readonly trigger: EscalationTrigger;
|
|
187
|
+
/** 'block' halts the turn. 'require-approval' blocks pending a human task. */
|
|
188
|
+
readonly onEscalate: 'block' | 'require-approval';
|
|
189
|
+
}
|
|
190
|
+
export interface EscalationResult {
|
|
191
|
+
readonly escalated: boolean;
|
|
192
|
+
readonly decision: GuardrailDecision;
|
|
193
|
+
readonly policy?: EscalationPolicy;
|
|
194
|
+
readonly taskId?: string;
|
|
195
|
+
readonly reason?: string;
|
|
196
|
+
}
|
|
197
|
+
export interface GuardrailResolverContext {
|
|
198
|
+
readonly tenantId?: string;
|
|
199
|
+
readonly persona?: string;
|
|
200
|
+
readonly stage: GuardrailStage;
|
|
201
|
+
}
|
|
202
|
+
export interface GuardrailResolver {
|
|
203
|
+
resolve(ctx: GuardrailResolverContext): Promise<Guardrail[]>;
|
|
204
|
+
}
|
|
205
|
+
export interface GuardrailRevision {
|
|
206
|
+
readonly id: string;
|
|
207
|
+
readonly guardrailId: string;
|
|
208
|
+
readonly version: number;
|
|
209
|
+
readonly snapshot: Guardrail;
|
|
210
|
+
readonly before?: Guardrail;
|
|
211
|
+
readonly actor: string;
|
|
212
|
+
readonly reason: string;
|
|
213
|
+
readonly timestamp: string;
|
|
214
|
+
}
|
|
215
|
+
export interface GuardrailRevisionStore {
|
|
216
|
+
record(revision: GuardrailRevision): Promise<void>;
|
|
217
|
+
list(guardrailId: string): Promise<GuardrailRevision[]>;
|
|
218
|
+
/** Returns the revision active at or before the given ISO timestamp. */
|
|
219
|
+
atTime(guardrailId: string, timestamp: string): Promise<GuardrailRevision | undefined>;
|
|
220
|
+
}
|
|
221
|
+
//# sourceMappingURL=guardrails.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guardrails.d.ts","sourceRoot":"","sources":["../src/guardrails.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAIvD;;;;;;;GAOG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AACtE,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG,eAAe,GAAG,gBAAgB,CAAC;AAClF,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,cAAc,GAAG,QAAQ,CAAC;AAEpG,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,0BAA0B;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;0GAEsG;IACtG,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,eAAe,EAAE,CAAC;IACpC,QAAQ,CAAC,E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AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,GAAG,EAAE,wBAAwB,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;CAC9D;AAID,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnD,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACxD,wEAAwE;IACxE,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAAC;CACxF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guardrails.js","sourceRoot":"","sources":["../src/guardrails.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single hardened egress client for the framework.
|
|
3
|
+
*
|
|
4
|
+
* Composes the five outbound-safety primitives every package needs:
|
|
5
|
+
* 1. SSRF guard — `assertSafeOutboundUrl` (cloud metadata, RFC1918, DNS rebinding)
|
|
6
|
+
* 2. Redirect re-validation — `followRedirectsSafely` (manual 3xx walk, each hop re-validated)
|
|
7
|
+
* 3. TLS / HTTPS floor — http:// permitted only for loopback when `allowLoopback`
|
|
8
|
+
* 4. Outer timeout — `AbortSignal.timeout(timeoutMs)`, composed with caller signal
|
|
9
|
+
* 5. Response size cap — streaming wrapper that errors past `maxBytes`
|
|
10
|
+
*
|
|
11
|
+
* Phase 1 of the enterprise-hardening plan: this REPLACES the 13 hand-rolled
|
|
12
|
+
* `_fetch.ts` files scattered across providers / tools / connectors. Each of
|
|
13
|
+
* those packages should now expose a thin closure built via `createHardenedFetch`
|
|
14
|
+
* with its own error tag and defaults — never re-implement the pipeline.
|
|
15
|
+
*
|
|
16
|
+
* Long-lived streams (SSE, NDJSON, chunked download) MUST NOT pass through the
|
|
17
|
+
* outer timeout. Use `hardenedFetchNoTimeout` (or set `timeoutMs: 0`) and
|
|
18
|
+
* consume `response.body` directly — the SSRF guard + redirect re-validation
|
|
19
|
+
* still apply.
|
|
20
|
+
*
|
|
21
|
+
* Depends only on `@weaveintel/core` itself (`net-guard`) + node built-ins.
|
|
22
|
+
*/
|
|
23
|
+
import { type OutboundUrlPolicy } from './net-guard.js';
|
|
24
|
+
export interface HardenedFetchOptions {
|
|
25
|
+
/** Outer wall-clock timeout in ms. Default: 60_000. Use 0 to disable (streaming). */
|
|
26
|
+
timeoutMs?: number;
|
|
27
|
+
/** Max bytes the response body may yield. Default: 50 MiB. Use 0 to disable. */
|
|
28
|
+
maxBytes?: number;
|
|
29
|
+
/** Enforce HTTPS + SSRF guard + redirect re-validation. Default: true. */
|
|
30
|
+
enforceHttps?: boolean;
|
|
31
|
+
/** Outbound URL policy forwarded to the SSRF guard. */
|
|
32
|
+
policy?: OutboundUrlPolicy;
|
|
33
|
+
/** Override the `redirect` mode. Default: 'manual' so the guard can re-validate. */
|
|
34
|
+
redirect?: RequestRedirect;
|
|
35
|
+
}
|
|
36
|
+
export interface HardenedFetchDefaults {
|
|
37
|
+
/** Error tag inserted into thrown messages (e.g. 'provider-openai'). REQUIRED. */
|
|
38
|
+
errorTag: string;
|
|
39
|
+
/** Default timeoutMs for this client. Default: 60_000. */
|
|
40
|
+
timeoutMs?: number;
|
|
41
|
+
/** Default maxBytes for this client. Default: 50 MiB. */
|
|
42
|
+
maxBytes?: number;
|
|
43
|
+
/** Default policy for the SSRF guard (extra blocked/allowed hosts, etc.). */
|
|
44
|
+
policy?: Omit<OutboundUrlPolicy, 'errorTag'>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Validate a URL with the shared SSRF guard. Streaming call sites that bypass
|
|
48
|
+
* `hardenedFetch` (because they need to consume `body.getReader()` directly)
|
|
49
|
+
* MUST still call this before opening the connection.
|
|
50
|
+
*
|
|
51
|
+
* Async — performs DNS resolution. Callers MUST await.
|
|
52
|
+
*/
|
|
53
|
+
export declare function assertSafeForEgress(url: string, defaults: HardenedFetchDefaults): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* The single hardened fetch. Per-package callers should `createHardenedFetch`
|
|
56
|
+
* with their `errorTag` and per-package defaults rather than calling this raw
|
|
57
|
+
* — that way every site shares one set of guards but messages stay readable.
|
|
58
|
+
*
|
|
59
|
+
* The third argument merges `HardenedFetchDefaults` (per-package identity,
|
|
60
|
+
* static defaults) and `HardenedFetchOptions` (per-call overrides) into a
|
|
61
|
+
* single object so every call site looks the same:
|
|
62
|
+
*
|
|
63
|
+
* await hardenedFetch(url, init, { errorTag: 'tools-x', timeoutMs: 0 });
|
|
64
|
+
*/
|
|
65
|
+
export declare function hardenedFetch(input: string, init?: RequestInit, opts?: HardenedFetchOptions & HardenedFetchDefaults): Promise<Response>;
|
|
66
|
+
/**
|
|
67
|
+
* Bind a `hardenedFetch` closure with per-package defaults. The canonical entry
|
|
68
|
+
* point for every `_fetch.ts` in the workspace. Returns:
|
|
69
|
+
* - `fetch(input, init, opts?)` — the standard hardened request/response path
|
|
70
|
+
* - `fetchStream(input, init)` — SSRF + redirect re-validated, but NO outer
|
|
71
|
+
* timeout + NO size cap (use for SSE / NDJSON / chunked transfer)
|
|
72
|
+
* - `assertSafe(url)` — just the SSRF guard for streaming call sites
|
|
73
|
+
* that bypass the wrapper entirely
|
|
74
|
+
*/
|
|
75
|
+
export declare function createHardenedFetch(defaults: HardenedFetchDefaults): {
|
|
76
|
+
fetch: (input: string, init?: RequestInit, opts?: HardenedFetchOptions) => Promise<Response>;
|
|
77
|
+
fetchStream: (input: string, init?: RequestInit) => Promise<Response>;
|
|
78
|
+
assertSafe: (url: string) => Promise<void>;
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=hardened-fetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hardened-fetch.d.ts","sourceRoot":"","sources":["../src/hardened-fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EACL,KAAK,iBAAiB,EAIvB,MAAM,gBAAgB,CAAC;AAqFxB,MAAM,WAAW,oBAAoB;IACnC,qFAAqF;IACrF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,uDAAuD;IACvD,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,oFAAoF;IACpF,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC5B;AAED,MAAM,WAAW,qBAAqB;IACpC,kFAAkF;IAClF,QAAQ,EAAE,MAAM,CAAC;IACjB,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,MAAM,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;CAC9C;AA2DD;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,qBAAqB,GAC9B,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,aAAa,CACjC,KAAK,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,WAAW,EAClB,IAAI,GAAE,oBAAoB,GAAG,qBAAsD,GAClF,OAAO,CAAC,QAAQ,CAAC,CAuDnB;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,qBAAqB,GAAG;IACpE,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,oBAAoB,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7F,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACtE,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5C,CAeA"}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single hardened egress client for the framework.
|
|
3
|
+
*
|
|
4
|
+
* Composes the five outbound-safety primitives every package needs:
|
|
5
|
+
* 1. SSRF guard — `assertSafeOutboundUrl` (cloud metadata, RFC1918, DNS rebinding)
|
|
6
|
+
* 2. Redirect re-validation — `followRedirectsSafely` (manual 3xx walk, each hop re-validated)
|
|
7
|
+
* 3. TLS / HTTPS floor — http:// permitted only for loopback when `allowLoopback`
|
|
8
|
+
* 4. Outer timeout — `AbortSignal.timeout(timeoutMs)`, composed with caller signal
|
|
9
|
+
* 5. Response size cap — streaming wrapper that errors past `maxBytes`
|
|
10
|
+
*
|
|
11
|
+
* Phase 1 of the enterprise-hardening plan: this REPLACES the 13 hand-rolled
|
|
12
|
+
* `_fetch.ts` files scattered across providers / tools / connectors. Each of
|
|
13
|
+
* those packages should now expose a thin closure built via `createHardenedFetch`
|
|
14
|
+
* with its own error tag and defaults — never re-implement the pipeline.
|
|
15
|
+
*
|
|
16
|
+
* Long-lived streams (SSE, NDJSON, chunked download) MUST NOT pass through the
|
|
17
|
+
* outer timeout. Use `hardenedFetchNoTimeout` (or set `timeoutMs: 0`) and
|
|
18
|
+
* consume `response.body` directly — the SSRF guard + redirect re-validation
|
|
19
|
+
* still apply.
|
|
20
|
+
*
|
|
21
|
+
* Depends only on `@weaveintel/core` itself (`net-guard`) + node built-ins.
|
|
22
|
+
*/
|
|
23
|
+
import dns from 'node:dns';
|
|
24
|
+
import { assertSafeOutboundUrl, followRedirectsSafely, validateResolvedAddress, } from './net-guard.js';
|
|
25
|
+
/**
|
|
26
|
+
* Phase 5 — TOCTOU DNS-pinning dispatcher.
|
|
27
|
+
*
|
|
28
|
+
* `assertSafeOutboundUrl` resolves DNS once at validation time. Between that
|
|
29
|
+
* resolution and the actual TCP connection, an attacker who controls DNS could
|
|
30
|
+
* rebind the hostname to a private IP — the classic SSRF bypass via DNS
|
|
31
|
+
* rebinding. This factory closes that window.
|
|
32
|
+
*
|
|
33
|
+
* It creates an undici `Agent` with a custom `connect.lookup` hook. Undici
|
|
34
|
+
* calls our hook at connection time (not earlier), so the IP we validate is
|
|
35
|
+
* exactly the IP undici connects to. A rebind between the two resolutions
|
|
36
|
+
* becomes impossible.
|
|
37
|
+
*
|
|
38
|
+
* Graceful degradation: if undici is unavailable (non-Node environments or
|
|
39
|
+
* bundlers that strip it) the function returns `undefined` and callers fall
|
|
40
|
+
* back to the pre-TOCTOU behaviour — still protected by the upfront
|
|
41
|
+
* `assertSafeOutboundUrl` check.
|
|
42
|
+
*/
|
|
43
|
+
async function createSafeDispatcher(policy) {
|
|
44
|
+
let AgentCtor;
|
|
45
|
+
try {
|
|
46
|
+
const undici = await import('undici');
|
|
47
|
+
AgentCtor = undici.Agent;
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return undefined; // undici unavailable — graceful degradation
|
|
51
|
+
}
|
|
52
|
+
// Undici's connect.lookup may ask for either a single resolved address or
|
|
53
|
+
// all candidates (`all:true`). Handle both callback shapes and validate each
|
|
54
|
+
// candidate so we never pass an undefined/unsafe address to the socket layer.
|
|
55
|
+
const lookup = (hostname, options, callback) => {
|
|
56
|
+
const wantsAll = typeof options === 'object' &&
|
|
57
|
+
options !== null &&
|
|
58
|
+
'all' in options &&
|
|
59
|
+
options.all === true;
|
|
60
|
+
if (wantsAll) {
|
|
61
|
+
dns.lookup(hostname, { all: true }, (err, addresses) => {
|
|
62
|
+
if (err) {
|
|
63
|
+
callback(err);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
for (const entry of addresses) {
|
|
68
|
+
validateResolvedAddress(entry.address, policy);
|
|
69
|
+
}
|
|
70
|
+
callback(null, addresses);
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
callback(e);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
dns.lookup(hostname, (err, address, family) => {
|
|
79
|
+
if (err) {
|
|
80
|
+
callback(err);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (!address || typeof address !== 'string') {
|
|
84
|
+
callback(new TypeError(`invalid DNS lookup result for host "${hostname}"`));
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
validateResolvedAddress(address, policy);
|
|
89
|
+
callback(null, address, family);
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
callback(e);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
const agent = new AgentCtor({ connect: { lookup } });
|
|
97
|
+
return { dispatcher: agent };
|
|
98
|
+
}
|
|
99
|
+
const DEFAULT_TIMEOUT_MS = 60_000;
|
|
100
|
+
const DEFAULT_MAX_BYTES = 50 * 1024 * 1024; // 50 MiB
|
|
101
|
+
function wrapBodyWithSizeCap(body, maxBytes, errorTag) {
|
|
102
|
+
if (!body)
|
|
103
|
+
return body;
|
|
104
|
+
if (maxBytes <= 0)
|
|
105
|
+
return body;
|
|
106
|
+
let total = 0;
|
|
107
|
+
const reader = body.getReader();
|
|
108
|
+
return new ReadableStream({
|
|
109
|
+
async pull(controller) {
|
|
110
|
+
try {
|
|
111
|
+
const { value, done } = await reader.read();
|
|
112
|
+
if (done) {
|
|
113
|
+
controller.close();
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
total += value.byteLength;
|
|
117
|
+
if (total > maxBytes) {
|
|
118
|
+
await reader.cancel();
|
|
119
|
+
controller.error(new Error(`${errorTag}: response body exceeded ${maxBytes} bytes`));
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
controller.enqueue(value);
|
|
123
|
+
}
|
|
124
|
+
catch (e) {
|
|
125
|
+
controller.error(e);
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
async cancel(reason) {
|
|
129
|
+
await reader.cancel(reason);
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
function composeSignal(caller, timeoutMs) {
|
|
134
|
+
if (timeoutMs <= 0)
|
|
135
|
+
return caller ?? undefined;
|
|
136
|
+
const t = AbortSignal.timeout(timeoutMs);
|
|
137
|
+
if (!caller)
|
|
138
|
+
return t;
|
|
139
|
+
// AbortSignal.any is Node ≥20 — fall back to manual composition on older runtimes.
|
|
140
|
+
if (typeof AbortSignal.any === 'function') {
|
|
141
|
+
return AbortSignal.any([caller, t]);
|
|
142
|
+
}
|
|
143
|
+
const ctl = new AbortController();
|
|
144
|
+
const onAbort = (reason) => ctl.abort(reason);
|
|
145
|
+
if (caller.aborted)
|
|
146
|
+
ctl.abort(caller.reason);
|
|
147
|
+
else
|
|
148
|
+
caller.addEventListener('abort', () => onAbort(caller.reason), { once: true });
|
|
149
|
+
if (t.aborted)
|
|
150
|
+
ctl.abort(t.reason);
|
|
151
|
+
else
|
|
152
|
+
t.addEventListener('abort', () => onAbort(t.reason), { once: true });
|
|
153
|
+
return ctl.signal;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Validate a URL with the shared SSRF guard. Streaming call sites that bypass
|
|
157
|
+
* `hardenedFetch` (because they need to consume `body.getReader()` directly)
|
|
158
|
+
* MUST still call this before opening the connection.
|
|
159
|
+
*
|
|
160
|
+
* Async — performs DNS resolution. Callers MUST await.
|
|
161
|
+
*/
|
|
162
|
+
export async function assertSafeForEgress(url, defaults) {
|
|
163
|
+
await assertSafeOutboundUrl(url, { ...(defaults.policy ?? {}), errorTag: defaults.errorTag });
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* The single hardened fetch. Per-package callers should `createHardenedFetch`
|
|
167
|
+
* with their `errorTag` and per-package defaults rather than calling this raw
|
|
168
|
+
* — that way every site shares one set of guards but messages stay readable.
|
|
169
|
+
*
|
|
170
|
+
* The third argument merges `HardenedFetchDefaults` (per-package identity,
|
|
171
|
+
* static defaults) and `HardenedFetchOptions` (per-call overrides) into a
|
|
172
|
+
* single object so every call site looks the same:
|
|
173
|
+
*
|
|
174
|
+
* await hardenedFetch(url, init, { errorTag: 'tools-x', timeoutMs: 0 });
|
|
175
|
+
*/
|
|
176
|
+
export async function hardenedFetch(input, init, opts = { errorTag: 'hardened-fetch' }) {
|
|
177
|
+
const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
178
|
+
const maxBytes = opts.maxBytes ?? DEFAULT_MAX_BYTES;
|
|
179
|
+
const enforceHttps = opts.enforceHttps ?? true;
|
|
180
|
+
const errorTag = opts.errorTag;
|
|
181
|
+
const policy = {
|
|
182
|
+
...(opts.policy ?? {}),
|
|
183
|
+
errorTag,
|
|
184
|
+
};
|
|
185
|
+
if (enforceHttps)
|
|
186
|
+
await assertSafeOutboundUrl(input, policy);
|
|
187
|
+
// Phase 5 — attach a DNS-pinning dispatcher so the IP validated above is the
|
|
188
|
+
// same IP undici connects to, closing the TOCTOU DNS-rebinding window.
|
|
189
|
+
// Gracefully absent when undici is unavailable.
|
|
190
|
+
const safeDispatcher = enforceHttps ? await createSafeDispatcher(policy) : undefined;
|
|
191
|
+
const callerSignal = (init?.signal ?? null);
|
|
192
|
+
const signal = composeSignal(callerSignal, timeoutMs);
|
|
193
|
+
const composed = {
|
|
194
|
+
...(init ?? {}),
|
|
195
|
+
redirect: opts.redirect ?? 'manual',
|
|
196
|
+
...(signal ? { signal } : {}),
|
|
197
|
+
...(safeDispatcher ?? {}),
|
|
198
|
+
};
|
|
199
|
+
const resp0 = await fetch(input, composed);
|
|
200
|
+
const resp = enforceHttps
|
|
201
|
+
? await followRedirectsSafely(resp0, init, signal, policy)
|
|
202
|
+
: resp0;
|
|
203
|
+
// When no size cap is requested (maxBytes <= 0 — the streaming / escape-hatch
|
|
204
|
+
// path), return the response untouched. Re-wrapping exists only to install the
|
|
205
|
+
// size-cap stream; doing it here would needlessly disturb/lock the body and
|
|
206
|
+
// drop the original Response's methods.
|
|
207
|
+
if (maxBytes <= 0)
|
|
208
|
+
return resp;
|
|
209
|
+
const cl = resp.headers.get('content-length');
|
|
210
|
+
if (cl) {
|
|
211
|
+
const n = Number(cl);
|
|
212
|
+
if (Number.isFinite(n) && n > maxBytes) {
|
|
213
|
+
try {
|
|
214
|
+
await resp.body?.cancel();
|
|
215
|
+
}
|
|
216
|
+
catch { /* ignore */ }
|
|
217
|
+
throw new Error(`${errorTag}: response Content-Length ${n} exceeds limit ${maxBytes}`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
const cappedBody = wrapBodyWithSizeCap(resp.body, maxBytes, errorTag);
|
|
221
|
+
return new Response(cappedBody, {
|
|
222
|
+
status: resp.status,
|
|
223
|
+
statusText: resp.statusText,
|
|
224
|
+
headers: resp.headers,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Bind a `hardenedFetch` closure with per-package defaults. The canonical entry
|
|
229
|
+
* point for every `_fetch.ts` in the workspace. Returns:
|
|
230
|
+
* - `fetch(input, init, opts?)` — the standard hardened request/response path
|
|
231
|
+
* - `fetchStream(input, init)` — SSRF + redirect re-validated, but NO outer
|
|
232
|
+
* timeout + NO size cap (use for SSE / NDJSON / chunked transfer)
|
|
233
|
+
* - `assertSafe(url)` — just the SSRF guard for streaming call sites
|
|
234
|
+
* that bypass the wrapper entirely
|
|
235
|
+
*/
|
|
236
|
+
export function createHardenedFetch(defaults) {
|
|
237
|
+
const merge = (opts = {}) => ({
|
|
238
|
+
errorTag: defaults.errorTag,
|
|
239
|
+
timeoutMs: opts.timeoutMs ?? defaults.timeoutMs,
|
|
240
|
+
maxBytes: opts.maxBytes ?? defaults.maxBytes,
|
|
241
|
+
...(opts.enforceHttps !== undefined ? { enforceHttps: opts.enforceHttps } : {}),
|
|
242
|
+
...(opts.redirect !== undefined ? { redirect: opts.redirect } : {}),
|
|
243
|
+
policy: { ...(defaults.policy ?? {}), ...(opts.policy ?? {}) },
|
|
244
|
+
});
|
|
245
|
+
return {
|
|
246
|
+
fetch: (input, init, opts) => hardenedFetch(input, init, merge(opts)),
|
|
247
|
+
fetchStream: (input, init) => hardenedFetch(input, init, merge({ timeoutMs: 0, maxBytes: 0 })),
|
|
248
|
+
assertSafe: (url) => assertSafeForEgress(url, defaults),
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=hardened-fetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hardened-fetch.js","sourceRoot":"","sources":["../src/hardened-fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAEL,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;;;;;;;;;;GAiBG;AACH,KAAK,UAAU,oBAAoB,CACjC,MAAyB;IAEzB,IAAI,SAAuE,CAAC;IAC5E,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAA8D,CAAC;QACnG,SAAS,GAAG,MAA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