{"_id":"@0xtld/node-security","name":"@0xtld/node-security","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@0xtld/node-security","version":"1.0.0","main":"dist/index.cjs","scripts":{"test":"jest","prebuild":"npm test","build":"tsup","dev":"tsup --watch","clean":"rimraf dist","prepublishOnly":"npm run clean && npm run build && npm run typecheck","publish":"npm run prepublishOnly && npm publish","typecheck":"tsc -p tsconfig.json --noEmit"},"keywords":["security","hashing","csrf","crypto","node"],"author":{"name":"tyluudinh"},"license":"MIT","description":"Lightweight Node.js security utilities (timing-safe compare, password hashing, CSRF tokens)","type":"module","module":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"}},"repository":{"type":"git","url":"git+ssh://git@github.com/tyluudinh/node-security.git"},"engines":{"node":">=18"},"sideEffects":false,"publishConfig":{"access":"public"},"devDependencies":{"@types/jest":"^30.0.0","@types/node":"^24.6.2","jest":"^29.7.0","rimraf":"^6.0.1","ts-jest":"^29.4.4","ts-node":"^10.9.2","tsup":"^8.5.0","typescript":"^5.9.3"},"dependencies":{"node-fetch":"^3.3.2"},"_id":"@0xtld/node-security@1.0.0","bugs":{"url":"https://github.com/tyluudinh/node-security/issues"},"homepage":"https://github.com/tyluudinh/node-security#readme","_nodeVersion":"23.7.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-f3SQS4n+4/9FX9X51NnWIjvakDvfqaiw7k29ha4UYzgcGLuCpQUnMg5scETWxtUx9QAISSAdhn4lpqnJy9n0eQ==","shasum":"2f92080ddeee975aa24700d9ba0593ee4117d6cd","tarball":"https://registry.npmjs.org/@0xtld/node-security/-/node-security-1.0.0.tgz","fileCount":8,"unpackedSize":123235,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIBbwVfTWN/Uy7DzNcUC1RMkpDSjrUYznp6KBPNQXl3AqAiEAmKtY3iy/SMXN32cqpPbJLBw7Gpgv3jiiDIJ1cbSQPl8="}]},"_npmUser":{"name":"0xtld","email":"kingcan007.ise@gmail.com"},"directories":{},"maintainers":[{"name":"0xtld","email":"kingcan007.ise@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/node-security_1.0.0_1759481144711_0.6873983379921589"},"_hasShrinkwrap":false}},"time":{"created":"2025-10-03T08:45:44.553Z","1.0.0":"2025-10-03T08:45:44.910Z","modified":"2025-10-03T08:45:45.331Z"},"maintainers":[{"name":"0xtld","email":"kingcan007.ise@gmail.com"}],"description":"Lightweight Node.js security utilities (timing-safe compare, password hashing, CSRF tokens)","homepage":"https://github.com/tyluudinh/node-security#readme","keywords":["security","hashing","csrf","crypto","node"],"repository":{"type":"git","url":"git+ssh://git@github.com/tyluudinh/node-security.git"},"author":{"name":"tyluudinh"},"bugs":{"url":"https://github.com/tyluudinh/node-security/issues"},"license":"MIT","readme":"# @0xtld/node-security\n\nLightweight Node.js security utilities: password hashing/verify, timing-safe compare, XSS detection, and safe file buffer fetch.\n\n## Install\n\n```bash\nnpm i @0xtld/node-security\n```\n\n## Quick start\n\n```ts\nimport {\n  // password utils\n  hashPassword,\n  verifyPassword,\n  timingSafeCompare,\n  // xss utils\n  xssAttackDetection,\n  validateXssAttack,\n  // file/common utils\n  isURL,\n  isPath,\n  isFileLocal,\n  getFileContentBuffer,\n} from '@0xtld/node-security';\n\n// Passwords\nconst stored = hashPassword('secret');\nverifyPassword('secret', stored); // true\ntimingSafeCompare('a', 'a'); // true\n\n// XSS\nconst res = xssAttackDetection('<script>alert(1)</script>');\n// res.isXss === true\n// Throws if payload contains XSS patterns\n// validateXssAttack('<img src=x onerror=alert(1)>');\n\n// File helpers\nawait isFileLocal(__filename); // true\nconst data = await getFileContentBuffer('https://example.com');\n// data: { buffer: Buffer, type: string }\n```\n\n## API\n\n- Password\n  - `hashPassword(password: string, opts?) => string`\n  - `verifyPassword(password: string, stored: string) => boolean`\n  - `timingSafeCompare(a: string|Buffer, b: string|Buffer) => boolean`\n\n- XSS\n  - `xssAttackDetection(text: string) => { isXss, patterns, severity, message }`\n  - `validateXssAttack(payload: any) => void | throws`\n\n- Common/File\n  - `isURL(input: string) => boolean`\n  - `isPath(input: string) => boolean`\n  - `isFileLocal(path: string) => Promise<boolean>`\n  - `getFileContentBuffer(urlOrPath: string) => Promise<{ buffer: Buffer; type: string } | null>`\n\n## Scripts\n\n```bash\nnpm run build      # bundle CJS/ESM + d.ts\nnpm test           # run jest tests\nnpm publish --access public\n```\n\n## License\n\nMIT","readmeFilename":"README.md","_rev":"1-119bc338a73a07363c2f74295738fc3b"}