{"_id":"@dodoinblue/simple-apikey","name":"@dodoinblue/simple-apikey","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@dodoinblue/simple-apikey","version":"0.0.1","description":"Basic API key mechanism with key rotation","main":"dist/index.js","types":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/dodoinblue/simple-apikey.git"},"license":"MIT","scripts":{"clean":"rimraf dist coverage","build":"npm run clean && tsc","pretty":"prettier --config .prettierrc '(src|test)/**/*.ts' --write","lint":"eslint . --ext .ts","lint:fix":"eslint . --ext .ts --fix","test":"jest --env=node --colors --coverage test"},"devDependencies":{"@types/jest":"^27.4.1","@types/node":"^17.0.27","@typescript-eslint/eslint-plugin":"^5.21.0","eslint":"^8.14.0","jest":"^27.5.1","prettier":"^2.6.2","rimraf":"^3.0.2","ts-jest":"^27.1.4","typescript":"^4.6.3"},"jest":{"moduleFileExtensions":["js","json","ts"],"rootDir":".","testRegex":".*\\.spec\\.ts$","transform":{"^.+\\.(t|j)s$":"ts-jest"},"collectCoverageFrom":["src/**/*.(t|j)s"],"coverageDirectory":"./coverage","testEnvironment":"node"},"gitHead":"c3c3d6d147872f3ad42fd9b3f17e5d13358bc217","bugs":{"url":"https://github.com/dodoinblue/simple-apikey/issues"},"homepage":"https://github.com/dodoinblue/simple-apikey#readme","_id":"@dodoinblue/simple-apikey@0.0.1","_nodeVersion":"16.14.2","_npmVersion":"8.5.0","dist":{"integrity":"sha512-N4jYCPsVBNoQGWBbbSqL/aPhssGDJEJSWNPalwveQtjkgnZF+EC0g6BFMxd8vbkR6+Xx7PeeOdKF3cvTaWopnA==","shasum":"52cc55b3af45c6da3a40d653f801e5aede69e797","tarball":"https://registry.npmjs.org/@dodoinblue/simple-apikey/-/simple-apikey-0.0.1.tgz","fileCount":12,"unpackedSize":10860,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICud3HEphZoSvivR7emeAnq0nZnOeeGoT7tOi0jqucpPAiEA57VtBYkZ/o31yOJTvaFvtVTRxLswco5y3wEe782Fp5g="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiaL+eACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo+fg//YR5EwcmUAYSuXsRiKiO86jGA15AVck/kdY0GyH5wfvnrMd5+\r\nRUCGaRFXvZTuW7++j3Ddb+CM1lkEAhkvpYVtFiLDuPEEFYHRKatxH0dblfhG\r\n1+yveLL6zKsMZUd1yzUAvIa8FU8i2Vnp3feNPsFPPBiOh6CYDKF7+UfnaQTt\r\nMiysIIV6fFg7/aW+/6d5laPjNhZzHIfOVBkOaLWQB2952Hh6mybyTcqd+QjH\r\nKAbVKBIxzlfbHklQvJDxKpd7t7ANmTWUcuBnfIcNF1d4c8JAv8FQoCGknC77\r\nuEWT5g3vfWOdl4pfjBaAO6MnbOgGSVzlMlIMQd6twleCQhgh5ADKpaJybyqR\r\nPAPD8Dzobi0L8IxwUtPA6aiT7D0b7FjAcz6ybC20YsRlxief8KYbZuQHnIp3\r\n8ftrnIT8TJ4Us4CoUdZ48Ky3LpXWcJF/Ic49y8zP0fXzrJDvj1B+vIWhBvta\r\nxo4Nm5XE9YQTlCkTuWB/B67aPGadjsSl5PRpFkjYtTqBhmjdPd8agpduekxN\r\nkuJnDSrGMQZx3MU/Qo/3CjZw33HZRYnoqZcEN5PphehYLFWTP7tKpYl1Yp7g\r\nKBSvohFXkG/696d6+mB2ryOq9yLqQS1P/c/NLZEazQVUPbiReh5Eq3WJ5I4Z\r\nHFIZtotuFn8B2eDWgK1dOczR/JOExhBWy38=\r\n=dTU3\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"dodoinblue","email":"dodoinblue@gmail.com"},"directories":{},"maintainers":[{"name":"dodoinblue","email":"dodoinblue@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-apikey_0.0.1_1651031966488_0.806775579389774"},"_hasShrinkwrap":false}},"time":{"created":"2022-04-27T03:59:26.425Z","0.0.1":"2022-04-27T03:59:26.694Z","modified":"2022-04-27T03:59:26.824Z"},"maintainers":[{"name":"dodoinblue","email":"dodoinblue@gmail.com"}],"description":"Basic API key mechanism with key rotation","homepage":"https://github.com/dodoinblue/simple-apikey#readme","repository":{"type":"git","url":"git+https://github.com/dodoinblue/simple-apikey.git"},"bugs":{"url":"https://github.com/dodoinblue/simple-apikey/issues"},"license":"MIT","readme":"# Simple ApiKey\n\nA small util to generate and authenticate API secret, using `aes-256-cbc`.\n\nThe generated secrets contain three parts:\n\n* Master secret identifier: This identifies which master secret to be used to decode the secret. This allows smooth swapping of the master secret. The identifier is a YYYY-MM-DD string, so master secret cannot be updated twice in a day.\n\n* Api key: The ID of the API key. Only keys in the validKeys list will be authenticated. This allows api key revocation.\n\n* Free text: this part can carry any information, such as userId, etc.\n\n## Usage\n\n```javascript\n// Encode\nconst gen = new ApiKeyGenerator(masterSecret);\nconst orgId = 'dummy+/name-=(*xyz';\nconst result = gen.createApiKey(orgId);\n\n// result = {\n//   orgId: 'dummy+/name-=(*xyz',\n//   issuedAt: '2022-01-28T00:00:00.000Z',\n//   apiKey: 'H/Tpb4sWjiijSCMyknqH6A==',\n//   apiSecret: 'MjAyMi0wMS0yOB/06W+LFo4oo0gjMpJ6h+hAqCqb2LMTeN6VUbGbz7+ZT5PTeB2xiCNqiMUepuepLg=='\n// }\n\n// Decode\nconst verifier = new ApiKeyVerifier(\n  masterSecret,\n  ['H/Tpb4sWjiijSCMyknqH6A=='], // validApiKeys\n  '2022-04-11', // Optional: masterSecretPublishedDate\n  previousMasterSecret // Optional: previous master key\n);\nconst apiSecret =\n  'MjAyMi0wMS0yOB/06W+LFo4oo0gjMpJ6h+hAqCqb2LMTeN6VUbGbz7+ZT5PTeB2xiCNqiMUepuepLg==';\nconst verifiedResult = verifier.validateApiSecret(apiSecret);\n// verifiedResult = 'dummy+/name-=(*xyz'\n```","readmeFilename":"README.md"}