Skip to main content
Glama
migrate-jwt-references.js•3.3 kB
#!/usr/bin/env node /** * JWT Reference Migration Tool * @version 1.0.0 * @description Updates critical files to use centralized JWT configuration */ import { readFileSync, writeFileSync } from 'fs'; import { join } from 'path'; const PROJECT_ROOT = '/Users/ricardokawasaki/Desktop/euconquisto-composer-mcp-poc'; const CRITICAL_FILES = [ 'dist/browser-automation-api-jit-v5.1.0.js', 'tools/servers/jwt-redirect-server-v1.0.2.js' ]; const MIGRATION_PATTERNS = [ { description: 'Replace hardcoded archive/authentication path', pattern: /const tokenPath = join\(PROJECT_ROOT, 'archive\/authentication\/correct-jwt-new\.txt'\);/g, replacement: `import { getJWTToken } from '../src/config/jwt-config.js';\n // JWT token loaded via centralized config` }, { description: 'Replace readFileSync with centralized loader', pattern: /this\.jwtToken = readFileSync\(tokenPath, 'utf-8'\)\.trim\(\);/g, replacement: 'this.jwtToken = getJWTToken();' }, { description: 'Replace fallback path loading', pattern: /const fallbackPath = join\(PROJECT_ROOT, 'correct-jwt-new\.txt'\);[\s\S]*?readFileSync\(fallbackPath, 'utf-8'\)\.trim\(\);/g, replacement: 'this.jwtToken = getJWTToken(); // Centralized loading with built-in fallbacks' }, { description: 'Replace JWT redirect server path', pattern: /this\.jwtFilePath = path\.join\(__dirname, 'correct-jwt-new\.txt'\);/g, replacement: `import { getJWTPrimaryPath } from '../../src/config/jwt-config.js';\n this.jwtFilePath = getJWTPrimaryPath();` } ]; function migrateFile(filePath) { console.log(`\nšŸ”§ Migrating: ${filePath}`); try { let content = readFileSync(join(PROJECT_ROOT, filePath), 'utf-8'); let modified = false; for (const pattern of MIGRATION_PATTERNS) { if (pattern.pattern.test(content)) { content = content.replace(pattern.pattern, pattern.replacement); modified = true; console.log(` āœ… Applied: ${pattern.description}`); } } if (modified) { // Create backup const backupPath = join(PROJECT_ROOT, filePath + '.backup-pre-jwt-migration'); writeFileSync(backupPath, readFileSync(join(PROJECT_ROOT, filePath))); console.log(` šŸ“¦ Backup created: ${backupPath}`); // Write updated file writeFileSync(join(PROJECT_ROOT, filePath), content); console.log(` āœ… File updated: ${filePath}`); } else { console.log(` ā„¹ļø No changes needed`); } } catch (error) { console.error(` āŒ Error migrating ${filePath}:`, error.message); } } function main() { console.log('šŸš€ JWT Reference Migration Tool v1.0.0'); console.log('šŸ“‹ Migrating critical files to use centralized JWT configuration...\n'); for (const file of CRITICAL_FILES) { migrateFile(file); } console.log(` āœ… Migration complete! šŸ“‹ Next Steps: 1. Test the migrated files to ensure they work correctly 2. Gradually migrate other files using the centralized JWT config 3. Remove duplicate JWT token files once migration is complete šŸ“ Centralized JWT Location: /config/jwt-token.txt šŸ“š Configuration Module: /src/config/jwt-config.js āš ļø Note: Backups were created for all modified files with .backup-pre-jwt-migration extension `); } main();

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/rkm097git/euconquisto-composer-mcp-poc'

If you have feedback or need assistance with the MCP directory API, please join our Discord server