{"_id":"@armoredfuzzball/fjtp","_rev":"2-c6fbf80ccf67105236d55c39674ad750","name":"@armoredfuzzball/fjtp","dist-tags":{"latest":"2.0.2"},"versions":{"2.0.1":{"name":"@armoredfuzzball/fjtp","version":"2.0.1","keywords":["ipc","interprocess","communication","uds","unix","domain","sockets","fjtp","fast","json","transfer","protocol"],"license":"MIT","_id":"@armoredfuzzball/fjtp@2.0.1","maintainers":[{"name":"armoredfuzzball","email":"armoredredfox@gmail.com"}],"homepage":"https://github.com/ArmoredFuzzball/fjtp#readme","dist":{"shasum":"50e84b0516fec93c1c61dc50a44e12fb75ee1cbc","tarball":"https://registry.npmjs.org/@armoredfuzzball/fjtp/-/fjtp-2.0.1.tgz","fileCount":16,"integrity":"sha512-5T1+QgtruPwxwHnGZ1sPNgELdzjWeiOmfCmxaSBTJRplc5NR3sWIm8cjQAhOly1tksxOe+DE1u5xxGMMNMKMgg==","signatures":[{"sig":"MEUCIEXC5/zFVp5ApdGGFxRHX84MdHHHOu0X2ouQpTxgRpbRAiEAjjsSuOrTkL4WuYq4Gkw8fENK2bzTHPaLqFiOMvulv6U=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":31119},"main":"dist/protocol.js","type":"module","types":"dist/protocol.d.ts","exports":{".":{"types":"./dist/protocol.d.ts","import":"./dist/protocol.js","default":"./dist/protocol.js"},"./package.json":"./package.json"},"gitHead":"b19733ec60f763df5de9896006a6ad0957548905","scripts":{"build":"tsc"},"_npmUser":{"name":"armoredfuzzball","email":"armoredredfox@gmail.com"},"repository":{"url":"git://ArmoredFuzzball/fjtp.git","type":"git"},"_npmVersion":"11.11.0","description":"Node.js interprocess communication with JSON","directories":{},"_nodeVersion":"24.14.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.9.3","@types/node":"^25.3.3"},"_npmOperationalInternal":{"tmp":"tmp/fjtp_2.0.1_1772336085742_0.04229690044389689","host":"s3://npm-registry-packages-npm-production"}},"2.0.2":{"name":"@armoredfuzzball/fjtp","description":"Node.js interprocess communication with JSON","version":"2.0.2","type":"module","main":"dist/protocol.js","types":"dist/protocol.d.ts","exports":{".":{"types":"./dist/protocol.d.ts","import":"./dist/protocol.js","default":"./dist/protocol.js"},"./package.json":"./package.json"},"repository":{"type":"git","url":"git://ArmoredFuzzball/fjtp.git"},"homepage":"https://github.com/ArmoredFuzzball/fjtp#readme","license":"MIT","keywords":["ipc","interprocess","communication","uds","unix","domain","sockets","fjtp","fast","json","transfer","protocol"],"devDependencies":{"@types/node":"^25.3.3","typescript":"^5.9.3"},"scripts":{"build":"tsc"},"gitHead":"778e8f1018d65a7ba5aad6890c329ac2600b6c01","_id":"@armoredfuzzball/fjtp@2.0.2","_nodeVersion":"24.14.0","_npmVersion":"11.11.0","dist":{"integrity":"sha512-W43zypp1pCCZSo03zMfqOdXxjFEjUpISFnatsEk9DXdbOUCX+xWAUamP7pjkPsw3C8n2TLCQ3FfP5Jl6XWpdmQ==","shasum":"ae80a1c114a3e21833eb1ed8a52ee6e332caf919","tarball":"https://registry.npmjs.org/@armoredfuzzball/fjtp/-/fjtp-2.0.2.tgz","fileCount":16,"unpackedSize":31308,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIHFfkbBmCAE6y9BPM3Hz2YpL9ODemDEjwgEYYM2QD4iGAiBLU0/EZt3KYbNoXSoCR4l0/8V1ZkQo9/zXhI03ppMvog=="}]},"_npmUser":{"name":"armoredfuzzball","email":"armoredredfox@gmail.com"},"directories":{},"maintainers":[{"name":"armoredfuzzball","email":"armoredredfox@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/fjtp_2.0.2_1772344607292_0.6511160932751643"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-01T03:34:45.668Z","modified":"2026-03-01T05:56:47.579Z","2.0.1":"2026-03-01T03:34:45.889Z","2.0.2":"2026-03-01T05:56:47.463Z"},"license":"MIT","homepage":"https://github.com/ArmoredFuzzball/fjtp#readme","keywords":["ipc","interprocess","communication","uds","unix","domain","sockets","fjtp","fast","json","transfer","protocol"],"repository":{"type":"git","url":"git://ArmoredFuzzball/fjtp.git"},"description":"Node.js interprocess communication with JSON","maintainers":[{"name":"armoredfuzzball","email":"armoredredfox@gmail.com"}],"readme":"<h1>Fast JSON Transfer Protocol</h1>\nThis simple library provides a fast and efficient way to communicate between different Node.js processes using JSON over Unix Domain Sockets.\n\n<h2>Performance</h2>\nFor small to medium payloads, this library offers extremely high speed communication with minimal overhead, considerably higher bandwidth and lower latency than popular alternatives.\n<br>\nNOTE: For larger payloads (more than ~256 KB), popular HTTP-based libraries start to quickly outperform this library by a large margin, as their protocol overhead no longer dominates at that scale and actually starts helping.\n\n<h3>Benchmarks</h3>\n\n<table class=\"center\">\n  <caption>Performance comparison of Fastify+Fetch and FJTP</caption>\n  <thead>\n    <tr>\n      <th rowspan=\"2\">Payload<br>size (KB)</th>\n      <th colspan=\"2\">Req/sec</th>\n      <th colspan=\"2\">Latency (ms)</th>\n    </tr>\n    <tr>\n      <th>Fastify</th>\n      <th>FJTP</th>\n      <th>Fastify</th>\n      <th>FJTP</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr><td>~0</td><td>15,400</td><td>121,000</td><td>0.065</td><td>0.008</td></tr>\n    <tr><td>0.5</td><td>14,400</td><td>96,000</td><td>0.070</td><td>0.010</td></tr>\n    <tr><td>1</td><td>13,500</td><td>84,500</td><td>0.074</td><td>0.012</td></tr>\n    <tr><td>2</td><td>12,900</td><td>67,000</td><td>0.078</td><td>0.015</td></tr>\n    <tr><td>4</td><td>11,700</td><td>49,000</td><td>0.086</td><td>0.021</td></tr>\n    <tr><td>8</td><td>10,500</td><td>32,000</td><td>0.096</td><td>0.030</td></tr>\n    <tr><td>12</td><td>9,100</td><td>23,500</td><td>0.110</td><td>0.041</td></tr>\n    <tr><td>16</td><td>8,000</td><td>19,300</td><td>0.126</td><td>0.052</td></tr>\n    <tr><td>24</td><td>6,300</td><td>14,000</td><td>0.158</td><td>0.071</td></tr>\n    <tr><td>32</td><td>5,000</td><td>10,000</td><td>0.200</td><td>0.100</td></tr>\n    <tr><td>48</td><td>4,300</td><td>9,000</td><td>0.230</td><td>0.112</td></tr>\n    <tr><td>64</td><td>2,900</td><td>5,800</td><td>0.340</td><td>0.172</td></tr>\n    <tr><td>72</td><td>2,800</td><td>5,700</td><td>0.351</td><td>0.176</td></tr>\n    <tr><td>96</td><td>2,400</td><td>4,200</td><td>0.425</td><td>0.240</td></tr>\n    <tr><td>128</td><td>1,300</td><td>1,800</td><td>0.745</td><td>0.570</td></tr>\n    <tr><td>256</td><td>800</td><td>800</td><td>1.300</td><td>1.200</td></tr>\n    <tr><td>512</td><td>400</td><td>400</td><td>2.370</td><td>2.550</td></tr>\n    <tr><td>768</td><td>300</td><td>200</td><td>3.480</td><td>4.100</td></tr>\n  </tbody>\n</table>\n\n*Test conducted with FJTP 2.0.1, Fastify 5.7.4, Node.js v24.14.0*\n\nFJTP is best suited for scenarios where you need high bandwidth and low latency with small to medium JSON payloads (for example, a backend authentication service, which just transmits tokens or user credentials to other services).\n\n<h2>Security</h2>\nUnix Domain Sockets are not exposed to the network. Instead, they are files in the file system. This typically makes them more secure than communication over localhost. Care should still be taken to ensure that the folder which contains the Unix Domain Socket file is properly permissioned and accessible only to trusted users. This helps prevent unauthorized access to the communication channel.\n\n<h2>Server Example</h2>\n\n```js\nimport { FJTPServer } from 'fjtp';\nconst SOCKET_PATH = './secure_directory/my_socket.sock';\n\nconst options = { clientOptions: { UDSInterfaceOptions: { payloadCodecOptions: { encoding: 'ascii' } } } };\nconst server = new FJTPServer(options);\n\n// Handle incoming connections\nserver.onConnection((socket) => {\n  console.log('Client connected');\n\n  // Handle incoming messages\n  socket.onRequest((message) => {\n    console.log('Received message:', message);\n    return { anything: 'Hello from server!' };\n    //or throw an error to the client\n    throw new Error(\"Something went wrong!\");\n  });\n\n  // Handle socket disconnect\n  socket.on('close', () => {\n    console.log('Client disconnected');\n  });\n\n  // Handle socket errors\n  socket.on('error', (error) => {\n    console.error('Socket error:', error);\n  });\n});\n\n// Listen for incoming connections\nserver.listen(SOCKET_PATH, () => console.log(`Server listening on ${SOCKET_PATH}`));\n```\n\n<h2>Client Example</h2>\n\n```js\nimport { FJTPClient } from 'fjtp';\nconst SOCKET_PATH = './secure_directory/my_socket.sock';\n\nconst options = { UDSInterfaceOptions: { payloadCodecOptions: { encoding: 'ascii' } } };\nconst socket = new FJTPClient(options);\n\n// Handle socket errors\nsocket.on('error', (error) => {\n  console.error('Socket error:', error);\n});\n\n// Connect to the server\nsocket.connect(SOCKET_PATH, () => {\n  console.log(\"Connected to the server\");\n\n  // Send a message and wait for a response\n  socket.rpc({ anything: 'Hello from client!' }, 3000) //custom timeout ms\n    .then(response => {\n      console.log('Received response:', response);\n    })\n    .catch(error => {\n      console.error('RPC error:', error);\n    });\n});\n```","readmeFilename":"README.md"}