@maskera/mcp 0.4.1 → 0.4.2
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 +14 -0
- package/dist/cli.js +1141 -230
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +49 -11
- package/dist/index.js +1023 -131
- package/dist/index.js.map +1 -1
- package/package.json +12 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NerRecognizer, NerOptions, RedactionProfile, RedactResult, Detector } from 'maskera';
|
|
2
|
-
import { ServerResponse, Server } from 'node:http';
|
|
2
|
+
import { ServerResponse, Server, IncomingMessage } from 'node:http';
|
|
3
3
|
|
|
4
4
|
type ApprovalMode = "automatic" | "browser" | "native";
|
|
5
5
|
type ApprovalStatus = "pending" | "approved" | "declined" | "expired" | "completed";
|
|
@@ -39,12 +39,14 @@ declare class ApprovalBroker {
|
|
|
39
39
|
tool: string;
|
|
40
40
|
reason: string;
|
|
41
41
|
sessionId?: string | null;
|
|
42
|
+
owner?: string;
|
|
42
43
|
placeholderCount: number;
|
|
43
44
|
execute: () => Promise<Record<string, unknown>>;
|
|
44
45
|
}): ApprovalSummary;
|
|
45
46
|
list(): ApprovalSummary[];
|
|
46
47
|
decide(id: string, decision: "approve" | "decline"): ApprovalSummary | null;
|
|
47
|
-
resume(id: string): Promise<ApprovalResumeResult>;
|
|
48
|
+
resume(id: string, owner?: string): Promise<ApprovalResumeResult>;
|
|
49
|
+
clearOwner(owner: string): void;
|
|
48
50
|
clearAll(): void;
|
|
49
51
|
}
|
|
50
52
|
|
|
@@ -101,6 +103,15 @@ interface MaskeraEngine {
|
|
|
101
103
|
cacheMisses: number;
|
|
102
104
|
};
|
|
103
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Folds Cyrillic homoglyphs back to their 1-to-1 Latin equivalents inside
|
|
108
|
+
* mixed-script words (e.g. `Ann\u0430`) or all-confusable tokens embedded in
|
|
109
|
+
* majority-Latin text, while leaving genuine Cyrillic prose untouched.
|
|
110
|
+
*/
|
|
111
|
+
declare function normalizeMixedScriptHomoglyphs(text: string): {
|
|
112
|
+
text: string;
|
|
113
|
+
changed: boolean;
|
|
114
|
+
};
|
|
104
115
|
/**
|
|
105
116
|
* Builds a deterministic, case-insensitive, longest-first detector for caller-
|
|
106
117
|
* supplied custom protected terms (client names, case IDs, codenames).
|
|
@@ -262,6 +273,8 @@ interface InspectedRequest {
|
|
|
262
273
|
counts: Record<string, number>;
|
|
263
274
|
/** Redacted snippets sent upstream (never raw PII). */
|
|
264
275
|
redactedPreview: string[];
|
|
276
|
+
/** Optional non-PII security warnings (e.g. uninspectable binary attachments). */
|
|
277
|
+
warnings?: string[];
|
|
265
278
|
}
|
|
266
279
|
/**
|
|
267
280
|
* In-memory ring buffer and SSE fan-out for the local proxy and MCP inspector.
|
|
@@ -370,7 +383,7 @@ declare class SessionVault {
|
|
|
370
383
|
* the same entity receives the exact same placeholder across multiple calls
|
|
371
384
|
* and files in the same session, while avoiding collisions with literal text.
|
|
372
385
|
*/
|
|
373
|
-
apply(originalInput: string, result: RedactResult, sessionId?: string): {
|
|
386
|
+
apply(originalInput: string, result: RedactResult, sessionId?: string, owner?: string): {
|
|
374
387
|
sessionId: string;
|
|
375
388
|
redacted: string;
|
|
376
389
|
counts: Record<string, number>;
|
|
@@ -380,6 +393,7 @@ declare class SessionVault {
|
|
|
380
393
|
restore(text: string, options: {
|
|
381
394
|
sessionId?: string;
|
|
382
395
|
map?: Record<string, string>;
|
|
396
|
+
owner?: string;
|
|
383
397
|
}): {
|
|
384
398
|
restored: string;
|
|
385
399
|
sessionId: string | null;
|
|
@@ -387,26 +401,29 @@ declare class SessionVault {
|
|
|
387
401
|
};
|
|
388
402
|
/**
|
|
389
403
|
* Picks the session that restores `text` when the caller named none.
|
|
390
|
-
*
|
|
391
|
-
*
|
|
392
|
-
* missing session_id can never put another document's values into a file.
|
|
404
|
+
* Confined strictly to sessions belonging to `owner` so a missing session_id
|
|
405
|
+
* can never read another client's or the proxy's vault entries.
|
|
393
406
|
*/
|
|
394
|
-
resolveSessionFor(text: string): string;
|
|
395
|
-
getMap(sessionId: string): Record<string, string>;
|
|
407
|
+
resolveSessionFor(text: string, owner?: string): string;
|
|
408
|
+
getMap(sessionId: string, owner?: string): Record<string, string>;
|
|
396
409
|
entries(): Array<{
|
|
397
410
|
sessionId: string;
|
|
398
411
|
token: string;
|
|
399
412
|
value: string;
|
|
400
413
|
}>;
|
|
401
414
|
clearAll(): void;
|
|
402
|
-
|
|
403
|
-
|
|
415
|
+
clearOwner(owner: string): number;
|
|
416
|
+
list(owner?: string): SessionSummary[];
|
|
417
|
+
clear(sessionId: string, owner?: string): boolean;
|
|
418
|
+
sizeForOwner(owner?: string): number;
|
|
404
419
|
get size(): number;
|
|
405
420
|
}
|
|
406
421
|
|
|
407
422
|
interface ProxyOptions {
|
|
408
423
|
/** Bind address. Defaults to loopback `127.0.0.1` for local safety. */
|
|
409
424
|
host?: string;
|
|
425
|
+
/** Allow binding to a non-loopback interface (default `false`; refuses LAN exposure of local vault/MCP). */
|
|
426
|
+
allowNonLoopback?: boolean;
|
|
410
427
|
/** Listening port. Defaults to `8787` (`0` picks an ephemeral port). */
|
|
411
428
|
port?: number;
|
|
412
429
|
/** Explicit upstream base URL (overrides automatic Anthropic/OpenAI routing). */
|
|
@@ -437,6 +454,8 @@ interface ProxyOptions {
|
|
|
437
454
|
customTerms?: readonly string[];
|
|
438
455
|
/** Restore placeholders in upstream responses. Default `true`. */
|
|
439
456
|
restoreResponses?: boolean;
|
|
457
|
+
/** Reject uninspectable binary attachments (images, PDFs, audio) with HTTP 415. Default `false` (warns in audit log/inspector). */
|
|
458
|
+
blockBinary?: boolean;
|
|
440
459
|
/** Optional local JSONL file for metadata-only audit logs (counts only, never raw PII). */
|
|
441
460
|
auditLogPath?: string;
|
|
442
461
|
/** Optional safe metadata logger (never receives raw PII). */
|
|
@@ -484,6 +503,21 @@ declare class StreamingRestorer {
|
|
|
484
503
|
private drain;
|
|
485
504
|
}
|
|
486
505
|
type RedactFieldKind = "message" | "system" | "tool_description";
|
|
506
|
+
/**
|
|
507
|
+
* Returns `true` when a `system` prompt block is clearly long English agent
|
|
508
|
+
* boilerplate (e.g. Claude Code / Codex / OpenCode system instructions) with
|
|
509
|
+
* zero Swedish characters or domain words. Those blocks still run deterministic
|
|
510
|
+
* structured PII rules + `customTerms`, avoiding hundreds of false Swedish NER
|
|
511
|
+
* hits on English keywords while keeping full NER on Swedish or short prompts.
|
|
512
|
+
*/
|
|
513
|
+
declare function isLikelyEnglishSystemPrompt(text: string): boolean;
|
|
514
|
+
/**
|
|
515
|
+
* Derives an isolated proxy vault session key per client/conversation when the
|
|
516
|
+
* caller omits `x-maskera-session`, preventing unrelated clients sharing a
|
|
517
|
+
* local proxy from sharing placeholder mappings while preserving multi-turn
|
|
518
|
+
* consistency within the same client thread.
|
|
519
|
+
*/
|
|
520
|
+
declare function deriveProxySessionId(headers: IncomingMessage["headers"], body?: Record<string, unknown>): string;
|
|
487
521
|
/**
|
|
488
522
|
* Redacts all user/tool/system text fields in an Anthropic Messages, OpenAI
|
|
489
523
|
* Chat Completions, or OpenAI Responses request body before it leaves the
|
|
@@ -491,6 +525,7 @@ type RedactFieldKind = "message" | "system" | "tool_description";
|
|
|
491
525
|
*/
|
|
492
526
|
declare function redactLlmRequestBody(body: Record<string, unknown>, redactString: (text: string, kind: RedactFieldKind) => Promise<string>, options?: {
|
|
493
527
|
mutate?: boolean;
|
|
528
|
+
onBinaryAttachment?: (kind: string) => void;
|
|
494
529
|
}): Promise<Record<string, unknown>>;
|
|
495
530
|
/**
|
|
496
531
|
* Restores Maskera placeholders in a non-streaming Anthropic or OpenAI JSON
|
|
@@ -553,6 +588,8 @@ interface MaskeraMcpPolicy {
|
|
|
553
588
|
readOnly?: boolean;
|
|
554
589
|
/** Gate raw PII release (`automatic`, `browser`, or `native` MCP elicitation). Default: `"automatic"`. */
|
|
555
590
|
approvalMode?: ApprovalMode;
|
|
591
|
+
/** Vault & approval isolation owner namespace (e.g. per Streamable HTTP `Mcp-Session-Id`). */
|
|
592
|
+
sessionOwner?: string;
|
|
556
593
|
}
|
|
557
594
|
interface MaskeraMcpOptions extends MaskeraMcpPolicy {
|
|
558
595
|
engine?: MaskeraEngine;
|
|
@@ -669,6 +706,7 @@ interface WrapOptions {
|
|
|
669
706
|
profile?: RedactionProfile;
|
|
670
707
|
customTerms?: readonly string[];
|
|
671
708
|
restoreResponses?: boolean;
|
|
709
|
+
blockBinary?: boolean;
|
|
672
710
|
auditLogPath?: string;
|
|
673
711
|
verify?: boolean;
|
|
674
712
|
receiptPath?: string;
|
|
@@ -708,4 +746,4 @@ declare function openUrlInBrowser(url: string, platform?: NodeJS.Platform): bool
|
|
|
708
746
|
*/
|
|
709
747
|
declare function runWrap(options: WrapOptions): Promise<WrapResult>;
|
|
710
748
|
|
|
711
|
-
export { ApprovalBroker, type ApprovalMode, type ApprovalResumeResult, type ApprovalStatus, type ApprovalSummary, type CommandRunner, type DoctorCheck, type DoctorCheckStatus, type DoctorReport, type DoctorSampleProof, type ElicitationRequest, type ElicitationResponse, type EngineOptions, type FileGuard, type GuardResult, type InspectedRequest, type InstallClient, type InstallOptions, type InstallResult, type InstallTransport, type JsonRpcResponse, LAUNCHD_LABEL, type ListedFile, MASKERA_PROMPTS, MASKERA_SKILL_MARKDOWN, MASKERA_SKILL_URI, MASKERA_STATUS_URI, type MaskMode, type MaskeraEngine, type MaskeraMcpOptions, type MaskeraMcpPolicy, type MaskeraMcpServer, type McpPromptDefinition, type ModelLoadEvent, ProxyInspector, type ProxyOptions, type ProxyStats, type RedactFieldKind, type RedactInputOptions, type RunningMaskeraProxy, SERVER_NAME, SERVER_VERSION, SUPPORTED_CLIENTS, SYSTEMD_UNIT, type SearchMatch, type ServiceAction, type ServiceOptions, type ServiceResult, type SessionSummary, SessionVault, StreamingRestorer, type ToolCallTelemetry, type WrapOptions, type WrapReceipt, type WrapResult, buildCustomTermsDetector, createFileGuard, createMaskeraEngine, createMaskeraMcpServer, createModelProgressLogger, createSseRestorer, detectInstalledClients, extractGuardText, formatDoctorReport, isInstallClient, openUrlInBrowser, redactLlmRequestBody, renderInspectorHtml, renderLaunchdPlist, renderMaskeraPrompt, renderSystemdUnit, restoreLlmResponseBody, runDoctor, runGuard, runGuardViaWarmProxy, runInstall, runService, runWrap, startMaskeraProxy, writeDoctorReceipt };
|
|
749
|
+
export { ApprovalBroker, type ApprovalMode, type ApprovalResumeResult, type ApprovalStatus, type ApprovalSummary, type CommandRunner, type DoctorCheck, type DoctorCheckStatus, type DoctorReport, type DoctorSampleProof, type ElicitationRequest, type ElicitationResponse, type EngineOptions, type FileGuard, type GuardResult, type InspectedRequest, type InstallClient, type InstallOptions, type InstallResult, type InstallTransport, type JsonRpcResponse, LAUNCHD_LABEL, type ListedFile, MASKERA_PROMPTS, MASKERA_SKILL_MARKDOWN, MASKERA_SKILL_URI, MASKERA_STATUS_URI, type MaskMode, type MaskeraEngine, type MaskeraMcpOptions, type MaskeraMcpPolicy, type MaskeraMcpServer, type McpPromptDefinition, type ModelLoadEvent, ProxyInspector, type ProxyOptions, type ProxyStats, type RedactFieldKind, type RedactInputOptions, type RunningMaskeraProxy, SERVER_NAME, SERVER_VERSION, SUPPORTED_CLIENTS, SYSTEMD_UNIT, type SearchMatch, type ServiceAction, type ServiceOptions, type ServiceResult, type SessionSummary, SessionVault, StreamingRestorer, type ToolCallTelemetry, type WrapOptions, type WrapReceipt, type WrapResult, buildCustomTermsDetector, createFileGuard, createMaskeraEngine, createMaskeraMcpServer, createModelProgressLogger, createSseRestorer, deriveProxySessionId, detectInstalledClients, extractGuardText, formatDoctorReport, isInstallClient, isLikelyEnglishSystemPrompt, normalizeMixedScriptHomoglyphs, openUrlInBrowser, redactLlmRequestBody, renderInspectorHtml, renderLaunchdPlist, renderMaskeraPrompt, renderSystemdUnit, restoreLlmResponseBody, runDoctor, runGuard, runGuardViaWarmProxy, runInstall, runService, runWrap, startMaskeraProxy, writeDoctorReceipt };
|