@saplings/plugins
v0.2.0
Published
Trusted plugin registration and permissions
Readme
@saplings/plugins
Versioned registration and permission checks for trusted application-installed plugins.
Usage
import { createPluginRegistry } from '@saplings/plugins';
const registry = createPluginRegistry(authorize);
registry.register({ manifest: { id: 'reports', apiVersion: 1, permissions: ['reports.read'] }, execute });
await registry.invoke({ tenantId: 'a', actorId: 'user' }, 'reports', {});The authorizer must use verified actor context. Every invocation requires an invoke grant and every declared permission. Revocation prevents future calls and checks again before dispatch. Already-running code is not interrupted. Registered functions run in the host process; do not load untrusted code. Isolation and marketplace lifecycle are not implemented.
Artifact signature verification
verifyPluginArtifact(bytes, signed, publicKey) verifies an Ed25519 signature and SHA-256 digest. The signed UTF-8 message is JSON encoding of ['saplings-plugin-v1', id, apiVersion, sortedPermissions, sha256]. The caller must pin trusted publisher keys, implement revocation, and load exactly the verified bytes without a time-of-check/time-of-use race. Signature verification does not sandbox code or automatically register it.
