{"_id":"@dqrshan/discord-interactions","_rev":"1-5afe827d507a4d23275b3b65baf4fd92","name":"@dqrshan/discord-interactions","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@dqrshan/discord-interactions","version":"0.1.0","description":"Helpers for discord interactions","main":"dist/index.js","license":"MIT","repository":{"type":"git","url":"git+https://github.com/Dqrshan/discord-interactions.git"},"engines":{"node":">=12"},"bugs":{"url":"https://github.com/Dqrshan/discord-interactions/issues"},"homepage":"https://github.com/Dqrshan/discord-interactions","prepare":"npm run build","types":"dist/index.d.ts","keywords":["discord"],"scripts":{"build":"tsc","build:watch":"tsc --watch","format":"eslint --fix '**/*.ts' '**/*.js'","lint":"eslint '**/*.ts' '**/*.js'","test":"jest --verbose"},"dependencies":{"tweetnacl":"^1.0.3"},"devDependencies":{"@types/express":"^4.17.9","@types/jest":"^27.4.1","@types/node":"^14.14.10","@types/node-fetch":"^2.5.7","@typescript-eslint/eslint-plugin":"^5.16.0","@typescript-eslint/parser":"^5.16.0","body-parser":"^1.19.0","eslint":"^8.11.0","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.0.0","express":"^4.17.1","jest":"^27.5.1","node-fetch":"^2.6.1","prettier":"^2.2.1","ts-jest":"^27.1.3","typescript":"^4.1.2"},"gitHead":"96b44e7ed738eeb26aa576f1ffc5536e14494fb3","_id":"@dqrshan/discord-interactions@0.1.0","_nodeVersion":"18.16.0","_npmVersion":"9.7.2","dist":{"integrity":"sha512-aLHhdLoknqYYn//tbJlXBOEotpTZyEcmPF/hSaCGpdl0V8qMHsUKqal0mbVZ6eudvaQ7EWJhmzoLnstZj2MqiQ==","shasum":"1366a47ae4981d383a5b9a05969b282621e435f0","tarball":"https://registry.npmjs.org/@dqrshan/discord-interactions/-/discord-interactions-0.1.0.tgz","fileCount":9,"unpackedSize":35938,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD6cih5fdEZbjlDLUJDMSh8FNhejahCRe7FsMWoXWUvzgIhAJ3xEcjFWeGRG6Q1xWUDAoTvxWBeDQm6ldYgPZn+SLQR"}]},"_npmUser":{"name":"dqrshan","email":"darshan310268@gmail.com"},"directories":{},"maintainers":[{"name":"dqrshan","email":"darshan310268@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/discord-interactions_0.1.0_1690193703187_0.3647630710080787"},"_hasShrinkwrap":false},"0.1.1":{"name":"@dqrshan/discord-interactions","version":"0.1.1","description":"Helpers for discord interactions","main":"dist/index.js","license":"MIT","repository":{"type":"git","url":"git+https://github.com/Dqrshan/discord-interactions.git"},"engines":{"node":">=12"},"bugs":{"url":"https://github.com/Dqrshan/discord-interactions/issues"},"homepage":"https://github.com/Dqrshan/discord-interactions","prepare":"npm run build","types":"dist/index.d.ts","keywords":["discord"],"scripts":{"build":"tsc","build:watch":"tsc --watch","format":"eslint --fix '**/*.ts' '**/*.js'","lint":"eslint '**/*.ts' '**/*.js'","test":"jest --verbose"},"dependencies":{"tweetnacl":"^1.0.3"},"devDependencies":{"@types/express":"^4.17.9","@types/jest":"^27.4.1","@types/node":"^14.14.10","@types/node-fetch":"^2.5.7","@typescript-eslint/eslint-plugin":"^5.16.0","@typescript-eslint/parser":"^5.16.0","body-parser":"^1.19.0","eslint":"^8.11.0","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.0.0","express":"^4.17.1","jest":"^27.5.1","node-fetch":"^2.6.1","prettier":"^2.2.1","ts-jest":"^27.1.3","typescript":"^4.1.2"},"gitHead":"3253c6d893f2e37d4f3a4e6e94332552c0058809","_id":"@dqrshan/discord-interactions@0.1.1","_nodeVersion":"18.16.0","_npmVersion":"9.7.2","dist":{"integrity":"sha512-YQicuJtLmExicO+ARQUmFzRPI8JfMXISp6IzB/oRGf+mcv4GCmjDlLg2IQXQ7/ZVh9RxRI+ZNiGRZJeeiItEaQ==","shasum":"87f9b0b3dfaa8e5a98f9b651d98611c605ba91ca","tarball":"https://registry.npmjs.org/@dqrshan/discord-interactions/-/discord-interactions-0.1.1.tgz","fileCount":12,"unpackedSize":72890,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC9YnKXkH54ZYnl082HDXpmEaQWWpAFoI3NLyg+LFT2wgIgeO7mO4S2vMJhi9IAIfmtDyz1tnfGQ5DTjuZADcZDX8U="}]},"_npmUser":{"name":"dqrshan","email":"darshan310268@gmail.com"},"directories":{},"maintainers":[{"name":"dqrshan","email":"darshan310268@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/discord-interactions_0.1.1_1690194069252_0.9236710881505528"},"_hasShrinkwrap":false}},"time":{"created":"2023-07-24T10:15:03.093Z","0.1.0":"2023-07-24T10:15:03.634Z","modified":"2023-07-24T10:21:09.657Z","0.1.1":"2023-07-24T10:21:09.470Z"},"maintainers":[{"name":"dqrshan","email":"darshan310268@gmail.com"}],"description":"Helpers for discord interactions","homepage":"https://github.com/Dqrshan/discord-interactions","keywords":["discord"],"repository":{"type":"git","url":"git+https://github.com/Dqrshan/discord-interactions.git"},"bugs":{"url":"https://github.com/Dqrshan/discord-interactions/issues"},"license":"MIT","readme":"## discord-interactions\n\n[![version](https://img.shields.io/npm/v/discord-interactions.svg)](https://www.npmjs.com/package/discord-interactions)\n[![Build Status](https://travis-ci.com/discord/discord-interactions-js.svg?branch=main)](https://travis-ci.com/discord/discord-interactions-js)\n![Downloads](https://img.shields.io/npm/dt/discord-interactions)\n\nTypes and helper functions that may come in handy when you implement a Discord Interactions webhook.\n\n## Installation\n\n```\nnpm install @dqrshan/discord-interactions\n```\n\n## Usage\n\nUse the `InteractionType` and `InteractionResponseType` enums to figure out how to respond to a webhook.\n\nUse `verifyKey` to check a request signature:\n\n```js\nconst signature = req.get('X-Signature-Ed25519');\nconst timestamp = req.get('X-Signature-Timestamp');\nconst isValidRequest = verifyKey(req.rawBody, signature, timestamp, 'MY_CLIENT_PUBLIC_KEY');\nif (!isValidRequest) {\n    return res.status(401).end('Bad request signature');\n}\n```\n\nNote that `req.rawBody` must be populated by a middleware (it is also set by some cloud function providers).\n\nIf you're using an express-like API, you can simplify things by using the `verifyKeyMiddleware`. For example:\n\n```js\napp.post('/interactions', verifyKeyMiddleware('MY_CLIENT_PUBLIC_KEY'), (req, res) => {\n    const message = req.body;\n    if (message.type === InteractionType.APPLICATION_COMMAND) {\n        res.send({\n            type: InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE,\n            data: {\n                content: 'Hello world'\n            }\n        });\n    }\n});\n```\n\nMake sure that you do not use other middlewares like `body-parser`, which tamper with the request body, for interaction routes.\n\n## Exports\n\nThis module exports the following:\n\n### `InteractionType`\n\nAn enum of interaction types that can be POSTed to your webhook endpoint.\n\n### `InteractionResponseType`\n\nAn enum of response types you may provide in reply to Discord's webhook.\n\n### `InteractionResponseFlags`\n\nAn enum of flags you can set on your response data.\n\n### `MessageComponentTypes`\n\nAn enum of message component types that can be used in messages and modals.\n\n### Message components\n\nClasses for the different message component structures: `Button`, `ActionRow`, `StringSelectMenu`, and `TextInput`.\n\nAlso includes the enums `ButtonStyle` and `TextStyle`, and a `StringSelectOption` type.\n\n### `verifyKey(rawBody: Buffer, signature: string, timestamp: string, clientPublicKey: string): Promise<boolean>`\n\nVerify a signed payload POSTed to your webhook endpoint.\n\n### `verifyKeyMiddleware(clientPublicKey: string)`\n\nExpress-style middleware that will verify request signatures (make sure you include this before any other middleware that modifies the request body).\n","readmeFilename":"README.md"}