{"_id":"simple-service-authorizer","_rev":"26-2fb82adc582bc945a4a0926f53ec7051","name":"simple-service-authorizer","dist-tags":{"latest":"1.5.1"},"versions":{"1.0.0":{"name":"simple-service-authorizer","version":"1.0.0","description":"A simple package that centralize authorization between applications","main":"dist/index.js","types":"dist/index.d.ts","engines":{"npm":">=10.2.5","node":">=21.4.0"},"scripts":{"build":"tsc","lint":"eslint --fix ./src","test":"node --require ts-node/register --test-reporter spec --test **/**/*.test.ts"},"keywords":[],"author":"","license":"ISC","dependencies":{"jsonwebtoken":"^9.0.2"},"devDependencies":{"@types/jsonwebtoken":"^9.0.5","@types/node":"^20.10.4","@typescript-eslint/eslint-plugin":"^6.9.1","@typescript-eslint/parser":"^6.9.1","eslint":"^8.52.0","husky":"^8.0.0","prettier":"^3.0.3","prettier-plugin-organize-imports":"^3.2.4","ts-node":"^10.9.2","typescript":"^5.3.3"},"_id":"simple-service-authorizer@1.0.0","gitHead":"be71fa54513aeb4c8a64688224c8844a3424e649","_nodeVersion":"21.4.0","_npmVersion":"10.2.5","dist":{"integrity":"sha512-1xGmuhYmOjw6imapAbZ/7Ckj7JvsnMVZbwr1jOsNPm+ckGMyjSNimFQ2dPi/3It2zSzmDz/r1aCeL9WhWA+kFQ==","shasum":"8e711ff9b9473172183b2dcca7b027e31af44794","tarball":"https://registry.npmjs.org/simple-service-authorizer/-/simple-service-authorizer-1.0.0.tgz","fileCount":29,"unpackedSize":11381,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICNaaM6twRchzncGoC/J232E1ztZyU1J8ZvaNuJikZcEAiEApbqdhVFhr7rdeQzshpdnhQ3tOPDpdcvkiHmgIXob1mg="}]},"_npmUser":{"name":"thaua","email":"thaua@outlook.com"},"directories":{},"maintainers":[{"name":"thaua","email":"thaua@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-service-authorizer_1.0.0_1702677583497_0.7588437036997293"},"_hasShrinkwrap":false},"1.1.0":{"name":"simple-service-authorizer","version":"1.1.0","description":"A simple package that centralize authorization between applications","main":"dist/index.js","types":"dist/index.d.ts","engines":{"npm":">=10.2.5","node":">=21.4.0"},"scripts":{"build":"tsc","lint":"eslint --fix ./src","test":"jest"},"keywords":[],"author":"","license":"ISC","dependencies":{"jsonwebtoken":"^9.0.2"},"devDependencies":{"@types/jest":"^29.5.11","@types/jsonwebtoken":"^9.0.5","@types/node":"^20.10.4","@typescript-eslint/eslint-plugin":"^6.9.1","@typescript-eslint/parser":"^6.9.1","eslint":"^8.52.0","husky":"^8.0.0","jest":"^29.7.0","prettier":"^3.0.3","prettier-plugin-organize-imports":"^3.2.4","ts-jest":"^29.1.1","ts-node":"^10.9.2","typescript":"^5.3.3"},"_id":"simple-service-authorizer@1.1.0","gitHead":"71a48342b38a967a22377a59b946e9cff68b5ce5","_nodeVersion":"21.4.0","_npmVersion":"10.2.5","dist":{"integrity":"sha512-Keh3gLtGUEbrsI90Ed++KCPIo2IFXxbIDJboUIvtaPvO8xL/9u0IUUK08sXhYhZ8c9A4NAdD6IAcaETX1fRgWQ==","shasum":"8e816746d27af7f49aa902d5b978240d81005620","tarball":"https://registry.npmjs.org/simple-service-authorizer/-/simple-service-authorizer-1.1.0.tgz","fileCount":49,"unpackedSize":24077,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGnBI6+xrx15VY1x9fDUkBQo0Dm+w5AnabF/K3rCSvPNAiEAnbJlOPmEjmeHu/3HsRF6MpnhPNCi8jyhoKG5w6B8SM8="}]},"_npmUser":{"name":"thaua","email":"thaua@outlook.com"},"directories":{},"maintainers":[{"name":"thaua","email":"thaua@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-service-authorizer_1.1.0_1702677657981_0.05433006574087984"},"_hasShrinkwrap":false},"1.2.1":{"name":"simple-service-authorizer","version":"1.2.1","description":"A simple package that centralize authorization between applications","keywords":["authentication","authorization","jwt","service authentication","service authorization","service jwt","microservice authentication","microservice authorization","microservice jwt"],"author":{"name":"Thauã Silveira"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/thaua/simple-service-authorizer.git"},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"npm":">=10","node":">=20"},"scripts":{"build":"tsc","lint":"eslint --fix ./src","test":"jest"},"dependencies":{"jsonwebtoken":"^9.0.2"},"devDependencies":{"@types/jest":"^29.5.11","@types/jsonwebtoken":"^9.0.5","@types/node":"^20.10.4","@typescript-eslint/eslint-plugin":"^6.9.1","@typescript-eslint/parser":"^6.9.1","eslint":"^8.52.0","husky":"^8.0.0","jest":"^29.7.0","prettier":"^3.0.3","prettier-plugin-organize-imports":"^3.2.4","ts-jest":"^29.1.1","ts-node":"^10.9.2","typescript":"^5.3.3"},"_id":"simple-service-authorizer@1.2.1","gitHead":"89ecc5d31c54bcf58889a5b92b8c6d93dd352f79","bugs":{"url":"https://github.com/thaua/simple-service-authorizer/issues"},"homepage":"https://github.com/thaua/simple-service-authorizer#readme","_nodeVersion":"21.4.0","_npmVersion":"10.2.5","dist":{"integrity":"sha512-Rx+iHBpII7f8IppITulBW285iiE1cmgtFATNHX3H6TfNif/G0AJH4BZWWFWKy2Na1Kj3TDPNgxNv2GLhcXzoUQ==","shasum":"beb587e825c20a5b085a705577591e65a2102161","tarball":"https://registry.npmjs.org/simple-service-authorizer/-/simple-service-authorizer-1.2.1.tgz","fileCount":29,"unpackedSize":26305,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD5JpkirpmNJ+2hXNPpwD5TYnIdH6kwtnomFFNAikdqZwIhAM9cJ2CkBJ5RNrht7XdLkmBcpWf+ofeVgo0d6TOGyZOw"}]},"_npmUser":{"name":"thaua","email":"thaua@outlook.com"},"directories":{},"maintainers":[{"name":"thaua","email":"thaua@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-service-authorizer_1.2.1_1702765262605_0.38484789081484316"},"_hasShrinkwrap":false},"1.4.1":{"name":"simple-service-authorizer","version":"1.4.1","description":"A simple package that centralize authorization between applications","keywords":["authentication","authorization","jwt","service authentication","service authorization","service jwt","microservice authentication","microservice authorization","microservice jwt"],"author":{"name":"Thauã Silveira"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/thaua/simple-service-authorizer.git"},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"npm":">=10","node":">=20"},"scripts":{"build":"tsc","lint":"eslint --fix ./src","test":"jest"},"dependencies":{"jsonwebtoken":"^9.0.2"},"devDependencies":{"@types/jest":"^29.5.11","@types/jsonwebtoken":"^9.0.5","@types/node":"^20.10.4","@typescript-eslint/eslint-plugin":"^6.9.1","@typescript-eslint/parser":"^6.9.1","eslint":"^8.52.0","husky":"^8.0.0","jest":"^29.7.0","prettier":"^3.0.3","prettier-plugin-organize-imports":"^3.2.4","ts-jest":"^29.1.1","ts-node":"^10.9.2","typescript":"^5.3.3"},"_id":"simple-service-authorizer@1.4.1","gitHead":"2efec1b50c6352f5874c96f40611d25cbeb54408","bugs":{"url":"https://github.com/thaua/simple-service-authorizer/issues"},"homepage":"https://github.com/thaua/simple-service-authorizer#readme","_nodeVersion":"21.4.0","_npmVersion":"10.2.5","dist":{"integrity":"sha512-nlwb3pyZg0XEA91EN96PmeMrZzHR9dd7bvB3s+TpzSkYBpD7g26nnA0iUsOwXtFPZhSdQgoSpPW8lm6MxZZdZA==","shasum":"a78faf63d908226c6c0113498458e27aadf8182c","tarball":"https://registry.npmjs.org/simple-service-authorizer/-/simple-service-authorizer-1.4.1.tgz","fileCount":29,"unpackedSize":26344,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGDXAureaLVaTVPqrQ54OTCbmHptDINCwq0HLzrJpjN/AiARXk1MK7bRfK/pCxJvSoC/gxvKQpWh1I3VKVIYFjnCJw=="}]},"_npmUser":{"name":"thaua","email":"thaua@outlook.com"},"directories":{},"maintainers":[{"name":"thaua","email":"thaua@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-service-authorizer_1.4.1_1702932682557_0.24523201187658095"},"_hasShrinkwrap":false},"1.5.1":{"name":"simple-service-authorizer","version":"1.5.1","description":"A simple package that centralize authorization between applications","keywords":["authentication","authorization","jwt","service authentication","service authorization","service jwt","microservice authentication","microservice authorization","microservice jwt"],"author":{"name":"Thauã Silveira"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/thaua/simple-service-authorizer.git"},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"npm":">=10","node":">=20"},"scripts":{"build":"tsc","format":"prettier --write --check ./src --config ./.prettierrc","lint":"eslint --fix ./src","test":"jest"},"dependencies":{"jsonwebtoken":"^9.0.2"},"devDependencies":{"@types/jest":"^29.5.11","@types/jsonwebtoken":"^9.0.5","@types/node":"^20.10.4","@typescript-eslint/eslint-plugin":"^6.9.1","@typescript-eslint/parser":"^6.9.1","eslint":"^8.52.0","husky":"^8.0.0","jest":"^29.7.0","prettier":"^3.0.3","prettier-plugin-organize-imports":"^3.2.4","ts-jest":"^29.1.1","ts-node":"^10.9.2","typescript":"^5.3.3"},"_id":"simple-service-authorizer@1.5.1","gitHead":"f6cf665d13284a5864cc5a7dc3d317ae161779a6","bugs":{"url":"https://github.com/thaua/simple-service-authorizer/issues"},"homepage":"https://github.com/thaua/simple-service-authorizer#readme","_nodeVersion":"21.4.0","_npmVersion":"10.2.5","dist":{"integrity":"sha512-vdJuHwlpcjrooZeLOx5lSraetOpLwCJ7WSoVCQPLH2RJGzMctvwekO4GjoyodX9//jAbcH1wY9SQZXX+i9vrNw==","shasum":"52eae700e5822f398745c6301d9ecb9d0f93d96e","tarball":"https://registry.npmjs.org/simple-service-authorizer/-/simple-service-authorizer-1.5.1.tgz","fileCount":54,"unpackedSize":32416,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBBW/WyVX13YzAkS+411nc5YGDVuMEv762ylnhtRqJv3AiAZqDmDNALEq2B/Na7/TKDx11QqJmgtKTYSfR7f2ByNZw=="}]},"_npmUser":{"name":"thaua","email":"thaua@outlook.com"},"directories":{},"maintainers":[{"name":"thaua","email":"thaua@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-service-authorizer_1.5.1_1703338879240_0.3870442888236816"},"_hasShrinkwrap":false}},"time":{"created":"2023-12-14T00:04:53.766Z","0.0.1":"2023-12-14T00:04:53.968Z","modified":"2023-12-23T13:41:19.604Z","0.0.2":"2023-12-14T00:19:00.656Z","0.0.3":"2023-12-14T01:39:59.678Z","0.0.4":"2023-12-14T01:43:32.593Z","0.0.5":"2023-12-14T03:42:03.038Z","0.0.6":"2023-12-14T03:46:20.254Z","0.0.7":"2023-12-14T03:50:23.623Z","0.0.8":"2023-12-14T16:11:44.558Z","0.0.9":"2023-12-14T16:16:21.821Z","1.0.0":"2023-12-15T21:59:43.703Z","1.1.0":"2023-12-15T22:00:58.174Z","1.2.0":"2023-12-16T22:03:45.319Z","1.2.1":"2023-12-16T22:21:02.847Z","1.3.1":"2023-12-18T00:10:52.461Z","1.4.1":"2023-12-18T20:51:22.721Z","1.5.1":"2023-12-23T13:41:19.412Z"},"maintainers":[{"name":"thaua","email":"thaua@outlook.com"}],"description":"A simple package that centralize authorization between applications","keywords":["authentication","authorization","jwt","service authentication","service authorization","service jwt","microservice authentication","microservice authorization","microservice jwt"],"license":"MIT","readme":"<p align=\"center\">\n<a href=\"https://codeclimate.com/github/thaua/simple-service-authorizer/maintainability\"><img src=\"https://api.codeclimate.com/v1/badges/aa9f54c6e09f5bf703bf/maintainability\" /></a>\n<a href=\"https://codeclimate.com/github/thaua/simple-service-authorizer/test_coverage\"><img src=\"https://api.codeclimate.com/v1/badges/aa9f54c6e09f5bf703bf/test_coverage\" /></a>\n</p>\n\n## simple-service-authorizer\n\nThis package is a encapsulated tool that uses JWT to make simple validation in communication between internal services/applications based on a shared private secret key between them and service names.\n\nThis is a **simple** tool, so it is not a complete security for service/applications communication. Ensure you have a complete security communication approach between you services, such as:\n- Making services/applications communication always using _SSL/TLS_ (example: _HTTPS_)\n- Limiting internal services/applications to be communicated always over internal network\n- Setting expiration time for generated tokens to avoid _replay attacks_\n- Keeping _secret key_ as hide as possible\n- Rotating/changing _secret key_ (and updating it in used services/applications) frequently\n\n## Usage\n\nThe tool is based in two use cases:\n\n- Generating token for requester service.\n- Validating token on requested service.\n\n### Generating token from requester service\n\n```typescript\nimport { SimpleServiceTokenGenerator } from \"simple-service-authorizer\";\n\nconst SERVICE_NAME = 'service-a';\nconst SECRET_SST_KEY = process.env.SECRET_SST; // in this example we are getting from env var\n\nconst simpleServiceTokenGenerator = new SimpleServiceTokenGenerator({\n    secretWord: SECRET_SST_KEY,\n    serviceName: SERVICE_NAME,\n});\n\nconst token = simpleServiceTokenGenerator.generate(20); // 20 is the token expiration time in seconds, default is 30 (if not defined)\n\n// now we can request other service with the token. In this example we will use HTTP\n\nconst http = require('http');\n\nconst options = {\n    hostname: 'internal-service-b.com',\n    path: '/get-resources',\n    method: 'GET',\n    headers: {\n        'sst-token': `${token}`,\n        'sst-service-name': '${SERVICE_NAME}',\n    },\n};\n\nresponse = await http.request(options);\n```\n\n### Validating token on requested service.\n\n```typescript\nimport { SimpleServiceTokenValidator } from \"simple-service-authorizer\";\n\nconst SECRET_SST_KEY = process.env.SECRET_SST; // in this example we are getting from env var\n\nconst simpleServiceTokenValidator = new SimpleServiceTokenValidator({\n    secretWord: SECRET_SST_KEY,\n    // services' names that are allowed to request this service, with undefinition on this, all service-names will be accept\n    allowedServiceNames: ['service-a'] \n});\n\n// now we can validate the requests' tokens received. In this example we are creating a middleware for Node.js http requests\n\nconst serviceRequestValidationMiddleware = (req, res, next) => {\n  const requestorServiceName  = req.headers['sst-service-name'];\n  const requestorToken        = req.headers['sst-token'];\n\n  // validation method usage\n  const isServiceTokenValid = simpleServiceTokenValidator.validate(\n    requestorServiceName,\n    requestorToken,\n  );\n\n  if (!isServiceTokenValid) {\n    res.writeHead(403, { 'Content-Type': 'text/plain' });\n    res.end('Service request not authorized!');\n  } else {\n    console.log('Middleware: Request accepted!');\n    next();\n  }\n};\n\n```\n\n## Development\n\n[Development instructions](docs/development.md)\n\n## License\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n\n## Stay in touch\n\nFor questions or inquiries, please contact **Thauã Silveira** at [thaua@outlook.com](mailto:thaua@outlook.com).\n","readmeFilename":"README.md","homepage":"https://github.com/thaua/simple-service-authorizer#readme","repository":{"type":"git","url":"git+https://github.com/thaua/simple-service-authorizer.git"},"author":{"name":"Thauã Silveira"},"bugs":{"url":"https://github.com/thaua/simple-service-authorizer/issues"}}