{"library":"policyfile","title":"Flash Socket Policy File Server","description":"The `policyfile` package provides a server designed to respond to Adobe Flash Player's cross-domain socket policy requests. It allows developers to specify which origins are permitted to connect to a Flash application, effectively managing security for older Flash-based projects. The current stable version is 0.0.6, indicating a very early stage of development, and it appears to have seen no significant updates in over a decade. Its release cadence is effectively non-existent. A key differentiator was its ability to either run as a dedicated server, typically on port 843, or integrate inline with an existing HTTP server (e.g., on port 80) to handle policy requests when Flash Player falls back from its primary policy port. This package is built directly on Node.js's native `net` and `http` modules. However, with Adobe Flash Player reaching End-of-Life in 2020, this package is now largely obsolete and should not be used for new projects or in production environments.","language":"javascript","status":"abandoned","last_verified":"Sun Apr 19","install":{"commands":["npm install policyfile"],"cli":null},"imports":["const policyfile = require('policyfile');\nconst server = policyfile.createServer();","const PolicyFileServer = require('policyfile');\nconst server = new PolicyFileServer.createServer();"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const policyfile = require('policyfile');\nconst http = require('http');\n\n// Create a new policy file server instance.\n// By default, it allows all origins ('*:*') but can be restricted.\nconst pf = policyfile.createServer({ log: true }, ['localhost:8080', 'myflashapp.com:443']);\n\n// Start a regular HTTP server. Flash Player will query this if port 843 fails.\nconst httpServer = http.createServer((req, res) => {\n  res.writeHead(200, { 'Content-Type': 'text/plain' });\n  res.end('Hello from the main HTTP server!\\n');\n});\n\nconst httpPort = process.env.HTTP_PORT ?? 8080;\nhttpServer.listen(httpPort, () => {\n  console.log(`HTTP Server listening on port ${httpPort}`);\n});\n\n// Start the policy server.\n// The default port is 843, which often requires root. Using 1337 for demonstration.\nconst policyPort = process.env.POLICY_PORT ?? 1337;\npf.listen(policyPort, httpServer, function() {\n  console.log(`Flash Policy File Server listening on port ${policyPort}`);\n  console.log(`Configured origins: ${pf.options.origins.join(', ')}`);\n});\n\n// Add more origins dynamically\nsetTimeout(() => {\n  pf.add('anotherdomain.net:80');\n  console.log('Added anotherdomain.net:80');\n}, 3000);\n\n// Clean up on process exit\nprocess.on('SIGINT', () => {\n  console.log('Shutting down servers...');\n  pf.close();\n  httpServer.close(() => {\n    console.log('HTTP server closed.');\n    process.exit(0);\n  });\n});","lang":"javascript","description":"Demonstrates how to create a Flash Socket Policy File server, listen on a specific port, and optionally integrate it to serve policy requests over an existing HTTP server, addressing Flash Player's fallback mechanism, along with dynamic origin management.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}