/** * Plugin extension trust framework. * * Defines trust tiers (untrusted, limited, trusted), signed manifest * validation for the trusted tier, and the PluginTrustStore that manages * trust records with persistence support. * * Trust tiers gate access to high-risk capabilities: * - untrusted, only safe, read-only capabilities allowed * - limited , moderate capabilities; high-risk capabilities blocked * - trusted , full capability set; requires signed manifest validation */ import type { PluginCapability } from './types.js'; /** * The three trust tiers available to a plugin. * * - `untrusted`, Default for newly discovered plugins. Only safe capabilities * are accessible. The plugin may not have been reviewed. * - `limited` , Operator-reviewed plugin. Moderate capabilities granted. * High-risk capabilities (shell.exec, filesystem.write, network.outbound) * remain blocked without explicit trust escalation. * - `trusted` , Fully trusted plugin. Requires a valid signed manifest. * All declared capabilities may be granted (subject to runtime policy). */ export type PluginTrustTier = 'untrusted' | 'limited' | 'trusted'; /** * A persisted trust record for a single plugin. */ export interface PluginTrustRecord { /** Plugin identifier (manifest name). */ readonly pluginName: string; /** Current trust tier. */ tier: PluginTrustTier; /** Unix epoch ms when the trust record was last updated. */ updatedAt: number; /** Who or what granted this trust level. */ grantedBy: 'operator' | 'signed-manifest'; /** * Fingerprint of the verified signature for trusted-tier plugins. * Undefined for untrusted/limited plugins. */ signatureFingerprint?: string | undefined; /** Optional human-readable note attached by the operator. */ note?: string | undefined; } /** * Result of validating a plugin's signed manifest. */ export interface SignatureValidationResult { /** Whether the signature is valid. */ valid: boolean; /** A stable fingerprint derived from the signature (e.g. hex digest prefix). */ fingerprint?: string | undefined; /** Human-readable failure reason. Only set when `valid` is false. */ reason?: string | undefined; } /** * validatePluginSignature, Validates the manifest signature for a plugin * seeking the `trusted` tier. * * The signature field in PluginManifestV2 is expected to be a base64-encoded * HMAC-SHA256 of the canonical manifest JSON (name + version + capabilities * sorted and serialised). For production use, callers should supply a real * key; this implementation uses a structural check so external tooling can * provide real crypto without requiring Node.js crypto APIs at import time. * * @param manifest - The raw manifest object containing the `signature` field. * @param publicKey - Optional verification key. When omitted, structural * validity only is checked (suitable for CI/test). */ export declare function validatePluginSignature(manifest: { name: string; version: string; capabilities?: string[] | undefined; signature?: string | undefined; }, publicKey?: string): SignatureValidationResult; /** * Capabilities that are safe for any trust tier (including untrusted). */ export declare const SAFE_CAPABILITIES: ReadonlyArray; /** * filterCapabilitiesByTrust, Returns the subset of `requested` capabilities * that are permitted for the given trust tier. * * - `untrusted`: only SAFE_CAPABILITIES * - `limited`: all capabilities except HIGH_RISK_CAPABILITIES * - `trusted`: all capabilities (HIGH_RISK_CAPABILITIES included) */ export declare function filterCapabilitiesByTrust(requested: ReadonlyArray, tier: PluginTrustTier): { permitted: PluginCapability[]; blocked: PluginCapability[]; reasons: Partial>; }; /** * PluginTrustStore, In-memory trust registry for all plugins. * * Callers are responsible for persistence (serialise/deserialise via * `exportRecords` / `importRecords`). The PluginManager bridges this to * the plugins.json state file. */ export declare class PluginTrustStore { private readonly records; /** * Returns the trust record for a plugin, or `undefined` if not yet assessed. * Callers should treat `undefined` as implicitly `untrusted`. */ getRecord(pluginName: string): Readonly | undefined; /** * Returns the trust tier for a plugin. * Plugins without an explicit record are treated as `untrusted`. */ getTier(pluginName: string): PluginTrustTier; /** * setTier, Explicitly assign a trust tier to a plugin. * * Intended for operator use via `/plugin trust`. * For the `trusted` tier, prefer `trustSigned()` which also validates the signature. */ setTier(pluginName: string, tier: PluginTrustTier, options?: { note?: string | undefined; }): PluginTrustRecord; /** * trustSigned, Elevate a plugin to the `trusted` tier after verifying its * signed manifest. Returns `{ ok: false, reason }` if validation fails. */ trustSigned(pluginName: string, manifest: { name: string; version: string; capabilities?: string[] | undefined; signature?: string | undefined; }, publicKey?: string): { ok: true; record: PluginTrustRecord; } | { ok: false; reason: string; }; /** * verify, Verify the current signature on a plugin manifest without * changing its tier. Useful for `/plugin verify` inspection. */ verify(manifest: { name: string; version: string; capabilities?: string[] | undefined; signature?: string | undefined; }, publicKey?: string): SignatureValidationResult; /** Returns all trust records as an array. */ getAllRecords(): ReadonlyArray>; /** Export all records for persistence. */ exportRecords(): Record; /** Import records from persisted state. Merges into existing records. */ importRecords(records: Record): void; } //# sourceMappingURL=trust.d.ts.map