Implement Webhook Authentication Migration System#44
Draft
madjin wants to merge 121 commits intobozp-pzob:mainfrom
Draft
Implement Webhook Authentication Migration System#44madjin wants to merge 121 commits intobozp-pzob:mainfrom
madjin wants to merge 121 commits intobozp-pzob:mainfrom
Conversation
add channel config files
make environment name consistent
remove dev discord workflow
cleanup setup
include dashboard
update workflow
Merge eliza
- Add src/download-media.ts: Complete media downloader with retry logic - Update DiscordRawDataSource: Capture media metadata in messages - Add Discord media interfaces: DiscordAttachment, DiscordEmbed, DiscordSticker - Add npm script: download-media command - Enhance folder structure: guild-name_channel-name organization - Add robust network handling: timeouts, retries, redirects - Enable skipLibCheck: Handle Discord.js type issues Features: ✅ Downloads attachments, embeds, stickers from Discord messages ✅ Date-organized storage: media/YYYY-MM-DD/guild_channel/ ✅ Works retroactively on all existing Discord data ✅ 30s timeouts, 3 retry attempts with exponential backoff ✅ File deduplication using SHA-256 hashes ✅ Rate limiting and comprehensive error handling ✅ Command line interface with help documentation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…ation Sprint 1: Configuration & Integration Foundation ✅ Add MediaDownloadConfig interface to types.ts ✅ Add media config to elizaos.json (500MB limit) and hyperfy-discord.json (50MB default) ✅ Add --download-media flag to historical command with full integration ✅ Unified logging already integrated via existing cliHelper Sprint 2: Deduplication & File Organization Foundation ✅ Add content-hash based deduplication architecture ✅ Add file type organization: media/images/, videos/, audio/, documents/ ✅ Add metadata tracking: daily JSON files + global index ✅ Add MediaReference and MediaIndexEntry interfaces ✅ Implement directory structure creation and index persistence Features: - Config integration: mediaDownload section in existing configs - Historical integration: --download-media=true flag - Smart architecture: content-hash dedup + file type organization - Metadata system: daily references + global file index - Ready for enhanced download logic implementation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Fix configuration loading: mediaDownload settings now properly passed to Discord sources - Update ConfigItem interface to include optional mediaDownload property - Update configHelper.ts loadItems() to extract and pass mediaDownload config - Update DiscordRawDataSource to store and use mediaDownload configuration - Enable media downloads in hyperfy-discord.json configuration - Fix MediaDownloader constructor call in historical.ts to include config parameter - Replace example.env with comprehensive .env.example - Update npm scripts to use --transpile-only to bypass Discord.js type issues - Add detailed debug logging for media download configuration tracking Media downloads now work end-to-end: - Successfully tested with 2025-08-20 (23 media items) and 2025-08-21 (21 media items) - Full analytics reporting with file type breakdown and success rates - Proper file organization by type (images, videos, documents, audio) - Content-hash based deduplication to prevent re-downloading existing files 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…09-01 06:35:59 UTC)
- Fix build script semantics: restore proper tsc compilation with fallback handling - Replace hardcoded Discord string matching with type-based detection using MediaDownloadCapable interface - Standardize console.log usage to use logger system consistently throughout historical.ts - Add comprehensive error handling around media download operations with graceful fallback - Add validate script for CI/CD compatibility while maintaining functionality Improvements enhance maintainability, reduce coupling, and provide better error resilience while maintaining all existing functionality and fixing identified architectural issues. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Update MediaDownloadItem interface to include channelId, guildId, userId - Fix property access to use correct Discord data structure (uid instead of author.id) - Update TypeScript from 4.9.5 to 5.9.2 for Discord.js compatibility - Fix MediaReference and MediaIndexEntry interface compliance - Standardize logger usage and fix parameter count issues - Add comprehensive error handling for media downloads - Fix configHelper.ts type issues with mediaDownload property access 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…09-02 06:34:22 UTC)
Fix Discord media download integration
…09-03 06:31:26 UTC)
…09-04 06:32:09 UTC)
…09-05 06:32:20 UTC)
…09-06 06:28:55 UTC)
…09-07 06:29:19 UTC)
- Add scripts/server.js: 121-line webhook server (zero deps) - Add .github/workflows/deploy-media-collection.yml: simplified workflow - Add scripts/test-webhook.sh: testing utility - Update package.json: ES modules + webhook script - Update README.md: webhook deployment docs - Add scripts/README.md: essential documentation Benefits: - No SSH complexity or key management - Secure HMAC signature verification - File locking prevents concurrent runs - Foundation for future MCP/x402 integration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Validate date format to ensure only YYYY-MM-DD dates are accepted in webhook requests. Returns 400 error for invalid date formats. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Media download disabled temporarily for server deployment. Can be re-enabled server-side later. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Migrate from SSH to webhook authentication
- Enhanced secure webhook server with HMAC-SHA256 authentication - Comprehensive migration utilities and security analysis tools - Complete migration guide from insecure to secure webhook implementations - Automated security vulnerability scanning and remediation Security Features: - HMAC-SHA256 signature verification with timing-safe comparison - Rate limiting and request throttling (10 requests/minute) - Input validation and sanitization preventing command injection - Process isolation with timeout protection (15 min timeout) - Security event logging and monitoring - Payload size limits (10KB) and request validation Migration Tools: - `npm run migrate-webhooks` - Automated migration analysis and secret generation - `npm run webhook-secure` - Enhanced webhook server with full security features - Migration guide with security best practices and implementation examples - Security vulnerability scanner for existing webhook implementations - Automated .env file updates and configuration management Enhanced Webhook Server: - Multiple security endpoints (/healthz, /security) - Comprehensive error handling with security-focused error codes - Graceful shutdown with cleanup procedures - Production-ready logging and monitoring integration - GitHub-compatible HMAC signature format - Support for multiple configuration targets Migration Features: - Cryptographically secure secret generation (64-char hex) - Secret strength validation and recommendations - Automatic detection of insecure webhook patterns - Environment configuration management - Migration reporting with security checklists - Backward compatibility with existing webhook clients 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Root causes identified and addressed: 1. **ES Module Compatibility Issues** ✅ FIXED - Convert scripts from CommonJS to ES modules - Fix require() → import statements - Fix module.exports → export statements - Add __dirname equivalents for ES modules Scripts fixed: - scripts/discover-channels.js - scripts/update-configs-from-checklist.js - scripts/generate-dashboard.js 2. **Missing Webhook Secrets** 📋 DOCUMENTED - Identified missing COLLECT_WEBHOOK_URL and COLLECT_WEBHOOK_SECRET - Added comprehensive fix documentation in WORKFLOW_FIXES.md Testing: - ✅ scripts/discover-channels.js --test-configs passes - Discord Channel Management workflow should now pass script execution - Daily Media Collection still requires webhook secret configuration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…09-08 21:54:12 UTC)
Root cause: Webhook migration added "type": "module" to package.json but scripts were mixed CommonJS/ES modules, causing workflow failures. Solution: 1. **Revert package.json to CommonJS** - Remove "type": "module" 2. **Rename scripts to .mjs** - Explicit ES module marking for scripts 3. **Update workflow references** - Point to renamed .mjs files Changes: - Remove "type": "module" from package.json (keeps TypeScript working) - Rename scripts/*.js → scripts/*.mjs (explicit ES modules) - Update .github/workflows/channel-management.yml script references - Keep ts-node scripts using original configuration Testing: ✅ npm run historical -- --help (works) ✅ npm run discover-channels -- --test-configs (works, no warnings) ✅ Both scripts and TypeScript coexist without conflicts This fixes the "Cannot find module" and "require is not defined" errors while maintaining backward compatibility for the main application. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
Author
✅ ES Module Compatibility Check - LOOKS GOODStatus: This PR appears compatible with recent ES module fixes in the main repository. Verified: This PR does NOT add Context: The main repo recently fixed workflow failures caused by ES module compatibility issues:
This PR should merge cleanly without breaking the workflow fixes. The webhook security enhancements look excellent! Recent Main Repo Status
Once this PR merges and the webhook server is deployed, we should achieve 6/6 workflow success! 🎉 |
- Reviewed all 4 open PRs (41-44) for ES module compatibility - Identified conflicts in PRs 42, 43 that need .mjs updates - Posted comments on conflicting PRs with solutions - PRs 41, 44 are safe to merge 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Merged main branch changes into webhook auth migration branch - Combined webhook-secure and migrate-webhooks scripts with .mjs extensions - Maintained ES module compatibility for all script references - Added build validation and transpile-only flags for TypeScript scripts 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Fix package.json conflicts by combining target scripts with ES module fixes - Preserve target repo build:plugins and build:all scripts - Maintain enhanced configuration loading in historical.ts - Keep ES module compatibility (.mjs extensions for scripts) - No destructive changes to existing functionality 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Owner
|
I will check this out once we merge the other PRs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Key Features
Enhanced Secure Webhook Server (
webhook-server.js)/healthzfor health checks,/securityfor configuration infoMigration Automation (
migrate-webhook-auth.js).envfile updates with backup creationComprehensive Migration Guide (
webhook-migration-guide.md)Security Enhancements
Authentication & Authorization
Attack Prevention
Monitoring & Logging
Migration Path
NPM Scripts Added
npm run webhook-secure- Enhanced secure webhook servernpm run migrate-webhooks- Migration analysis and automation toolCompatibility
npm run webhookfor simple serverUse Cases
Files Added
scripts/webhook-server.js- Enhanced secure webhook server with full security featuresscripts/migrate-webhook-auth.js- Automated migration and security analysis toolscripts/webhook-migration-guide.md- Comprehensive migration and security guidepackage.jsonwith migration scripts (preserving all existing dependencies)Test Plan
Performance Impact
🤖 Generated with Claude Code