{"_id":"@03gibbss/remix-auth-twitch","_rev":"1-905984ec003ddfa6f4237a340346767d","name":"@03gibbss/remix-auth-twitch","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@03gibbss/remix-auth-twitch","version":"1.0.0","main":"./build/index.js","types":"./build/index.d.ts","scripts":{"build":"tsc --project tsconfig.json","typecheck":"tsc --project tsconfig.json --noEmit","lint":"eslint --ext .ts,.tsx src/","test":"jest --config=config/jest.config.ts --passWithNoTests","coverage":"npm run test -- --coverage"},"keywords":["remix","remix-auth","auth","authentication","strategy","twitch"],"description":"A TwitchStrategy for Remix Auth, based on the OAuth2Strategy","author":{"name":"Sam Gibbs","email":"sam-gibbs1@hotmail.co.uk","url":"https://github.com/03gibbss/"},"repository":{"url":"git+https://github.com/03gibbss/remix-auth-twitch.git","type":"git"},"homepage":"https://github.com/03gibbss/remix-auth-twitch","bugs":{"url":"https://github.com/03gibbss/remix-auth-twitch/issues"},"license":"MIT","peerDependencies":{"@remix-run/server-runtime":"^1.0.0"},"devDependencies":{"@babel/core":"^7.14.2","@babel/preset-env":"^7.14.1","@babel/preset-react":"^7.13.13","@babel/preset-typescript":"^7.13.0","@remix-run/node":"^1.0.3","@remix-run/react":"^1.1.1","@remix-run/server-runtime":"^1.0.0","@types/jest":"^26.0.23","@typescript-eslint/eslint-plugin":"^4.23.0","@typescript-eslint/parser":"^4.23.0","babel-jest":"^26.6.3","eslint":"^7.26.0","eslint-config-prettier":"^8.3.0","eslint-plugin-jest":"^24.3.6","eslint-plugin-jest-dom":"^3.9.0","eslint-plugin-prettier":"^3.4.0","eslint-plugin-unicorn":"^32.0.1","jest":"^26.6.3","jest-fetch-mock":"^3.0.3","prettier":"^2.3.2","react":"^17.0.2","ts-node":"^10.8.0","typescript":"^4.3.5"},"dependencies":{"remix-auth":"^3.0.0","remix-auth-oauth2":"^1.2.2"},"gitHead":"b548160e3c94aca215a2e2506ac2eb34f12eb9ca","_id":"@03gibbss/remix-auth-twitch@1.0.0","_nodeVersion":"14.19.2","_npmVersion":"6.14.17","dist":{"integrity":"sha512-GvHJjaNL/foUJN624wQ2aCClN51E9vAWiDTGHDpl5fjnx5DqLVqvYOeiFreozSVXBL5oKnNxcD7AYoLp5b1qHA==","shasum":"dbe9c86d3c05ceb7df2df59016cd6b4f097a6860","tarball":"https://registry.npmjs.org/@03gibbss/remix-auth-twitch/-/remix-auth-twitch-1.0.0.tgz","fileCount":5,"unpackedSize":9681,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCQDdlL9DbcPzWg6z3mgOSPpV4ZEwAuuDYHamHk7lKGmwIgHcCQ0+FjnK3uOs6EbV+d99kKaU82PW2KPFGVWrT2c9k="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJilTdtACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrJKg//TniSqjX2rnhrvmV97aBDQ1DPRb+hRRcsWlEGjNsAD7jybtaz\r\nHB+lnuDw64do/PLIoJt7jSA3cCMrdP180p2wXdIqO0tajcVPXwaqwRUSVMby\r\no+BIe0zGH0RndWxhiC+Y1IBMFvh82d1LXK7k/fDHN/gCbyny1Frjw6F3sU3S\r\nXJgwkp5K3UB5oMyzA6J+zQcZmK7VP6KL1NV4OCqwQkiNRfz5+BWm60rDYFM5\r\nekb9DF6JGQ4MG/spBSfFxfkYMSCNWDS944YtPY6YQgcz89LvPimC+C0p6fj1\r\nrsw3EqowA8SQ2YZXFgvkZEL9FkCaBCDTvbkz7F4TxWStNPKe9XVhAXNZTYcg\r\nfCCmQ8wFJUn2uIDge0/6y71qYtDGCgniL5ZEVOIheiBnxish25iEzKQgDuJR\r\nb9sh7r7Vy3Ccppnr3dsTYTsbLatddJCpoX+v+u9iPASjeHdMR9p257ST6gcy\r\nZYc/4kLv8Qg2m7ZHQ9kZ6vz+Z5+O1SIEJ/EyRMNzAVetdh7fZcjtb1+YNjXQ\r\nPE/MRrxzlNaZXvZVPXvvLkb/t8MfGOt+riFXXtBxyk7wr8FZUBlhMkGkfSZU\r\ny7jsuUZW3d2rCovAXqabpDe59efLqWK82gRItrq/C+iT7BS5TwpDWBBuhxVw\r\n/vy5EruJY+I0lLQGN4O6Xk6F1bd+ZuU1/tI=\r\n=TnfQ\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"03gibbss","email":"sam-gibbs1@hotmail.co.uk"},"directories":{},"maintainers":[{"name":"03gibbss","email":"sam-gibbs1@hotmail.co.uk"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/remix-auth-twitch_1.0.0_1653946221437_0.9061766251056056"},"_hasShrinkwrap":false},"1.0.1":{"name":"@03gibbss/remix-auth-twitch","version":"1.0.1","main":"./build/index.js","types":"./build/index.d.ts","scripts":{"build":"tsc --project tsconfig.json","typecheck":"tsc --project tsconfig.json --noEmit","lint":"eslint --ext .ts,.tsx src/","test":"jest --config=config/jest.config.ts --passWithNoTests","coverage":"npm run test -- --coverage"},"keywords":["remix","remix-auth","auth","authentication","strategy","twitch"],"description":"A TwitchStrategy for Remix Auth, based on the OAuth2Strategy","author":{"name":"Sam Gibbs","email":"sam-gibbs1@hotmail.co.uk","url":"https://github.com/03gibbss/"},"repository":{"url":"git+https://github.com/03gibbss/remix-auth-twitch.git","type":"git"},"homepage":"https://github.com/03gibbss/remix-auth-twitch","bugs":{"url":"https://github.com/03gibbss/remix-auth-twitch/issues"},"license":"MIT","peerDependencies":{"@remix-run/server-runtime":"^1.0.0"},"devDependencies":{"@babel/core":"^7.14.2","@babel/preset-env":"^7.14.1","@babel/preset-react":"^7.13.13","@babel/preset-typescript":"^7.13.0","@remix-run/node":"^1.0.3","@remix-run/react":"^1.1.1","@remix-run/server-runtime":"^1.0.0","@types/jest":"^26.0.23","@typescript-eslint/eslint-plugin":"^4.23.0","@typescript-eslint/parser":"^4.23.0","babel-jest":"^26.6.3","eslint":"^7.26.0","eslint-config-prettier":"^8.3.0","eslint-plugin-jest":"^24.3.6","eslint-plugin-jest-dom":"^3.9.0","eslint-plugin-prettier":"^3.4.0","eslint-plugin-unicorn":"^32.0.1","jest":"^26.6.3","jest-fetch-mock":"^3.0.3","prettier":"^2.3.2","react":"^17.0.2","ts-node":"^10.8.0","typescript":"^4.3.5"},"dependencies":{"remix-auth":"^3.0.0","remix-auth-oauth2":"^1.2.2"},"gitHead":"4612e55485f35a28ce4adc83ce02f991ceddcef7","_id":"@03gibbss/remix-auth-twitch@1.0.1","_nodeVersion":"14.19.2","_npmVersion":"6.14.17","dist":{"integrity":"sha512-hbFYwdsgg5HiUn5CDKgya6oG2qc2vQZZhrs00PE6ulI9kuUGfN294fBg/KbjulJmilwaSgrUaA8wRpJT9zrHpg==","shasum":"92eb89b03d7d397a8d970e4c79c842009a7976c1","tarball":"https://registry.npmjs.org/@03gibbss/remix-auth-twitch/-/remix-auth-twitch-1.0.1.tgz","fileCount":5,"unpackedSize":9758,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCCbD6sr/EWzSP7ZXT37m2YLNjXeT1lq7ChwIA5g129lgIgBhoFXD7FRgoXZ8bbmo3kueSEGQrjjgi8NPvBHt+rgQk="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJilTwHACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpEeA/5ACG9ZQtA8Rf3uQrMdLTRFywzzSh97k6SX8BG/xJXrFPtt7BH\r\nDf1aEKYuFsUO/rdsetn37WvgHnFYsecq/bicLlTTIHSMLEZ+H4+cEkT25C92\r\nGIjB6Chlr4wN4i9HnkLQbZOk9Ahe9U3XMXV7x99eRkck8A2J0YAmPeuqhuGC\r\nXO2Xu+5mvpFfDIlMcwDS6YsbeFrVFsYutoaoqd0SDy4N41O8p6ptyxHFPv9C\r\nY96HKdPDn0wqYTG7TaFY8xSRtNXVBgepCeZe3njASbQBzAX6mxl4lh8fnL7e\r\nrY4j4p9iDcKb6En88zhm3IUHVNoi2MefX/mqUTngwCqVssGQ6MwNr6psAcxI\r\n0jNLKxp4OC3mJuq8pP9PHVA445b4MAY8gbQ0NIaOpTMK+k6TP38pLV3nGlCL\r\nOADT2YpfbSmUCjG8YS/m/cHNNEa5glU2fqNQ0LTNssrCAsDb7Py0pU6To/4L\r\nkR6Naxuf+xaXN3Aj1gWTOC0ziQKsjKplb4NL6SCuBD6iaFydbomWWK7tKS+j\r\n04KMG5bAnkVptofWqzWztXOhV4N5fR9ds//dN7JFV8HOqt6FUJeE4GayYclj\r\nUroNmRCb01AHC/dXRlUrYN7Um5n1u0+Q6UoPWXcEDvikHkV8eLetHduW6DXq\r\nzuiGOECXk75ZzFEkyieqSFdcThA4o50kL/0=\r\n=oKsS\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"03gibbss","email":"sam-gibbs1@hotmail.co.uk"},"directories":{},"maintainers":[{"name":"03gibbss","email":"sam-gibbs1@hotmail.co.uk"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/remix-auth-twitch_1.0.1_1653947399698_0.7064742317207537"},"_hasShrinkwrap":false}},"time":{"created":"2022-05-30T21:30:21.355Z","1.0.0":"2022-05-30T21:30:21.588Z","modified":"2022-05-30T21:50:00.049Z","1.0.1":"2022-05-30T21:49:59.894Z"},"maintainers":[{"name":"03gibbss","email":"sam-gibbs1@hotmail.co.uk"}],"description":"A TwitchStrategy for Remix Auth, based on the OAuth2Strategy","homepage":"https://github.com/03gibbss/remix-auth-twitch","keywords":["remix","remix-auth","auth","authentication","strategy","twitch"],"repository":{"url":"git+https://github.com/03gibbss/remix-auth-twitch.git","type":"git"},"author":{"name":"Sam Gibbs","email":"sam-gibbs1@hotmail.co.uk","url":"https://github.com/03gibbss/"},"bugs":{"url":"https://github.com/03gibbss/remix-auth-twitch/issues"},"license":"MIT","readme":"# TwitchStrategy\n\nThe Twitch strategy is used to authenticate users against a Twitch account. It extends the OAuth2Strategy.\n\n## Supported runtimes\n\n| Runtime    | Has Support |\n| ---------- | ----------- |\n| Node.js    | ✅          |\n| Cloudflare | ✅          |\n\n## Usage\n\n### Create an OAuth application\n\nFollow the steps on [the Twitch documentation](https://dev.twitch.tv/docs/authentication/register-app) to create a new application and get a client ID and secret.\n\n### Install via npm\n\n```tsx\nnpm i @03gibbss/remix-auth-twitch\n```\n\n### Create the strategy instance\n\n```ts\nimport { TwitchStrategy } from \"@03gibbss/remix-auth-twitch\";\n\nlet twitchStrategy = new TwitchStrategy(\n  {\n    clientID: \"YOUR_CLIENT_ID\",\n    clientSecret: \"YOUR_CLIENT_SECRET\",\n    callbackURL: \"https://example.com/auth/twitch/callback\",\n  },\n  async ({ accessToken, extraParams, profile }) => {\n    // Get the user data from your DB or API using the tokens and profile\n    const user = await db.user.findUnique({\n      where: { twitchId: profile.id },\n    });\n\n    if (user) {\n      return { id: user.id, displayName: user.displayName };\n    }\n\n    const newUser = await db.user.create({\n      data: { twitchId: profile.id, displayName: profile.display_name },\n    });\n\n    return { id: newUser.id, displayName: newUser.displayName };\n  }\n);\n\nauthenticator.use(twitchStrategy);\n```\n\n### Setup your routes\n\n```tsx\n// app/routes/login.tsx\nexport default function Login() {\n  return (\n    <Form action=\"/auth/twitch\" method=\"post\">\n      <button>Login with Twitch</button>\n    </Form>\n  );\n}\n```\n\n```tsx\n// app/routes/auth/twitch.tsx\nimport { ActionFunction, LoaderFunction, redirect } from \"remix\";\nimport { authenticator } from \"~/auth.server\";\n\nexport let loader: LoaderFunction = () => redirect(\"/login\");\n\nexport let action: ActionFunction = ({ request }) => {\n  return authenticator.authenticate(\"twitch\", request);\n};\n```\n\n```tsx\n// app/routes/auth/twitch/callback.tsx\nimport { LoaderFunction } from \"remix\";\nimport { authenticator } from \"~/auth.server\";\n\nexport let loader: LoaderFunction = ({ request }) => {\n  return authenticator.authenticate(\"twitch\", request, {\n    successRedirect: \"/dashboard\",\n    failureRedirect: \"/login\",\n  });\n};\n```\n","readmeFilename":"README.md"}