@maskera/mcp 0.4.0 → 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/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,26 +393,37 @@ 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;
386
400
  knownPlaceholders: number;
387
401
  };
388
- getMap(sessionId: string): Record<string, string>;
402
+ /**
403
+ * Picks the session that restores `text` when the caller named none.
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.
406
+ */
407
+ resolveSessionFor(text: string, owner?: string): string;
408
+ getMap(sessionId: string, owner?: string): Record<string, string>;
389
409
  entries(): Array<{
390
410
  sessionId: string;
391
411
  token: string;
392
412
  value: string;
393
413
  }>;
394
414
  clearAll(): void;
395
- list(): SessionSummary[];
396
- clear(sessionId: string): boolean;
415
+ clearOwner(owner: string): number;
416
+ list(owner?: string): SessionSummary[];
417
+ clear(sessionId: string, owner?: string): boolean;
418
+ sizeForOwner(owner?: string): number;
397
419
  get size(): number;
398
420
  }
399
421
 
400
422
  interface ProxyOptions {
401
423
  /** Bind address. Defaults to loopback `127.0.0.1` for local safety. */
402
424
  host?: string;
425
+ /** Allow binding to a non-loopback interface (default `false`; refuses LAN exposure of local vault/MCP). */
426
+ allowNonLoopback?: boolean;
403
427
  /** Listening port. Defaults to `8787` (`0` picks an ephemeral port). */
404
428
  port?: number;
405
429
  /** Explicit upstream base URL (overrides automatic Anthropic/OpenAI routing). */
@@ -430,6 +454,8 @@ interface ProxyOptions {
430
454
  customTerms?: readonly string[];
431
455
  /** Restore placeholders in upstream responses. Default `true`. */
432
456
  restoreResponses?: boolean;
457
+ /** Reject uninspectable binary attachments (images, PDFs, audio) with HTTP 415. Default `false` (warns in audit log/inspector). */
458
+ blockBinary?: boolean;
433
459
  /** Optional local JSONL file for metadata-only audit logs (counts only, never raw PII). */
434
460
  auditLogPath?: string;
435
461
  /** Optional safe metadata logger (never receives raw PII). */
@@ -477,6 +503,21 @@ declare class StreamingRestorer {
477
503
  private drain;
478
504
  }
479
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;
480
521
  /**
481
522
  * Redacts all user/tool/system text fields in an Anthropic Messages, OpenAI
482
523
  * Chat Completions, or OpenAI Responses request body before it leaves the
@@ -484,6 +525,7 @@ type RedactFieldKind = "message" | "system" | "tool_description";
484
525
  */
485
526
  declare function redactLlmRequestBody(body: Record<string, unknown>, redactString: (text: string, kind: RedactFieldKind) => Promise<string>, options?: {
486
527
  mutate?: boolean;
528
+ onBinaryAttachment?: (kind: string) => void;
487
529
  }): Promise<Record<string, unknown>>;
488
530
  /**
489
531
  * Restores Maskera placeholders in a non-streaming Anthropic or OpenAI JSON
@@ -512,7 +554,7 @@ declare function createSseRestorer(map: Readonly<Record<string, string>>): {
512
554
  declare function startMaskeraProxy(options?: ProxyOptions): Promise<RunningMaskeraProxy>;
513
555
 
514
556
  declare const SERVER_NAME = "maskera-mcp";
515
- declare const SERVER_VERSION = "0.4.0";
557
+ declare const SERVER_VERSION: string;
516
558
  interface JsonRpcResponse {
517
559
  jsonrpc: "2.0";
518
560
  id: string | number | null;
@@ -546,6 +588,8 @@ interface MaskeraMcpPolicy {
546
588
  readOnly?: boolean;
547
589
  /** Gate raw PII release (`automatic`, `browser`, or `native` MCP elicitation). Default: `"automatic"`. */
548
590
  approvalMode?: ApprovalMode;
591
+ /** Vault & approval isolation owner namespace (e.g. per Streamable HTTP `Mcp-Session-Id`). */
592
+ sessionOwner?: string;
549
593
  }
550
594
  interface MaskeraMcpOptions extends MaskeraMcpPolicy {
551
595
  engine?: MaskeraEngine;
@@ -662,6 +706,7 @@ interface WrapOptions {
662
706
  profile?: RedactionProfile;
663
707
  customTerms?: readonly string[];
664
708
  restoreResponses?: boolean;
709
+ blockBinary?: boolean;
665
710
  auditLogPath?: string;
666
711
  verify?: boolean;
667
712
  receiptPath?: string;
@@ -701,4 +746,4 @@ declare function openUrlInBrowser(url: string, platform?: NodeJS.Platform): bool
701
746
  */
702
747
  declare function runWrap(options: WrapOptions): Promise<WrapResult>;
703
748
 
704
- 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 };