{"_id":"@autotelic/fastify-timestamp-signer","_rev":"3-15a2557e7cf67fc286bf32bf6d3a5f2d","name":"@autotelic/fastify-timestamp-signer","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.0":{"name":"@autotelic/fastify-timestamp-signer","version":"0.1.0","description":"A fastify plugin for signing and validating strings","main":"index.js","directories":{"test":"test"},"scripts":{"test":"tap --100 -j1 -R classic test/*.test.js","example":"fastify start example.js","lint":"standard","fix":"npm run lint -- --fix","validate":"npm run lint && npm run test"},"repository":{"type":"git","url":"git+https://github.com/autotelic/fastify-timestamp-signer.git"},"keywords":[],"author":{"name":"Autotelic Development Ltd","email":"info@autotelic.com"},"license":"MIT","bugs":{"url":"https://github.com/autotelic/fastify-timestamp-signer/issues"},"homepage":"https://github.com/autotelic/fastify-timestamp-signer#readme","dependencies":{"fastify-plugin":"^3.0.0"},"devDependencies":{"fastify":"^3.0.0","fastify-cli":"^2.5.1","husky":"^4.3.8","lint-staged":"^10.2.11","sinon":"^9.2.3","standard":"^14.3.4","tap":"^14.0.0"},"lint-staged":{"*.{js,jsx}":["npm run fix"]},"husky":{"hooks":{"pre-commit":"lint-staged && npm test"}},"gitHead":"28d31423e98d49e7fad7eb9a3272925f7e877081","_id":"@autotelic/fastify-timestamp-signer@0.1.0","_nodeVersion":"12.20.2","_npmVersion":"6.14.11","dist":{"integrity":"sha512-ZXTsTsf+PyZUQuntDiew6E90vCsvJEZuoGSX6QSTvCHHNO0SkxTeETEcvmx5V62SeOzN3U4fFd5xkh9dTNaf0g==","shasum":"4c5aaf5d12c43e8a45a054795d7fe99457f4bc87","tarball":"https://registry.npmjs.org/@autotelic/fastify-timestamp-signer/-/fastify-timestamp-signer-0.1.0.tgz","fileCount":5,"unpackedSize":7322,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgLZfACRA9TVsSAnZWagAAH0IQAJZwNyvSgO+xhLalkDHN\nM6QUeVS3KSd9POzao8N2LdRHNaQU5WOiwmz2PoHvHoSveyLt6zJ/zmmQrjQ6\nOnjYbwUqGcfEEU1OvC/jm8BfiMAS5emPPo0UEHxKSzTuf/kjP4Uw3EtYBlvf\noUIH8Zaj7Qcn9KR1G3Y58hTqLLJm1ChtfAQeb6pz71ZUBQmBzhQ7/HvU/02W\nTZEQG1CLC/pLHNaNUm98iK2c1xkb+GHTqvNNAXs16U4IZ9QBeVIQmLpLPsx4\n/mZjvNpti48rePOB1H8EHz+98lgMlTBLI15VI4adU8pis5eYqeIPwfh00V3T\nVs1fKwzexAkUZMv4e0JBjyG/lzc50pj76OSsEYeP+MpSN4aihB/6ZERyQMT4\nnKrSqMwRsvORmjrD4ZbVj0ZN3AGL6nFctQcgTT1uMztiIbXwh9cXJdpRm58k\nW6rTv3/jMd39euFKyJos5OsI/cr4CGKh0f6Qr0pRTPLCRrwS7WN533M2zKNN\nvVxpQaQmPuIrKVJe6WPdh6HV0iRuHvpL4yDZYM+La6iq7ytd0GtbRyv3p9Qf\nqQerG8d4lrB7bg4qGogrFoP8ZVZnxLOnHzDW0ZEt2QDV5v+VGdc0isVcyRmC\nspuHuibpzo55Yb6MOzNOegHxsUma/O/pZY3AhGrpsQ7c16kmYQSLAsgiuqYu\n1AUI\r\n=MRZz\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCvSagLVnJecvyIKXiaZ/c3A+1NejadXFRL3Kvagt6fFQIhAOsWKrIjBiWn17X15K1ZxBu+a8/M0SodKjA0hYy3hv/Y"}]},"_npmUser":{"name":"autotelic","email":"info+npm@autotelic.com"},"maintainers":[{"name":"autotelic","email":"info+npm@autotelic.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fastify-timestamp-signer_0.1.0_1613600704010_0.5898626165000489"},"_hasShrinkwrap":false},"0.1.1":{"name":"@autotelic/fastify-timestamp-signer","version":"0.1.1","description":"A fastify plugin for signing and validating strings","main":"index.js","types":"index.d.ts","directories":{"test":"test"},"scripts":{"test":"tap --100 -j1 -R classic test/*.test.js","example":"fastify start example.js","lint":"standard","fix":"npm run lint -- --fix","validate":"npm run lint && npm run test"},"repository":{"type":"git","url":"git+https://github.com/autotelic/fastify-timestamp-signer.git"},"keywords":[],"author":{"name":"Autotelic Development Ltd","email":"info@autotelic.com"},"license":"MIT","bugs":{"url":"https://github.com/autotelic/fastify-timestamp-signer/issues"},"homepage":"https://github.com/autotelic/fastify-timestamp-signer#readme","dependencies":{"fastify-plugin":"^3.0.0"},"devDependencies":{"fastify":"^3.0.0","fastify-cli":"^2.5.1","husky":"^4.3.8","lint-staged":"^10.2.11","sinon":"^9.2.3","standard":"^14.3.4","tap":"^14.0.0"},"lint-staged":{"*.{js,jsx}":["npm run fix"]},"husky":{"hooks":{"pre-commit":"lint-staged && npm test"}},"gitHead":"e420d91a6fbc7312555653930c539b85983ef217","_id":"@autotelic/fastify-timestamp-signer@0.1.1","_nodeVersion":"12.22.12","_npmVersion":"6.14.16","dist":{"integrity":"sha512-lPI0ViNhxu3aho5QNNJpe3b97OkdN/ov4Yb6dM7EswkhjU7kwgeNqK1osqAXSJpBAEULnGWovn4iwQM3OmhoJA==","shasum":"e5a0b0fb19e263b902dc36a21961301e87166aea","tarball":"https://registry.npmjs.org/@autotelic/fastify-timestamp-signer/-/fastify-timestamp-signer-0.1.1.tgz","fileCount":5,"unpackedSize":8405,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCUQuS10a699MkJoiKFq/oN0uGp5M90V3YMzrTF3R9juAIhAOg/5rnaLsFHF1ruD0V+HhUMuraGnCyU6nfewzyHFJpc"}]},"_npmUser":{"name":"autotelic","email":"info+npm@autotelic.com"},"maintainers":[{"name":"autotelic","email":"info+npm@autotelic.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fastify-timestamp-signer_0.1.1_1709923793082_0.32056400533279317"},"_hasShrinkwrap":false},"0.1.2":{"name":"@autotelic/fastify-timestamp-signer","version":"0.1.2","description":"A fastify plugin for signing and validating strings","main":"index.js","types":"index.d.ts","directories":{"test":"test"},"scripts":{"test":"tap --100 -j1 -R classic test/*.test.js","example":"fastify start example.js","lint":"standard","fix":"npm run lint -- --fix","validate":"npm run lint && npm run test"},"repository":{"type":"git","url":"git+https://github.com/autotelic/fastify-timestamp-signer.git"},"keywords":[],"author":{"name":"Autotelic Development Ltd","email":"info@autotelic.com"},"license":"MIT","bugs":{"url":"https://github.com/autotelic/fastify-timestamp-signer/issues"},"homepage":"https://github.com/autotelic/fastify-timestamp-signer#readme","dependencies":{"fastify-plugin":"^3.0.0"},"devDependencies":{"fastify":"^3.0.0","fastify-cli":"^2.5.1","husky":"^4.3.8","lint-staged":"^10.2.11","sinon":"^9.2.3","standard":"^14.3.4","tap":"^14.0.0"},"lint-staged":{"*.{js,jsx}":["npm run fix"]},"husky":{"hooks":{"pre-commit":"lint-staged && npm test"}},"gitHead":"5f62f2db8b6c672d5433b6e2b0217ce225a1fdb4","_id":"@autotelic/fastify-timestamp-signer@0.1.2","_nodeVersion":"12.22.12","_npmVersion":"6.14.16","dist":{"integrity":"sha512-VNlpgL0JJI4OgaCIQtjdUflBZJkhqZZ5cIsv70htSpn2xYx8UgutG3kn1W8mOFzz4lmeks2Ha2k6HXaADG+1RA==","shasum":"1bd8fafa48890534dba0d8789ea12d1b0277b56a","tarball":"https://registry.npmjs.org/@autotelic/fastify-timestamp-signer/-/fastify-timestamp-signer-0.1.2.tgz","fileCount":6,"unpackedSize":8507,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCjWgYt3bwXNtev87OFMLz2mG4sR0dD6Ih77zCFKDznOgIgc3BnrkhRHKTJKb8bFtGCNcVwp6UnzJtyv1AiV7C5+KE="}]},"_npmUser":{"name":"autotelic","email":"info+npm@autotelic.com"},"maintainers":[{"name":"autotelic","email":"info+npm@autotelic.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fastify-timestamp-signer_0.1.2_1709924036008_0.7518728967184731"},"_hasShrinkwrap":false}},"time":{"created":"2021-02-17T22:25:03.977Z","0.1.0":"2021-02-17T22:25:04.140Z","modified":"2024-03-08T18:53:56.623Z","0.1.1":"2024-03-08T18:49:53.271Z","0.1.2":"2024-03-08T18:53:56.194Z"},"maintainers":[{"name":"autotelic","email":"info+npm@autotelic.com"}],"description":"A fastify plugin for signing and validating strings","homepage":"https://github.com/autotelic/fastify-timestamp-signer#readme","keywords":[],"repository":{"type":"git","url":"git+https://github.com/autotelic/fastify-timestamp-signer.git"},"author":{"name":"Autotelic Development Ltd","email":"info@autotelic.com"},"bugs":{"url":"https://github.com/autotelic/fastify-timestamp-signer/issues"},"license":"MIT","readme":"# fastify-timestamp-signer\n\nA [Fastify](https://www.fastify.io/) plugin to timestamp/cryptographically sign strings and validate that signed strings have not been tampered with.\n\n## Usage\n\n```sh\nnpm i @autotelic/fastify-timestamp-signer\n```\n\n## Examples\n\n### Plugin Usage\n\n```js\n// index.js\nconst signer = require('@autotelic/fastify-timestamp-singer')\n\n// register fastify-timestamp-signer\nfastify.register(signer, { secret: 'secret-string' })\n\n// sign route\nfastify.get('/sign/:value', async (req, reply) => {\n  const { params: { value } } = req\n\n  const signedString = await fastify.sign(value, { salt: 'example-salt' })\n\n  reply.send({ signedString })\n})\n\n// validate route\nfastify.post('/validate', async (req, reply) => {\n  const { body: { signedString } } = req\n  const maxAge = 10\n  const validated = await fastify.validate(signedString, maxAge, { salt: 'example-salt' })\n  reply.send({ validated })\n})\n```\n\n### Example App\n\nsee [/example.js](./example.js) for a working example app.\n\n## API\n\n### Configuration\n\nThe plugin accepts the the following configuration properties:\n\n- **`secret`** : `string` - The secret used to sign/ validate a string (required).\n\n- **`algorithm`** : `string` - The algorithm used to sign/ validate a string (defaults to `sha512`).\n\n- **`delimiter`**: `string` - The delimiter used to separate the raw string, timestamp and signature (defaults to `:`).\n\n- **`encoding`**: `string` - The encoding type used to encode the signature. (defaults to `base64`)\n\n### Decorators\n\nThis plugin decorates fastify with the following methods:\n\n- **`sign`**: `function` - Generates a timestamp and cryptographically signed string.\n  - Accepts the following arguments:\n    - **`string`**: `string` - The raw string to be signed (required).\n    - **`options`**: `object` - Accepts the following parameters:\n      - **`salt`**: `string` - The salt used to hash the signature (required).\n      - **`timestamp`**: `number` - A unix timestamp used to timestamp the string (defaults to current time).\n  - Returns: `string` - A timestamped and cryptographically signed string.\n\n- **`validate`**: `function` - Validates a signed string has a valid signature and has not expired.\n  - Accepts the following arguments:\n    - **`signedString`**: `string` - The signed string to be validated (required).\n    - **`maxAge`**: `number` - The max allowable age in minutes to validate a signed string. (defaults to 5)\n    - **`options`**: `object` - Accepts the following parameters:\n      - **`salt`**: `string` - The salt used to validate the signature (required).\n      - **`validateTime`**: `number` - A unix timestamp representing when validation occurs (defaults to current time).\n","readmeFilename":"README.md"}