* fix(plugins): harden node execution grants * fix(plugins): harden iframe bridge boundaries (#8208) * fix(plugins): harden iframe bridge boundaries * fix(plugins): tighten iframe bridge follow-up * test(plugins): make node-executor electron test hermetic The new plugin-node-executor test read the real built-in plugin manifest (src/assets/bundled-plugins/sync-md/manifest.json), which is a build artifact absent when 'npm run test:electron' runs in CI (before the frontend/plugin build). Stub the manifest read, scoped to the executor module via Module._load, so the grant/token/webContents assertions no longer depend on built plugin assets. * fix(plugins): allow iframe formatDate & getCurrentLanguage i18n methods The iframe API allow-list gate added in #8208 only listed a subset of the i18n methods that master's #8146 exposes to iframe plugins. Without this, plugin calls to formatDate/getCurrentLanguage (and translate) are rejected with 'Unknown API method'. Add all three so the merged gate matches the methods createBoundMethods/createPluginApiScript expose. * docs(plugins): document node-exec handoff bootstrap-ordering invariant The one-shot consumePluginNodeExecutionApi() handoff is defended by construction ordering, not structural isolation: PluginBridgeService must consume it before any plugin 'new Function' code runs (both share window.ea in one renderer realm). Document the invariant at the consumption site so a future lazy-service/early-plugin-load refactor can't silently regress it. Surfaced by the post-merge security review (latent finding; not currently exploitable). * fix(plugins): use static iframe sandbox attribute to avoid NG0910 Binding a security-sensitive iframe attribute (sandbox) via [attr.sandbox] makes Angular throw RuntimeError NG0910 and tear down the iframe, crashing the plugin view to the global error screen. This broke the plugin-iframe, plugin-loading and plugin-lifecycle e2e tests. Restore the static sandbox attribute (still without allow-same-origin, so the opaque-origin isolation from #8208 is preserved) and drop the now-unused iframeSandbox binding/import. |
||
|---|---|---|
| .. | ||
| src | ||
| .gitignore | ||
| .npmignore | ||
| DEVELOPMENT.md | ||
| package-lock.json | ||
| package.json | ||
| publish.sh | ||
| PUBLISHING.md | ||
| README.md | ||
| tsconfig.json | ||
@super-productivity/plugin-api
Official TypeScript definitions for developing Super Productivity plugins.
Installation
npm install @super-productivity/plugin-api
Usage
TypeScript Plugin Development
import type {
PluginAPI,
PluginManifest,
PluginHooks,
} from '@super-productivity/plugin-api';
// Your plugin code with full type support
PluginAPI.registerHook(PluginHooks.TASK_COMPLETE, (taskData) => {
console.log('Task completed!', taskData);
PluginAPI.showSnack({
msg: 'Task completed successfully!',
type: 'SUCCESS',
ico: 'celebration',
});
});
// Register a header button
PluginAPI.registerHeaderButton({
label: 'My Plugin',
icon: 'extension',
onClick: () => {
PluginAPI.showIndexHtmlAsView();
},
});
// Register a keyboard shortcut
PluginAPI.registerShortcut({
id: 'my_shortcut',
label: 'My Custom Shortcut',
onExec: () => {
PluginAPI.showSnack({
msg: 'Shortcut executed!',
type: 'SUCCESS',
});
},
});
Plugin Manifest
{
"name": "My Awesome Plugin",
"id": "my-awesome-plugin",
"manifestVersion": 1,
"version": "1.0.0",
"minSupVersion": "13.0.0",
"description": "An awesome plugin for Super Productivity",
"hooks": ["taskComplete", "taskUpdate"],
"permissions": ["showSnack", "getTasks", "addTask", "showIndexHtmlAsView"],
"iFrame": true,
"uiKit": true,
"icon": "icon.svg"
}
Available Types
Core Types
PluginAPI- Main plugin API interfacePluginManifest- Plugin configurationPluginHooks- Available hook typesPluginBaseCfg- Runtime configuration
Data Types
TaskData- Task informationProjectData- Project informationTagData- Tag information
UI Types
DialogCfg- Dialog configurationDialogResult- Dialog return valueSnackCfg- Notification configurationPluginMenuEntryCfg- Menu entry configurationPluginShortcutCfg- Keyboard shortcut configuration
Plugin Development Guide
1. Available Hooks
enum PluginHooks {
TASK_COMPLETE = 'taskComplete',
TASK_UPDATE = 'taskUpdate',
TASK_DELETE = 'taskDelete',
FINISH_DAY = 'finishDay',
LANGUAGE_CHANGE = 'languageChange',
PERSISTED_DATA_CHANGED = 'persistedDataChanged',
ACTION = 'action',
}
PERSISTED_DATA_CHANGED fires on any persistent-data change to this
plugin after the host has finished its initial boot load — including
remote sync deliveries and bulk imports. Handler receives no payload;
re-call loadSyncedData(key?) for any key your plugin tracks to get
fresh data (scoped to the calling plugin). Contract: call
loadSyncedData() on plugin init for the initial state; then use this
hook for subsequent changes. There is no replay-on-register, no
per-key discrimination in the event, and no guaranteed ordering across
rapid changes. Handlers must be idempotent.
2. Required Permissions
Add these to your manifest.json based on what your plugin needs:
showSnack- Show notificationsnotify- System notificationsshowIndexHtmlAsView- Display plugin UIopenDialog- Show dialogsgetTasks- Read tasksgetArchivedTasks- Read archived tasksgetCurrentContextTasks- Read current context tasksaddTask- Create tasksgetAllProjects- Read projectsaddProject- Create projectsgetAllTags- Read tagsaddTag- Create tagspersistDataSynced- Persist plugin datagetAppState- Read-only snapshot of application state
3. Plugin Structure
my-plugin/
├── manifest.json
├── plugin.js
├── index.html (optional, if iFrame: true)
└── icon.svg (optional)
4. Example Plugin
// plugin.js
console.log('My Plugin initializing...', PluginAPI);
// Register hook for task completion
PluginAPI.registerHook(PluginAPI.Hooks.TASK_COMPLETE, function (taskData) {
console.log('Task completed!', taskData);
PluginAPI.showSnack({
msg: '🎉 Task completed!',
type: 'SUCCESS',
ico: 'celebration',
});
});
// Register header button
PluginAPI.registerHeaderButton({
label: 'My Plugin',
icon: 'dashboard',
onClick: function () {
PluginAPI.showIndexHtmlAsView();
},
});
// Read full app state
const state = await PluginAPI.getAppState();
License
MIT - See the main Super Productivity repository for details.
Contributing
Please contribute to the main Super Productivity repository.