Compare commits

..

1 Commits

Author SHA1 Message Date
43455e005e Add example-plugin-2
Some checks failed
Validate Plugin PR / validate (pull_request) Failing after 51s
2026-04-17 02:11:56 +10:00
18 changed files with 1912 additions and 362 deletions

9
.env.example Normal file
View File

@@ -0,0 +1,9 @@
# Gitea configuration
GITEA_URL=http://synbox.ruv.wtf:8418
GITEA_TOKEN=your_gitea_access_token_here
# Webhook secret (must match Gitea webhook configuration)
WEBHOOK_SECRET=your_webhook_secret_here
# Server port
PORT=3000

View File

@@ -1,28 +0,0 @@
import { readdir, readFile, writeFile } from 'fs/promises';
import { join } from 'path';
const pluginsDir = './plugins';
async function updateIndex() {
const files = await readdir(pluginsDir);
const pluginIds = files
.filter(f => f.endsWith('.json') && f !== 'index.json')
.map(f => f.replace('.json', ''))
.sort();
const index = {
version: '1.0.0',
updatedAt: new Date().toISOString(),
plugins: pluginIds
};
await writeFile(
join(pluginsDir, 'index.json'),
JSON.stringify(index, null, 2) + '\n'
);
console.log(`✅ Updated index.json with ${pluginIds.length} plugins`);
console.log('Plugins:', pluginIds.join(', '));
}
updateIndex().catch(console.error);

View File

@@ -10,93 +10,12 @@
* 4. Plugin ID matches filename * 4. Plugin ID matches filename
* 5. Author matches PR creator (for new plugins) * 5. Author matches PR creator (for new plugins)
* 6. Can only remove own plugins * 6. Can only remove own plugins
* 7. Thumbnail requirements: png/gif/jpg, max 512x512, max 2MB
*/ */
import { readFile, access } from 'fs/promises'; import { readFile, access } from 'fs/promises';
import { join } from 'path'; import { join } from 'path';
import https from 'https';
import http from 'http';
const REQUIRED_FIELDS = ['id', 'name', 'version', 'description', 'author', 'repository']; const REQUIRED_FIELDS = ['id', 'name', 'version', 'description', 'author', 'repository'];
const MAX_THUMBNAIL_SIZE = 2 * 1024 * 1024; // 2MB
const MAX_THUMBNAIL_DIMENSIONS = 512;
const ALLOWED_IMAGE_FORMATS = ['png', 'gif', 'jpg', 'jpeg'];
async function validateThumbnail(url) {
return new Promise((resolve, reject) => {
const protocol = url.startsWith('https') ? https : http;
protocol.get(url, (res) => {
if (res.statusCode !== 200) {
return reject(new Error(`Thumbnail URL returned ${res.statusCode}`));
}
const chunks = [];
let size = 0;
res.on('data', (chunk) => {
chunks.push(chunk);
size += chunk.length;
if (size > MAX_THUMBNAIL_SIZE) {
res.destroy();
reject(new Error(`Thumbnail exceeds 2MB limit (${(size / 1024 / 1024).toFixed(2)}MB)`));
}
});
res.on('end', () => {
const buffer = Buffer.concat(chunks);
// Check image format by magic bytes
const isPNG = buffer[0] === 0x89 && buffer[1] === 0x50 && buffer[2] === 0x4E && buffer[3] === 0x47;
const isJPG = buffer[0] === 0xFF && buffer[1] === 0xD8 && buffer[2] === 0xFF;
const isGIF = buffer[0] === 0x47 && buffer[1] === 0x49 && buffer[2] === 0x46;
if (!isPNG && !isJPG && !isGIF) {
return reject(new Error('Thumbnail must be PNG, JPG, or GIF format'));
}
// Check dimensions (simplified check - reads PNG/JPG headers)
let width, height;
if (isPNG) {
width = buffer.readUInt32BE(16);
height = buffer.readUInt32BE(20);
} else if (isJPG) {
// Simplified JPEG dimension reading
let offset = 2;
while (offset < buffer.length) {
if (buffer[offset] !== 0xFF) break;
offset++;
const marker = buffer[offset];
offset++;
if (marker === 0xC0 || marker === 0xC2) {
height = buffer.readUInt16BE(offset + 3);
width = buffer.readUInt16BE(offset + 5);
break;
}
const segmentLength = buffer.readUInt16BE(offset);
offset += segmentLength;
}
} else if (isGIF) {
width = buffer.readUInt16LE(6);
height = buffer.readUInt16LE(8);
}
if (width > MAX_THUMBNAIL_DIMENSIONS || height > MAX_THUMBNAIL_DIMENSIONS) {
return reject(new Error(`Thumbnail dimensions ${width}x${height} exceed ${MAX_THUMBNAIL_DIMENSIONS}x${MAX_THUMBNAIL_DIMENSIONS}`));
}
resolve({ width, height, size, format: isPNG ? 'PNG' : isJPG ? 'JPG' : 'GIF' });
});
res.on('error', reject);
}).on('error', reject);
});
}
const prAuthor = process.argv[2]; const prAuthor = process.argv[2];
const changedFiles = process.argv[3]?.split('\n').filter(f => f.trim()) || []; const changedFiles = process.argv[3]?.split('\n').filter(f => f.trim()) || [];
@@ -137,22 +56,12 @@ for (const file of changedFiles) {
const pluginId = file.replace('plugins/', '').replace('.json', ''); const pluginId = file.replace('plugins/', '').replace('.json', '');
// Filename must be prefixed with username
if (!pluginId.startsWith(`${prAuthor}-`)) {
errors.push(`${file}: Filename must start with your username "${prAuthor}-" (e.g., "${prAuthor}-my-plugin.json")`);
continue;
}
// Adjust file paths based on working directory
const prFilePath = process.env.PR_FILES_DIR ? `${process.env.PR_FILES_DIR}/${file.replace('plugins/', '')}` : file;
const baseFilePath = file;
// Check if file was added or removed // Check if file was added or removed
let isAdded = false; let isAdded = false;
let isRemoved = false; let isRemoved = false;
try { try {
await access(prFilePath); await access(file);
isAdded = true; isAdded = true;
} catch { } catch {
isRemoved = true; isRemoved = true;
@@ -161,32 +70,9 @@ for (const file of changedFiles) {
if (isAdded) { if (isAdded) {
// Validate added/modified plugin // Validate added/modified plugin
try { try {
const content = await readFile(prFilePath, 'utf-8'); const content = await readFile(file, 'utf-8');
const plugin = JSON.parse(content); const plugin = JSON.parse(content);
// Check if this plugin already exists on main
let isModification = false;
let originalAuthor = null;
try {
const originalContent = await readFile(baseFilePath, 'utf-8');
const originalPlugin = JSON.parse(originalContent);
isModification = true;
originalAuthor = originalPlugin.author;
} catch {
// File doesn't exist on main, this is a new plugin
isModification = false;
}
// If modifying existing plugin, MUST match original author
if (isModification) {
if (originalAuthor !== prAuthor) {
errors.push(`${file}: Cannot modify plugin owned by "${originalAuthor}" (you are "${prAuthor}")`);
continue;
}
console.log(` Modifying existing plugin by ${originalAuthor}`);
}
// Check required fields // Check required fields
for (const field of REQUIRED_FIELDS) { for (const field of REQUIRED_FIELDS) {
if (!plugin[field]) { if (!plugin[field]) {
@@ -204,7 +90,7 @@ for (const file of changedFiles) {
errors.push(`${file}: Invalid version format: ${plugin.version}`); errors.push(`${file}: Invalid version format: ${plugin.version}`);
} }
// Check author matches PR creator // Check author matches PR creator (for new files)
if (plugin.author !== prAuthor) { if (plugin.author !== prAuthor) {
errors.push(`${file}: Author "${plugin.author}" must match PR creator "${prAuthor}"`); errors.push(`${file}: Author "${plugin.author}" must match PR creator "${prAuthor}"`);
} }
@@ -213,64 +99,11 @@ for (const file of changedFiles) {
if (plugin.repository) { if (plugin.repository) {
try { try {
new URL(plugin.repository); new URL(plugin.repository);
// Repository URL should not end with .git
if (plugin.repository.endsWith('.git')) {
errors.push(`${file}: Repository URL should not end with .git: ${plugin.repository}`);
}
} catch { } catch {
errors.push(`${file}: Invalid repository URL: ${plugin.repository}`); errors.push(`${file}: Invalid repository URL: ${plugin.repository}`);
} }
} }
// Check homepage URL if provided
if (plugin.homepage) {
try {
new URL(plugin.homepage);
if (plugin.homepage.endsWith('.git')) {
errors.push(`${file}: Homepage URL should not end with .git: ${plugin.homepage}`);
}
} catch {
errors.push(`${file}: Invalid homepage URL: ${plugin.homepage}`);
}
}
// Check downloadUrl if provided
if (plugin.downloadUrl) {
try {
new URL(plugin.downloadUrl);
if (plugin.downloadUrl.endsWith('.git')) {
errors.push(`${file}: Download URL should not end with .git: ${plugin.downloadUrl}`);
}
} catch {
errors.push(`${file}: Invalid download URL: ${plugin.downloadUrl}`);
}
}
// Check thumbnail if provided (optional)
if (plugin.thumbnail) {
try {
new URL(plugin.thumbnail);
// Must be named thumbnail.png, thumbnail.jpg, or thumbnail.gif
if (!/\/thumbnail\.(png|jpg|gif)$/i.test(plugin.thumbnail)) {
errors.push(`${file}: Thumbnail must be named thumbnail.png, thumbnail.jpg, or thumbnail.gif`);
}
// Validate thumbnail meets requirements
try {
const thumbInfo = await validateThumbnail(plugin.thumbnail);
console.log(` ✓ Thumbnail: ${thumbInfo.format} ${thumbInfo.width}x${thumbInfo.height} (${(thumbInfo.size / 1024).toFixed(1)}KB)`);
} catch (thumbErr) {
errors.push(`${file}: Thumbnail validation failed: ${thumbErr.message}`);
}
} catch {
errors.push(`${file}: Invalid thumbnail URL: ${plugin.thumbnail}`);
}
}
if (errors.length === 0) { if (errors.length === 0) {
added.push(pluginId); added.push(pluginId);
console.log(`✅ Valid plugin: ${plugin.name}`); console.log(`✅ Valid plugin: ${plugin.name}`);
@@ -281,21 +114,10 @@ for (const file of changedFiles) {
} }
} else if (isRemoved) { } else if (isRemoved) {
// For removed files, check the original author from main branch // For removed files, we can't validate ownership easily in CI
try { // Just track that it was removed
const originalContent = await readFile(baseFilePath, 'utf-8'); removed.push(pluginId);
const originalPlugin = JSON.parse(originalContent); console.log(`🗑️ Removed: ${pluginId}`);
if (originalPlugin.author !== prAuthor) {
errors.push(`${file}: Cannot remove plugin owned by "${originalPlugin.author}" (you are "${prAuthor}")`);
continue;
}
removed.push(pluginId);
console.log(`🗑️ Removed: ${pluginId} (owned by ${prAuthor})`);
} catch (err) {
errors.push(`${file}: Could not verify ownership for removal: ${err.message}`);
}
} }
} }

View File

@@ -13,13 +13,29 @@ jobs:
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Generate index.json - name: Generate index.json
run: node .gitea/scripts/update-index.js run: |
cd plugins
echo '{' > index.json
echo ' "version": "1.0.0",' >> index.json
echo ' "updatedAt": "'$(date -u +"%Y-%m-%dT%H:%M:%S.000Z")'",' >> index.json
echo ' "plugins": [' >> index.json
first=true
for file in *.json; do
if [ "$file" != "index.json" ]; then
plugin_id="${file%.json}"
if [ "$first" = true ]; then
echo " \"$plugin_id\"" >> index.json
first=false
else
echo ", \"$plugin_id\"" >> index.json
fi
fi
done | sed '$ s/,$//'
echo ' ]' >> index.json
echo '}' >> index.json
- name: Commit index.json - name: Commit index.json
run: | run: |

View File

@@ -2,21 +2,15 @@ name: Validate Plugin PR
on: on:
pull_request: pull_request:
branches: [ main ] branches: [ main ]
paths:
- 'plugins/**'
jobs: jobs:
validate: validate:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout base branch (main) for validation scripts - uses: actions/checkout@v3
uses: actions/checkout@v3
with: with:
ref: main
path: base
- name: Checkout PR branch for plugin files
uses: actions/checkout@v3
with:
path: pr
fetch-depth: 0 fetch-depth: 0
- name: Setup Node.js - name: Setup Node.js
@@ -27,81 +21,13 @@ jobs:
- name: Get changed files - name: Get changed files
id: changed-files id: changed-files
run: | run: |
cd pr
echo "files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep '^plugins/' || echo '')" >> $GITHUB_OUTPUT echo "files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep '^plugins/' || echo '')" >> $GITHUB_OUTPUT
- name: Block attempts to modify infrastructure - name: Validate PR
run: | run: |
cd pr
INFRA_CHANGES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -E '^\.gitea/' || echo '')
if [ -n "$INFRA_CHANGES" ]; then
echo "❌ ERROR: PRs cannot modify .gitea/ directory files"
echo "Changed infrastructure files:"
echo "$INFRA_CHANGES"
echo ""
echo "Only plugins/ directory changes are allowed."
exit 1
fi
- name: Verify commit authors match PR creator
run: |
cd pr
echo "🔍 Verifying commit authors..."
PR_USER="${{ github.event.pull_request.user.login }}"
echo "PR created by: $PR_USER"
# Get all commits in this PR
COMMITS=$(git log --format="%H" origin/${{ github.base_ref }}..HEAD)
for commit in $COMMITS; do
AUTHOR=$(git show -s --format='%an' $commit)
EMAIL=$(git show -s --format='%ae' $commit)
echo " Commit $commit by $AUTHOR <$EMAIL>"
# This is a warning, not a hard block, since git authors can be configured differently
# The real security comes from PR creator authentication
done
echo "✓ PR created by authenticated user: $PR_USER"
echo "Note: Validation will check plugin ownership against this authenticated user, not git commit authors"
- name: Validate PR (using trusted validation script from main)
run: |
cd base
node .gitea/scripts/validate-pr.js "${{ github.event.pull_request.user.login }}" "${{ steps.changed-files.outputs.files }}" node .gitea/scripts/validate-pr.js "${{ github.event.pull_request.user.login }}" "${{ steps.changed-files.outputs.files }}"
env:
PR_FILES_DIR: ../pr/plugins
- name: Post approval comment - name: Auto-approve if valid
if: success() if: success()
run: | run: |
curl -X POST \ echo "✅ Validation passed - PR is ready to merge"
-H "Authorization: token ${{ github.token }}" \
-H "Content-Type: application/json" \
-d '{"body":"✅ **Validation passed!** Auto-merging this pull request.\n\nAll plugin requirements have been met:\n- ✓ Valid plugin schema\n- ✓ Correct filename format\n- ✓ Author verification\n- ✓ Repository URL valid\n\nYour plugin will be available in the directory shortly!"}' \
"http://synbox.ruv.wtf:8418/api/v1/repos/litruv/Plugin-Directory/issues/${{ github.event.pull_request.number }}/comments"
- name: Auto-merge PR
if: success()
run: |
cd pr
echo "✅ Validation passed - Auto-merging PR"
# Configure git with token authentication
git config user.name "gitea-actions[bot]"
git config user.email "gitea-actions[bot]@users.noreply.gitea.io"
# Set up authenticated remote URL using github.token
git remote set-url origin "http://oauth2:${{ github.token }}@synbox.ruv.wtf:8418/litruv/Plugin-Directory.git"
# Fetch and merge
git fetch origin ${{ github.event.pull_request.head.ref }}
git checkout main
git merge --squash origin/${{ github.event.pull_request.head.ref }}
git commit -m "${{ github.event.pull_request.title }}"
# Push changes
git push origin main
# Delete the PR branch
git push origin --delete ${{ github.event.pull_request.head.ref }}

131
README.md
View File

@@ -1,63 +1,124 @@
# Plugin Directory # Plugin Directory
Git-based plugin registry for Plugin Host. No server needed - just JSON files. A simple git-based plugin registry for the Plugin Host system.
## How to Submit a Plugin ## 📦 What This Is
### 1. Create your plugin JSON file A collection of JSON files that describe available plugins. The Plugin Host fetches these definitions directly from the git repository.
Filename format: `plugins/{username}-{plugin-name}.json` ## 🚀 How It Works
Example: `plugins/litruv-example-plugin.json` 1. Plugin authors create a JSON file in `plugins/` directory
2. Submit via Pull Request
3. Gitea Actions validate the submission
4. If valid, maintainer merges the PR
5. Plugin Host automatically discovers the new plugin
## 📝 Submitting a Plugin
### 1. Fork this repository
### 2. Create your plugin definition
Create `plugins/your-plugin-id.json`:
```json ```json
{ {
"id": "litruv-example-plugin", "id": "your-plugin-id",
"name": "Example Plugin", "name": "Your Plugin Name",
"version": "1.0.0", "version": "1.0.0",
"description": "What your plugin does", "description": "What your plugin does",
"author": "litruv", "author": "your-gitea-username",
"repository": "http://synbox.ruv.wtf:8418/litruv/Plugin-Example", "repository": "http://synbox.ruv.wtf:8418/you/your-plugin.git",
"homepage": "http://synbox.ruv.wtf:8418/litruv/Plugin-Example", "downloadUrl": "http://synbox.ruv.wtf:8418/you/your-plugin/archive/main.zip",
"thumbnail": "http://synbox.ruv.wtf:8418/litruv/Plugin-Example/raw/branch/main/thumbnail.png", "homepage": "http://synbox.ruv.wtf:8418/you/your-plugin",
"tags": ["example"] "tags": ["category", "keywords"]
} }
``` ```
**Required fields:** `id`, `name`, `version`, `description`, `author`, `repository` **Required fields:**
- `id` - Must match filename (without .json)
- `name` - Display name
- `version` - Semantic version (X.Y.Z)
- `description` - Brief description
- `author` - Your Gitea username (must match PR creator)
- `repository` - Git repository URL
**Optional fields:** `homepage`, `thumbnail`, `tags`, `downloadUrl` ### 3. Create Pull Request
**Rules:** Gitea Actions will automatically validate:
- All URLs must NOT end with `.git` - ✅ File is in `plugins/` directory
- `repository` and `homepage` should point to your plugin repo (without .git) - ✅ File is valid JSON
- `thumbnail` must be `thumbnail.png`, `thumbnail.jpg`, or `thumbnail.gif` (max 512x512, max 2MB) - ✅ All required fields present
- ✅ ID matches filename
- ✅ Author matches your username
- ✅ Version format is valid
- ✅ URLs are valid
**Important:** **Note:** Don't edit `plugins/index.json` - it's automatically generated when your PR is merged!
- Filename must start with your username: `{username}-`
- Plugin `id` must match filename (without .json)
- `author` field must match your Gitea username
### 2. Create a Pull Request ### 4. Merge
Push your branch and create a PR. Gitea Actions will automatically: If validation passes, maintainer will merge your PR. The `index.json` file will be automatically updated.
- Validate your submission
- Post approval comment if valid
- Auto-merge and update the plugin index
That's it! Your plugin will be available immediately after merge. ## 🗑️ Removing Your Plugin
## Updating or Removing Only plugin authors can remove their own plugins:
- **Update:** Create PR with modified JSON (version bump required) 1. Fork this repository
- **Remove:** Create PR deleting your plugin JSON file 2. Delete `plugins/your-plugin-id.json`
3. Create Pull Request
You can only modify/remove plugins you authored. ## 🔄 Updating Your Plugin
## Plugin Discovery 1. Fork this repository
2. Edit `plugins/your-plugin-id.json`
3. Update version number and any other fields
4. Create Pull Request
## 📋 Plugin Schema
See [SCHEMA.md](SCHEMA.md) for full schema documentation.
## 🔍 Validation Rules
PRs must:
- Only modify files in `plugins/` directory
- Only modify `.json` files
- Have valid JSON
- Match the plugin schema
- Have author field matching PR creator
- Have plugin ID matching filename
## 🏗️ Directory Structure
Plugin Host fetches from:
``` ```
http://synbox.ruv.wtf:8418/litruv/Plugin-Directory/raw/branch/main/plugins/index.json Plugin-Directory/
├── plugins/
│ ├── example-plugin.json
│ ├── your-plugin.json
│ └── ...
├── .gitea/
│ ├── workflows/
│ │ └── validate-pr.yml
│ └── scripts/
│ └── validate-pr.js
└── README.md
``` ```
## 🔗 Plugin Host Integration
The Plugin Host fetches plugin definitions from:
```
http://synbox.ruv.wtf:8418/litruv/Plugin-Directory/raw/branch/main/plugins/
```
No server needed - just static JSON files served by Gitea!
## 📖 Example Plugins
- [example-plugin.json](plugins/example-plugin.json) - Reference implementation
## License
MIT

73
SCHEMA.md Normal file
View File

@@ -0,0 +1,73 @@
# Plugin Schema
All plugin definitions must be valid JSON files following this schema.
## Required Fields
| Field | Type | Description | Example |
|-------|------|-------------|---------|
| `id` | string | Unique identifier (must match filename) | `"awesome-plugin"` |
| `name` | string | Display name | `"Awesome Plugin"` |
| `version` | string | Semantic version | `"1.0.0"` |
| `description` | string | What the plugin does | `"Does awesome things"` |
| `author` | string | Gitea username of creator | `"litruv"` |
| `repository` | string | Git repository URL | `"http://synbox.ruv.wtf:8418/litruv/awesome-plugin.git"` |
## Optional Fields
| Field | Type | Description | Example |
|-------|------|-------------|---------|
| `downloadUrl` | string | Direct download URL | `"http://synbox.ruv.wtf:8418/litruv/awesome-plugin/archive/main.zip"` |
| `homepage` | string | Plugin homepage or documentation | `"http://synbox.ruv.wtf:8418/litruv/awesome-plugin"` |
| `tags` | array | Category tags | `["utility", "automation"]` |
| `addedDate` | string | ISO 8601 date | `"2026-04-17T00:00:00.000Z"` |
| `dependencies` | object | Required dependencies | `{"lodash": "^4.17.21"}` |
## Example
```json
{
"id": "example-plugin",
"name": "Example Plugin",
"version": "1.0.0",
"description": "An example plugin demonstrating the plugin system capabilities",
"author": "litruv",
"repository": "http://synbox.ruv.wtf:8418/litruv/Plugin-Example.git",
"downloadUrl": "http://synbox.ruv.wtf:8418/litruv/Plugin-Example/archive/main.zip",
"homepage": "http://synbox.ruv.wtf:8418/litruv/Plugin-Example",
"tags": ["example", "demo"],
"addedDate": "2026-04-17T00:00:00.000Z"
}
```
## Validation Rules
1. **Filename Match**: Plugin ID must match the filename (without .json extension)
-`awesome-plugin.json` with `"id": "awesome-plugin"`
-`awesome-plugin.json` with `"id": "different-name"`
2. **Version Format**: Must follow semantic versioning (X.Y.Z)
-`"1.0.0"`, `"2.5.3"`, `"0.1.0"`
-`"1.0"`, `"v1.0.0"`, `"latest"`
3. **Author Matching**: For new plugins, author must match PR creator
- If PR is by user `litruv`, author field must be `"litruv"`
4. **Valid URLs**: Repository, downloadUrl, and homepage must be valid URLs
-`"http://example.com/repo.git"`
-`"not-a-url"`, `"//example.com"`
5. **Tags**: If present, must be an array of strings
-`["tag1", "tag2"]`
-`"tag1,tag2"`, `{"tag": "value"}`
## Submission Process
1. Create a JSON file in the `plugins/` directory
2. Filename must be `{plugin-id}.json`
3. Ensure all required fields are present
4. Author field must match your Gitea username
5. Create a Pull Request
6. Automated validation will run
7. If valid, PR auto-merges
8. If invalid, you'll receive comments explaining what to fix

920
package-lock.json generated Normal file
View File

@@ -0,0 +1,920 @@
{
"name": "@pluginhost/directory",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@pluginhost/directory",
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"express": "^4.18.2",
"node-fetch": "^3.3.2"
}
},
"node_modules/accepts": {
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
"integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
"license": "MIT",
"dependencies": {
"mime-types": "~2.1.34",
"negotiator": "0.6.3"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
"license": "MIT"
},
"node_modules/body-parser": {
"version": "1.20.4",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.4.tgz",
"integrity": "sha512-ZTgYYLMOXY9qKU/57FAo8F+HA2dGX7bqGc71txDRC1rS4frdFI5R7NhluHxH6M0YItAP0sHB4uqAOcYKxO6uGA==",
"license": "MIT",
"dependencies": {
"bytes": "~3.1.2",
"content-type": "~1.0.5",
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "~1.2.0",
"http-errors": "~2.0.1",
"iconv-lite": "~0.4.24",
"on-finished": "~2.4.1",
"qs": "~6.14.0",
"raw-body": "~2.5.3",
"type-is": "~1.6.18",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/bytes": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
"integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/call-bind-apply-helpers": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/call-bound": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
"integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"get-intrinsic": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/content-disposition": {
"version": "0.5.4",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
"integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
"license": "MIT",
"dependencies": {
"safe-buffer": "5.2.1"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/content-type": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
"integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie-signature": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz",
"integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==",
"license": "MIT"
},
"node_modules/data-uri-to-buffer": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz",
"integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==",
"license": "MIT",
"engines": {
"node": ">= 12"
}
},
"node_modules/debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"license": "MIT",
"dependencies": {
"ms": "2.0.0"
}
},
"node_modules/depd": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/destroy": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
"integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
"license": "MIT",
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/dunder-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.1",
"es-errors": "^1.3.0",
"gopd": "^1.2.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
"license": "MIT"
},
"node_modules/encodeurl": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
"integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/es-define-property": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-errors": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-object-atoms": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
"integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
"license": "MIT"
},
"node_modules/etag": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/express": {
"version": "4.22.1",
"resolved": "https://registry.npmjs.org/express/-/express-4.22.1.tgz",
"integrity": "sha512-F2X8g9P1X7uCPZMA3MVf9wcTqlyNp7IhH5qPCI0izhaOIYXaW9L535tGA3qmjRzpH+bZczqq7hVKxTR4NWnu+g==",
"license": "MIT",
"dependencies": {
"accepts": "~1.3.8",
"array-flatten": "1.1.1",
"body-parser": "~1.20.3",
"content-disposition": "~0.5.4",
"content-type": "~1.0.4",
"cookie": "~0.7.1",
"cookie-signature": "~1.0.6",
"debug": "2.6.9",
"depd": "2.0.0",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"finalhandler": "~1.3.1",
"fresh": "~0.5.2",
"http-errors": "~2.0.0",
"merge-descriptors": "1.0.3",
"methods": "~1.1.2",
"on-finished": "~2.4.1",
"parseurl": "~1.3.3",
"path-to-regexp": "~0.1.12",
"proxy-addr": "~2.0.7",
"qs": "~6.14.0",
"range-parser": "~1.2.1",
"safe-buffer": "5.2.1",
"send": "~0.19.0",
"serve-static": "~1.16.2",
"setprototypeof": "1.2.0",
"statuses": "~2.0.1",
"type-is": "~1.6.18",
"utils-merge": "1.0.1",
"vary": "~1.1.2"
},
"engines": {
"node": ">= 0.10.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/fetch-blob": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz",
"integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/jimmywarting"
},
{
"type": "paypal",
"url": "https://paypal.me/jimmywarting"
}
],
"license": "MIT",
"dependencies": {
"node-domexception": "^1.0.0",
"web-streams-polyfill": "^3.0.3"
},
"engines": {
"node": "^12.20 || >= 14.13"
}
},
"node_modules/finalhandler": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.2.tgz",
"integrity": "sha512-aA4RyPcd3badbdABGDuTXCMTtOneUCAYH/gxoYRTZlIJdF0YPWuGqiAsIrhNnnqdXGswYk6dGujem4w80UJFhg==",
"license": "MIT",
"dependencies": {
"debug": "2.6.9",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"on-finished": "~2.4.1",
"parseurl": "~1.3.3",
"statuses": "~2.0.2",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/formdata-polyfill": {
"version": "4.0.10",
"resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
"integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
"license": "MIT",
"dependencies": {
"fetch-blob": "^3.1.2"
},
"engines": {
"node": ">=12.20.0"
}
},
"node_modules/forwarded": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
"integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/fresh": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/function-bind": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-intrinsic": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"es-define-property": "^1.0.1",
"es-errors": "^1.3.0",
"es-object-atoms": "^1.1.1",
"function-bind": "^1.1.2",
"get-proto": "^1.0.1",
"gopd": "^1.2.0",
"has-symbols": "^1.1.0",
"hasown": "^2.0.2",
"math-intrinsics": "^1.1.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
"license": "MIT",
"dependencies": {
"dunder-proto": "^1.0.1",
"es-object-atoms": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/gopd": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-symbols": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/hasown": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
"license": "MIT",
"dependencies": {
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/http-errors": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz",
"integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==",
"license": "MIT",
"dependencies": {
"depd": "~2.0.0",
"inherits": "~2.0.4",
"setprototypeof": "~1.2.0",
"statuses": "~2.0.2",
"toidentifier": "~1.0.1"
},
"engines": {
"node": ">= 0.8"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
"license": "MIT",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"license": "ISC"
},
"node_modules/ipaddr.js": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
"license": "MIT",
"engines": {
"node": ">= 0.10"
}
},
"node_modules/math-intrinsics": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/merge-descriptors": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz",
"integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/methods": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
"integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
"license": "MIT",
"bin": {
"mime": "cli.js"
},
"engines": {
"node": ">=4"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"license": "MIT",
"dependencies": {
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
"license": "MIT"
},
"node_modules/negotiator": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/node-domexception": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
"integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==",
"deprecated": "Use your platform's native DOMException instead",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/jimmywarting"
},
{
"type": "github",
"url": "https://paypal.me/jimmywarting"
}
],
"license": "MIT",
"engines": {
"node": ">=10.5.0"
}
},
"node_modules/node-fetch": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz",
"integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==",
"license": "MIT",
"dependencies": {
"data-uri-to-buffer": "^4.0.0",
"fetch-blob": "^3.1.4",
"formdata-polyfill": "^4.0.10"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/node-fetch"
}
},
"node_modules/object-inspect": {
"version": "1.13.4",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
"integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/on-finished": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
"integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
"license": "MIT",
"dependencies": {
"ee-first": "1.1.1"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/parseurl": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/path-to-regexp": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.13.tgz",
"integrity": "sha512-A/AGNMFN3c8bOlvV9RreMdrv7jsmF9XIfDeCd87+I8RNg6s78BhJxMu69NEMHBSJFxKidViTEdruRwEk/WIKqA==",
"license": "MIT"
},
"node_modules/proxy-addr": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
"integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
"license": "MIT",
"dependencies": {
"forwarded": "0.2.0",
"ipaddr.js": "1.9.1"
},
"engines": {
"node": ">= 0.10"
}
},
"node_modules/qs": {
"version": "6.14.2",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.14.2.tgz",
"integrity": "sha512-V/yCWTTF7VJ9hIh18Ugr2zhJMP01MY7c5kh4J870L7imm6/DIzBsNLTXzMwUA3yZ5b/KBqLx8Kp3uRvd7xSe3Q==",
"license": "BSD-3-Clause",
"dependencies": {
"side-channel": "^1.1.0"
},
"engines": {
"node": ">=0.6"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/raw-body": {
"version": "2.5.3",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.3.tgz",
"integrity": "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA==",
"license": "MIT",
"dependencies": {
"bytes": "~3.1.2",
"http-errors": "~2.0.1",
"iconv-lite": "~0.4.24",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT"
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"license": "MIT"
},
"node_modules/send": {
"version": "0.19.2",
"resolved": "https://registry.npmjs.org/send/-/send-0.19.2.tgz",
"integrity": "sha512-VMbMxbDeehAxpOtWJXlcUS5E8iXh6QmN+BkRX1GARS3wRaXEEgzCcB10gTQazO42tpNIya8xIyNx8fll1OFPrg==",
"license": "MIT",
"dependencies": {
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "1.2.0",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"fresh": "~0.5.2",
"http-errors": "~2.0.1",
"mime": "1.6.0",
"ms": "2.1.3",
"on-finished": "~2.4.1",
"range-parser": "~1.2.1",
"statuses": "~2.0.2"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/send/node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"license": "MIT"
},
"node_modules/serve-static": {
"version": "1.16.3",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.3.tgz",
"integrity": "sha512-x0RTqQel6g5SY7Lg6ZreMmsOzncHFU7nhnRWkKgWuMTu5NN0DR5oruckMqRvacAN9d5w6ARnRBXl9xhDCgfMeA==",
"license": "MIT",
"dependencies": {
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"parseurl": "~1.3.3",
"send": "~0.19.1"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/setprototypeof": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
"license": "ISC"
},
"node_modules/side-channel": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz",
"integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.3",
"side-channel-list": "^1.0.0",
"side-channel-map": "^1.0.1",
"side-channel-weakmap": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-list": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz",
"integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.4"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-map": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",
"integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-weakmap": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
"integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3",
"side-channel-map": "^1.0.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/statuses": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
"integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/toidentifier": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
"integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
"license": "MIT",
"engines": {
"node": ">=0.6"
}
},
"node_modules/type-is": {
"version": "1.6.18",
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
"integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
"license": "MIT",
"dependencies": {
"media-typer": "0.3.0",
"mime-types": "~2.1.24"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
"integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/utils-merge": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
"integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
"license": "MIT",
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/web-streams-polyfill": {
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz",
"integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==",
"license": "MIT",
"engines": {
"node": ">= 8"
}
}
}
}

19
package.json Normal file
View File

@@ -0,0 +1,19 @@
{
"name": "@pluginhost/directory",
"version": "1.0.0",
"description": "Automated plugin directory with PR validation and auto-merge",
"main": "src/server.js",
"type": "module",
"scripts": {
"start": "node src/server.js",
"dev": "node --watch src/server.js",
"validate": "node src/validate.js"
},
"keywords": ["plugin", "directory", "registry"],
"author": "",
"license": "MIT",
"dependencies": {
"express": "^4.18.2",
"node-fetch": "^3.3.2"
}
}

View File

View File

@@ -1,11 +1,10 @@
{ {
"id": "litruv-example-plugin", "id": "example-plugin",
"name": "Example Plugin", "name": "Example Plugin",
"version": "1.0.0", "version": "1.0.0",
"description": "An example plugin demonstrating the plugin system capabilities", "description": "An example plugin demonstrating the plugin system capabilities",
"author": "litruv", "author": "litruv",
"repository": "http://synbox.ruv.wtf:8418/litruv/Plugin-Example", "repository": "http://synbox.ruv.wtf:8418/litruv/Plugin-Example.git",
"thumbnail": "http://synbox.ruv.wtf:8418/litruv/Plugin-Example/raw/branch/main/thumbnail.png",
"downloadUrl": "http://synbox.ruv.wtf:8418/litruv/Plugin-Example/archive/main.zip", "downloadUrl": "http://synbox.ruv.wtf:8418/litruv/Plugin-Example/archive/main.zip",
"homepage": "http://synbox.ruv.wtf:8418/litruv/Plugin-Example", "homepage": "http://synbox.ruv.wtf:8418/litruv/Plugin-Example",
"tags": ["example", "demo"], "tags": ["example", "demo"],

View File

@@ -1,8 +1,7 @@
{ {
"version": "1.0.0", "version": "1.0.0",
"updatedAt": "2026-04-16T17:29:40.639Z", "updatedAt": "2026-04-17T00:00:00.000Z",
"plugins": [ "plugins": [
"litruv-example-plugin", "example-plugin"
"litruv-example-plugin-2"
] ]
} }

View File

@@ -1,12 +0,0 @@
{
"id": "litruv-example-plugin-2",
"name": "Example Plugin 2",
"version": "1.0.0",
"description": "A second example plugin demonstrating additional capabilities",
"author": "litruv",
"repository": "http://synbox.ruv.wtf:8418/litruv/Plugin-Example2",
"downloadUrl": "http://synbox.ruv.wtf:8418/litruv/Plugin-Example2/archive/main.zip",
"homepage": "http://synbox.ruv.wtf:8418/litruv/Plugin-Example2",
"tags": ["example", "demo", "filtering", "validation"],
"addedDate": "2026-04-17T00:00:00.000Z"
}

View File

@@ -1,10 +0,0 @@
{
"id": "litruv-example-plugin-3",
"name": "Example Plugin 3",
"version": "1.0.0",
"description": "A third example plugin demonstrating async operations and data storage",
"author": "litruv",
"repository": "http://synbox.ruv.wtf:8418/litruv/Plugin-Example3",
"homepage": "http://synbox.ruv.wtf:8418/litruv/Plugin-Example3",
"tags": ["example", "async", "storage"]
}

193
src/Validator.js Normal file
View File

@@ -0,0 +1,193 @@
import { readFile } from 'fs/promises';
/**
* Validator - Validates PR changes against plugin directory rules
*/
export class Validator {
constructor() {
this.requiredFields = ['id', 'name', 'version', 'description', 'author', 'repository'];
this.optionalFields = ['downloadUrl', 'homepage', 'tags', 'addedDate', 'dependencies'];
}
/**
* Validate a PR's file changes
*/
async validatePR(files, prAuthor) {
const errors = [];
const added = [];
const removed = [];
// Check that all files are in the plugins/ directory
const invalidPaths = files.filter(f => !f.filename.startsWith('plugins/'));
if (invalidPaths.length > 0) {
errors.push(`Files outside plugins/ directory: ${invalidPaths.map(f => f.filename).join(', ')}`);
}
// Check that all files are .json files
const nonJsonFiles = files.filter(f =>
f.filename.startsWith('plugins/') && !f.filename.endsWith('.json')
);
if (nonJsonFiles.length > 0) {
errors.push(`Non-JSON files in plugins/: ${nonJsonFiles.map(f => f.filename).join(', ')}`);
}
// Process each changed file
for (const file of files) {
if (!file.filename.startsWith('plugins/') || !file.filename.endsWith('.json')) {
continue;
}
const pluginId = file.filename.replace('plugins/', '').replace('.json', '');
if (file.status === 'added' || file.status === 'modified') {
// Validate added/modified plugins
try {
const validation = await this.validatePluginFile(file, pluginId, prAuthor);
if (!validation.valid) {
errors.push(...validation.errors.map(e => `${file.filename}: ${e}`));
} else {
added.push(pluginId);
}
} catch (error) {
errors.push(`${file.filename}: ${error.message}`);
}
} else if (file.status === 'removed') {
// Validate removed plugins (check ownership)
try {
const canRemove = await this.validateRemoval(pluginId, prAuthor);
if (!canRemove.valid) {
errors.push(...canRemove.errors.map(e => `${file.filename}: ${e}`));
} else {
removed.push(pluginId);
}
} catch (error) {
errors.push(`${file.filename}: ${error.message}`);
}
}
}
// Must have at least one change
if (files.length === 0) {
errors.push('PR has no file changes');
}
return {
valid: errors.length === 0,
errors,
added,
removed
};
}
/**
* Validate a plugin JSON file
*/
async validatePluginFile(file, pluginId, prAuthor) {
const errors = [];
try {
// Parse the JSON content from the file patch
const content = this.extractFileContent(file);
const plugin = JSON.parse(content);
// Check required fields
for (const field of this.requiredFields) {
if (!plugin[field]) {
errors.push(`Missing required field: ${field}`);
}
}
// Check that ID matches filename
if (plugin.id !== pluginId) {
errors.push(`Plugin ID "${plugin.id}" does not match filename "${pluginId}.json"`);
}
// Validate version format (semver-ish)
if (plugin.version && !this.isValidVersion(plugin.version)) {
errors.push(`Invalid version format: ${plugin.version} (expected: X.Y.Z)`);
}
// Validate repository URL
if (plugin.repository && !this.isValidUrl(plugin.repository)) {
errors.push(`Invalid repository URL: ${plugin.repository}`);
}
// Validate author matches PR author (for new plugins)
if (file.status === 'added' && plugin.author !== prAuthor) {
errors.push(`Author "${plugin.author}" must match PR author "${prAuthor}"`);
}
// Validate tags if present
if (plugin.tags && !Array.isArray(plugin.tags)) {
errors.push('Tags must be an array');
}
} catch (error) {
errors.push(`Invalid JSON: ${error.message}`);
}
return {
valid: errors.length === 0,
errors
};
}
/**
* Validate that a user can remove a plugin
*/
async validateRemoval(pluginId, prAuthor) {
const errors = [];
try {
// Read the existing plugin file from disk
const content = await readFile(`./plugins/${pluginId}.json`, 'utf-8');
const plugin = JSON.parse(content);
// Check if the PR author is the plugin author
if (plugin.author !== prAuthor) {
errors.push(`Cannot remove plugin: you are not the author (author: ${plugin.author})`);
}
} catch (error) {
// If file doesn't exist, it's probably already removed
console.warn(`Could not validate removal of ${pluginId}:`, error.message);
}
return {
valid: errors.length === 0,
errors
};
}
/**
* Extract file content from Gitea file object
* In a real implementation, you'd fetch the raw content from the PR
*/
extractFileContent(file) {
// This is a simplified version
// In production, fetch the actual file content from the PR's head branch
// For now, return a placeholder that would need to be fetched
throw new Error('File content extraction not fully implemented - fetch from PR branch');
}
/**
* Validate semantic version format
*/
isValidVersion(version) {
return /^\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?(\+[a-zA-Z0-9.-]+)?$/.test(version);
}
/**
* Validate URL format
*/
isValidUrl(url) {
try {
new URL(url);
return true;
} catch {
return false;
}
}
}

232
src/ValidatorEnhanced.js Normal file
View File

@@ -0,0 +1,232 @@
import { WebhookHandler } from './WebhookHandler.js';
import fetch from 'node-fetch';
/**
* Enhanced validator that fetches actual file content from PR
*/
export class Validator {
constructor(webhookHandler) {
this.handler = webhookHandler;
this.requiredFields = ['id', 'name', 'version', 'description', 'author', 'repository'];
this.optionalFields = ['downloadUrl', 'homepage', 'tags', 'addedDate', 'dependencies'];
}
/**
* Validate a PR's file changes
*/
async validatePR(files, prAuthor, prNumber) {
const errors = [];
const added = [];
const removed = [];
// Check that all files are in the plugins/ directory
const invalidPaths = files.filter(f => !f.filename.startsWith('plugins/'));
if (invalidPaths.length > 0) {
errors.push(`Files outside plugins/ directory: ${invalidPaths.map(f => f.filename).join(', ')}`);
}
// Check that all files are .json files
const nonJsonFiles = files.filter(f =>
f.filename.startsWith('plugins/') && !f.filename.endsWith('.json')
);
if (nonJsonFiles.length > 0) {
errors.push(`Non-JSON files in plugins/: ${nonJsonFiles.map(f => f.filename).join(', ')}`);
}
// Process each changed file
for (const file of files) {
if (!file.filename.startsWith('plugins/') || !file.filename.endsWith('.json')) {
continue;
}
const pluginId = file.filename.replace('plugins/', '').replace('.json', '');
if (file.status === 'added' || file.status === 'modified') {
// Fetch and validate the file content
try {
const content = await this.fetchPRFileContent(prNumber, file.filename);
const validation = await this.validatePluginContent(content, pluginId, prAuthor, file.status);
if (!validation.valid) {
errors.push(...validation.errors.map(e => `${file.filename}: ${e}`));
} else {
added.push(pluginId);
}
} catch (error) {
errors.push(`${file.filename}: ${error.message}`);
}
} else if (file.status === 'removed') {
// Validate removed plugins (check ownership)
try {
const canRemove = await this.validateRemoval(pluginId, prAuthor);
if (!canRemove.valid) {
errors.push(...canRemove.errors.map(e => `${file.filename}: ${e}`));
} else {
removed.push(pluginId);
}
} catch (error) {
errors.push(`${file.filename}: ${error.message}`);
}
}
}
// Must have at least one change
if (files.length === 0) {
errors.push('PR has no file changes');
}
return {
valid: errors.length === 0,
errors,
added,
removed
};
}
/**
* Fetch file content from a PR
*/
async fetchPRFileContent(prNumber, filename) {
const pr = await this.getPRDetails(prNumber);
const headSha = pr.head.sha;
const url = `${this.handler.giteaUrl}/api/v1/repos/${this.handler.repoOwner}/${this.handler.repoName}/contents/${filename}?ref=${headSha}`;
const response = await fetch(url, {
headers: { 'Authorization': `token ${this.handler.giteaToken}` }
});
if (!response.ok) {
throw new Error(`Failed to fetch file: ${response.statusText}`);
}
const data = await response.json();
const content = Buffer.from(data.content, 'base64').toString('utf-8');
return content;
}
/**
* Get PR details
*/
async getPRDetails(prNumber) {
const url = `${this.handler.giteaUrl}/api/v1/repos/${this.handler.repoOwner}/${this.handler.repoName}/pulls/${prNumber}`;
const response = await fetch(url, {
headers: { 'Authorization': `token ${this.handler.giteaToken}` }
});
if (!response.ok) {
throw new Error(`Failed to fetch PR: ${response.statusText}`);
}
return await response.json();
}
/**
* Validate plugin JSON content
*/
async validatePluginContent(content, pluginId, prAuthor, status) {
const errors = [];
try {
const plugin = JSON.parse(content);
// Check required fields
for (const field of this.requiredFields) {
if (!plugin[field]) {
errors.push(`Missing required field: ${field}`);
}
}
// Check that ID matches filename
if (plugin.id !== pluginId) {
errors.push(`Plugin ID "${plugin.id}" does not match filename "${pluginId}.json"`);
}
// Validate version format (semver-ish)
if (plugin.version && !this.isValidVersion(plugin.version)) {
errors.push(`Invalid version format: ${plugin.version} (expected: X.Y.Z)`);
}
// Validate repository URL
if (plugin.repository && !this.isValidUrl(plugin.repository)) {
errors.push(`Invalid repository URL: ${plugin.repository}`);
}
// Validate author matches PR author (for new plugins)
if (status === 'added' && plugin.author !== prAuthor) {
errors.push(`Author "${plugin.author}" must match PR author "${prAuthor}"`);
}
// Validate tags if present
if (plugin.tags && !Array.isArray(plugin.tags)) {
errors.push('Tags must be an array');
}
} catch (error) {
errors.push(`Invalid JSON: ${error.message}`);
}
return {
valid: errors.length === 0,
errors
};
}
/**
* Validate that a user can remove a plugin
*/
async validateRemoval(pluginId, prAuthor) {
const errors = [];
try {
// Read the existing plugin file from main branch
const url = `${this.handler.giteaUrl}/api/v1/repos/${this.handler.repoOwner}/${this.handler.repoName}/contents/plugins/${pluginId}.json`;
const response = await fetch(url, {
headers: { 'Authorization': `token ${this.handler.giteaToken}` }
});
if (!response.ok) {
// If file doesn't exist on main, removal is fine
return { valid: true, errors: [] };
}
const data = await response.json();
const content = Buffer.from(data.content, 'base64').toString('utf-8');
const plugin = JSON.parse(content);
// Check if the PR author is the plugin author
if (plugin.author !== prAuthor) {
errors.push(`Cannot remove plugin: you are not the author (author: ${plugin.author})`);
}
} catch (error) {
console.warn(`Could not validate removal of ${pluginId}:`, error.message);
}
return {
valid: errors.length === 0,
errors
};
}
/**
* Validate semantic version format
*/
isValidVersion(version) {
return /^\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?(\+[a-zA-Z0-9.-]+)?$/.test(version);
}
/**
* Validate URL format
*/
isValidUrl(url) {
try {
new URL(url);
return true;
} catch {
return false;
}
}
}

245
src/WebhookHandler.js Normal file
View File

@@ -0,0 +1,245 @@
import crypto from 'crypto';
import fetch from 'node-fetch';
import { readdir, readFile } from 'fs/promises';
import { join, dirname, resolve } from 'path';
import { fileURLToPath } from 'url';
import { Validator } from './ValidatorEnhanced.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
/**
* WebhookHandler - Processes Gitea webhooks for automated PR handling
*/
export class WebhookHandler {
constructor(options) {
this.giteaUrl = options.giteaUrl;
this.giteaToken = options.giteaToken;
this.webhookSecret = options.webhookSecret;
this.repoOwner = options.repoOwner;
this.repoName = options.repoName;
this.validator = new Validator(this);
}
/**
* Verify webhook signature
*/
verifySignature(payload, signature) {
if (!this.webhookSecret) return true; // Skip if no secret configured
const hmac = crypto.createHmac('sha256', this.webhookSecret);
const digest = hmac.update(JSON.stringify(payload)).digest('hex');
return signature === digest;
}
/**
* Handle pull request webhook
*/
async handlePullRequest(payload) {
const { action, pull_request, repository } = payload;
console.log(`PR #${pull_request.number}: ${action} by ${pull_request.user.login}`);
// Only process opened or synchronized PRs
if (action !== 'opened' && action !== 'synchronize') {
console.log('Skipping PR action:', action);
return;
}
try {
// Get PR details
const prNumber = pull_request.number;
const prAuthor = pull_request.user.login;
const headBranch = pull_request.head.ref;
const baseBranch = pull_request.base.ref;
// Get file changes in the PR
const files = await this.getPRFiles(prNumber);
console.log(`PR files changed: ${files.map(f => `${f.filename} (${f.status})`).join(', ')}`);
// Validate the PR
const validation = await this.validator.validatePR(files, prAuthor, prNumber);
if (!validation.valid) {
console.log('Validation failed:', validation.errors);
await this.commentOnPR(prNumber, this.buildErrorComment(validation.errors));
await this.labelPR(prNumber, 'validation-failed');
return;
}
// PR is valid, auto-approve and merge
console.log('✓ PR validation passed');
await this.commentOnPR(prNumber, this.buildSuccessComment(validation));
await this.labelPR(prNumber, 'auto-approved');
await this.mergePR(prNumber);
console.log(`✓ Auto-merged PR #${prNumber}`);
} catch (error) {
console.error('Error handling PR:', error);
await this.commentOnPR(pull_request.number,
`❌ **Automation Error**\n\nFailed to process this PR: ${error.message}`
);
}
}
/**
* Get files changed in a PR
*/
async getPRFiles(prNumber) {
const url = `${this.giteaUrl}/api/v1/repos/${this.repoOwner}/${this.repoName}/pulls/${prNumber}/files`;
const response = await fetch(url, {
headers: { 'Authorization': `token ${this.giteaToken}` }
});
if (!response.ok) {
throw new Error(`Failed to fetch PR files: ${response.statusText}`);
}
return await response.json();
}
/**
* Comment on a PR
*/
async commentOnPR(prNumber, body) {
const url = `${this.giteaUrl}/api/v1/repos/${this.repoOwner}/${this.repoName}/issues/${prNumber}/comments`;
const response = await fetch(url, {
method: 'POST',
headers: {
'Authorization': `token ${this.giteaToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ body })
});
if (!response.ok) {
console.error('Failed to comment on PR:', response.statusText);
}
}
/**
* Label a PR
*/
async labelPR(prNumber, label) {
const url = `${this.giteaUrl}/api/v1/repos/${this.repoOwner}/${this.repoName}/issues/${prNumber}/labels`;
const response = await fetch(url, {
method: 'POST',
headers: {
'Authorization': `token ${this.giteaToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ labels: [label] })
});
if (!response.ok) {
console.error('Failed to label PR:', response.statusText);
}
}
/**
* Merge a PR
*/
async mergePR(prNumber) {
const url = `${this.giteaUrl}/api/v1/repos/${this.repoOwner}/${this.repoName}/pulls/${prNumber}/merge`;
const response = await fetch(url, {
method: 'POST',
headers: {
'Authorization': `token ${this.giteaToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
Do: 'squash',
MergeMessageField: 'Auto-merged plugin directory update',
delete_branch_after_merge: true
})
});
if (!response.ok) {
throw new Error(`Failed to merge PR: ${response.statusText}`);
}
return await response.json();
}
/**
* Build error comment for PR
*/
buildErrorComment(errors) {
let comment = '❌ **Validation Failed**\n\nThis PR cannot be auto-merged due to the following issues:\n\n';
errors.forEach(error => {
comment += `- ${error}\n`;
});
comment += '\n**Rules:**\n';
comment += '1. Only modify files in the `plugins/` directory\n';
comment += '2. Only add or remove `.json` files\n';
comment += '3. JSON files must match the plugin schema\n';
comment += '4. You can only remove plugins you authored\n';
comment += '5. Plugin ID must match the filename (without .json)\n';
comment += '\nPlease fix these issues and push again.';
return comment;
}
/**
* Build success comment for PR
*/
buildSuccessComment(validation) {
let comment = '✅ **Validation Passed**\n\nThis PR has been automatically approved and will be merged.\n\n';
if (validation.added.length > 0) {
comment += `**Added plugins:** ${validation.added.join(', ')}\n`;
}
if (validation.removed.length > 0) {
comment += `**Removed plugins:** ${validation.removed.join(', ')}\n`;
}
comment += '\nTo undo this change, create a new PR that reverses these changes.';
return comment;
}
/**
* List all plugins from the plugins directory
*/
async listPlugins() {
const pluginsDir = resolve(__dirname, '../plugins');
const files = await readdir(pluginsDir);
const plugins = [];
for (const file of files) {
if (file.endsWith('.json')) {
try {
const content = await readFile(join(pluginsDir, file), 'utf-8');
const plugin = JSON.parse(content);
plugins.push(plugin);
} catch (error) {
console.error(`Error reading plugin ${file}:`, error);
}
}
}
return plugins;
}
/**
* Get a specific plugin
*/
async getPlugin(pluginId) {
const pluginsDir = resolve(__dirname, '../plugins');
const filePath = join(pluginsDir, `${pluginId}.json`);
try {
const content = await readFile(filePath, 'utf-8');
return JSON.parse(content);
} catch (error) {
return null;
}
}
}

86
src/server.js Normal file
View File

@@ -0,0 +1,86 @@
import express from 'express';
import { WebhookHandler } from './WebhookHandler.js';
import { readFile } from 'fs/promises';
const app = express();
const port = process.env.PORT || 3000;
const webhookSecret = process.env.WEBHOOK_SECRET || '';
app.use(express.json());
const handler = new WebhookHandler({
giteaUrl: process.env.GITEA_URL || 'http://synbox.ruv.wtf:8418',
giteaToken: process.env.GITEA_TOKEN || '',
webhookSecret,
repoOwner: 'litruv',
repoName: 'Plugin-Directory'
});
/**
* Health check endpoint
*/
app.get('/health', (req, res) => {
res.json({ status: 'ok', timestamp: new Date().toISOString() });
});
/**
* List all plugins endpoint
*/
app.get('/plugins', async (req, res) => {
try {
const plugins = await handler.listPlugins();
res.json({ plugins, count: plugins.length });
} catch (error) {
console.error('Error listing plugins:', error);
res.status(500).json({ error: 'Failed to list plugins' });
}
});
/**
* Get specific plugin endpoint
*/
app.get('/plugins/:pluginId', async (req, res) => {
try {
const plugin = await handler.getPlugin(req.params.pluginId);
if (plugin) {
res.json(plugin);
} else {
res.status(404).json({ error: 'Plugin not found' });
}
} catch (error) {
console.error('Error getting plugin:', error);
res.status(500).json({ error: 'Failed to get plugin' });
}
});
/**
* Webhook endpoint for Gitea PR events
*/
app.post('/webhook', async (req, res) => {
try {
const signature = req.headers['x-gitea-signature'];
const event = req.headers['x-gitea-event'];
if (!handler.verifySignature(req.body, signature)) {
console.warn('Invalid webhook signature');
return res.status(401).json({ error: 'Invalid signature' });
}
console.log(`Received webhook event: ${event}`);
if (event === 'pull_request') {
await handler.handlePullRequest(req.body);
}
res.json({ status: 'processed' });
} catch (error) {
console.error('Webhook error:', error);
res.status(500).json({ error: 'Webhook processing failed' });
}
});
app.listen(port, () => {
console.log(`Plugin Directory server running on port ${port}`);
console.log(`Webhook endpoint: http://litruv-sub:${port}/webhook`);
console.log(`Plugin list: http://litruv-sub:${port}/plugins`);
});