ConfigManager
ConfigManager holds the server-driven configuration for Sentinel and evaluates which outbound URLs should be protected (enriched with sentinel context and/or encrypted).
Responsibilities
| Responsibility | Detail |
|---|---|
| Store config | Maintains the current SentinelConfig in memory |
| Normalise config | Coerces partial / malformed server responses to safe defaults |
| Path matching | Compiles include/exclude regex patterns and evaluates URLs |
| Expose accessors | Simple getters for enabled, thresholds, and bucket sizes |
Default Configuration
If no config has been received from the server, everything is disabled:
const DEFAULT_CONFIG: SentinelConfig = {
enabled: false,
contextSignalTypeSize: 0,
signalThresholdMs: 0,
signalThresholdSize: 0,
paths: [],
};
Config Shape
interface SentinelConfig {
enabled: boolean;
contextSignalTypeSize: number;
signalThresholdMs: number;
signalThresholdSize: number;
paths: Array<SentinelPathConfig>;
}
interface SentinelPathConfig {
includedPaths: Array<string>; // regex patterns
excludedPaths: Array<string>; // regex patterns
}
Public API
| Method | Return | Description |
|---|---|---|
update(config?) | void | Merge partial config into current state |
getConfig() | SentinelConfig | Deep-copy of current config |
isEnabled() | boolean | Whether signal collection is active |
getContextSignalTypeSize() | number | Max signals per type in the context bucket |
getSignalThresholdMs() | number | Time-based flush interval |
getSignalThresholdSize() | number | Size-based flush threshold |
shouldProtectResource(url) | boolean | Whether the URL should be sentinel-protected |
Path Matching Logic
shouldProtectResource(url) determines if an outgoing request should carry sentinel context and/or be encrypted.
Evaluation order
- Sentinel internal URLs (
/api/sen/…,/api/dfp/…) are always protected regardless of config. - If Sentinel is disabled or no path matchers are configured →
false. - Extract
pathnamefrom the URL. - For each path config:
- If
includedPathsis non-empty, the pathname must match at least one include pattern. - If matched, the pathname must not match any
excludedPathspattern.
- If
- Returns
trueon the first matching path config.
Pattern compilation
Path strings are compiled to RegExp at config update time. Invalid regex patterns are silently dropped.
Normalisation Rules
When update() receives a partial config:
| Field | Rule |
|---|---|
enabled | Must be a boolean; otherwise falls back to previous value |
contextSignalTypeSize | Coerced to Number; if NaN or negative, uses previous value |
signalThresholdMs | Same as above |
signalThresholdSize | Same as above |
paths | Must be an Array; each entry's includedPaths/excludedPaths are filtered to non-empty strings |
The server API returns threshold values as strings (e.g. "5000"); normalisation handles this via Number() coercion.
Usage Within Sentinel
ConfigManager is never used standalone. The Sentinel class calls:
this.configManager.update(config);
this.signalStore.setBucketSize(this.configManager.getContextSignalTypeSize());
this.reporter.setThresholds({
timeThresholdMs: this.configManager.getSignalThresholdMs(),
sizeThreshold: this.configManager.getSignalThresholdSize(),
});
this.configManager.isEnabled() ? this.start() : this.stop();
This happens both at initialisation and whenever the reporter returns an updated config from the server.
Last updated: 2026-02-24