{"_id":"@danreeves/remix-auth-steam","name":"@danreeves/remix-auth-steam","dist-tags":{"latest":"2.0.0"},"versions":{"2.0.0":{"name":"@danreeves/remix-auth-steam","version":"2.0.0","main":"./build/index.js","types":"./build/index.d.ts","contributors":[{"name":"Andrii Yaroshenko","email":"haxellio@pm.me"},{"name":"Dan Reeves","email":"hey@danreev.es"}],"repository":{"url":"git+https://github.com/Andreychik32/remix-auth-steam.git","type":"git"},"scripts":{"build":"tsc --project tsconfig.json","typecheck":"tsc --project tsconfig.json --noEmit","lint":"eslint --ext .ts,.tsx src/","coverage":"npm run test -- --coverage"},"keywords":["remix","remix-auth","auth","authentication","strategy","steam","remix-steam"],"license":"MIT","peerDependencies":{"@remix-run/server-runtime":"^2"},"devDependencies":{"@babel/core":"^7.23.3","@babel/preset-env":"^7.23.3","@babel/preset-react":"^7.23.3","@babel/preset-typescript":"^7.23.3","@remix-run/server-runtime":"^2.2.0","@types/openid":"^2.0.5","@typescript-eslint/eslint-plugin":"^6.10.0","@typescript-eslint/parser":"^6.10.0","babel-jest":"^29.7.0","eslint":"^8.53.0","eslint-config-prettier":"^9.0.0","eslint-plugin-jest":"^27.6.0","eslint-plugin-jest-dom":"^5.1.0","eslint-plugin-prettier":"^5.0.1","eslint-plugin-unicorn":"^49.0.0","jest":"^29.7.0","jest-fetch-mock":"^3.0.3","prettier":"^3.0.3","typescript":"^5.2.2"},"dependencies":{"@types/steamapi":"^2.2.5","openid":"^2.0.10","remix-auth":"^3.6.0","steamapi":"^2.4.2"},"prettier":{},"_id":"@danreeves/remix-auth-steam@2.0.0","gitHead":"3c9863892b28dce7025fd03ffbeeb0d4a4e4689e","description":"This is a [Steam](https://steamcommunity.com/) strategy for [remix-auth](https://github.com/sergiodxa/remix-auth) library.","bugs":{"url":"https://github.com/Andreychik32/remix-auth-steam/issues"},"homepage":"https://github.com/Andreychik32/remix-auth-steam#readme","_nodeVersion":"20.8.0","_npmVersion":"10.1.0","dist":{"integrity":"sha512-EraxR+55kk9+W9R4MdgXAXJgIuLL0UdH2u2NHtQ1ONa4NUOsjcXdrOVMq01qYRRS1pk65N9jZ7eK4Smv66UJtg==","shasum":"7813ad3254a4707a870868d36080467ce2c7b4fe","tarball":"https://registry.npmjs.org/@danreeves/remix-auth-steam/-/remix-auth-steam-2.0.0.tgz","fileCount":7,"unpackedSize":10793,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAQXQBmIatQbiOxQOfxI8eO+czFtt4DbODuo9EOeKXISAiEA1FVw3n3AgX9p1EFRFagipfLBSdJ8CL75/VocG/pvWzk="}]},"_npmUser":{"name":"danreeves","email":"hey@danreev.es"},"directories":{},"maintainers":[{"name":"danreeves","email":"hey@danreev.es"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/remix-auth-steam_2.0.0_1699822076782_0.8525093109699251"},"_hasShrinkwrap":false}},"time":{"created":"2023-11-12T20:47:56.715Z","2.0.0":"2023-11-12T20:47:56.939Z","modified":"2023-11-12T20:47:57.226Z"},"maintainers":[{"name":"danreeves","email":"hey@danreev.es"}],"description":"This is a [Steam](https://steamcommunity.com/) strategy for [remix-auth](https://github.com/sergiodxa/remix-auth) library.","homepage":"https://github.com/Andreychik32/remix-auth-steam#readme","keywords":["remix","remix-auth","auth","authentication","strategy","steam","remix-steam"],"repository":{"url":"git+https://github.com/Andreychik32/remix-auth-steam.git","type":"git"},"contributors":[{"name":"Andrii Yaroshenko","email":"haxellio@pm.me"},{"name":"Dan Reeves","email":"hey@danreev.es"}],"bugs":{"url":"https://github.com/Andreychik32/remix-auth-steam/issues"},"license":"MIT","readme":"# Remix Auth Steam Strategy\r\n\r\nThis is a [Steam](https://steamcommunity.com/) strategy for [remix-auth](https://github.com/sergiodxa/remix-auth) library.\r\n\r\n## Supported runtimes\r\n\r\n| Runtime    | Has Support |\r\n| ---------- | ----------- |\r\n| Node.js    | ✅          |\r\n| Cloudflare | Not tested  |\r\n\r\n## How to use\r\n\r\n### Installation\r\n\r\nPlease, use\r\n\r\n```bash\r\nnpm i remix-auth-steam\r\n```\r\n\r\nor\r\n\r\n```bash\r\nyarn add remix-auth-steam\r\n```\r\n\r\n### File structure\r\n\r\nTo properly use the library, you need to maintain these additional files in your `app` directory:\r\n\r\n`app/services/auth.server.ts`:\r\n\r\n```ts\r\nimport { Authenticator } from \"remix-auth\";\r\nimport { sessionStorage } from \"~/services/session.server\";\r\nimport { SteamStrategy, SteamStrategyVerifyParams } from \"remix-auth-steam\";\r\n\r\nexport type User = SteamStrategyVerifyParams;\r\n\r\nexport let authenticator = new Authenticator<User>(sessionStorage);\r\n\r\nauthenticator.use(\r\n  new SteamStrategy(\r\n    {\r\n      returnURL: \"http://localhost:3000/auth/steam/callback\",\r\n      apiKey: \"YOUR_STEAM_API_KEY\", // you can get it here: https://steamcommunity.com/dev/apikey\r\n    },\r\n    async (user) => user, // perform additional checks for user here, I just leave this to SteamStrategyVerifyParams value\r\n  ),\r\n);\r\n```\r\n\r\n`app/services/session.server.ts`:\r\n\r\n```ts\r\nimport { createCookieSessionStorage } from \"remix\";\r\n\r\nconst calculateExpirationDate = (days: number) => {\r\n  const expDate = new Date();\r\n  expDate.setDate(expDate.getDate() + days);\r\n  return expDate;\r\n};\r\n\r\n// export the whole sessionStorage object\r\nexport let sessionStorage = createCookieSessionStorage({\r\n  cookie: {\r\n    name: \"_session\", // use any name you want here\r\n    sameSite: \"lax\", // this helps with CSRF\r\n    path: \"/\", // remember to add this so the cookie will work in all routes\r\n    httpOnly: true, // for security reasons, make this cookie http only\r\n    secrets: [\"s3cr3t\"], // replace this with an actual secret\r\n    secure: process.env.NODE_ENV === \"production\", // enable this in prod only\r\n    expires: calculateExpirationDate(7), // expire cookie after 7 days\r\n  },\r\n});\r\n\r\n// you can also export the methods individually for your own usage\r\nexport let { getSession, commitSession, destroySession } = sessionStorage;\r\n```\r\n\r\n`app/routes/auth/steam.tsx`:\r\n\r\n```tsx\r\nimport { LoaderFunction } from \"remix\";\r\nimport { authenticator } from \"~/services/auth.server\";\r\n\r\nexport let loader: LoaderFunction = async ({ request }) => {\r\n  await authenticator.authenticate(\"steam\", request, {});\r\n};\r\n```\r\n\r\n`app/routes/auth/steam/callback.tsx`:\r\n\r\n```tsx\r\nimport { LoaderFunction } from \"remix\";\r\nimport { authenticator } from \"~/services/auth.server\";\r\n\r\nexport let loader: LoaderFunction = ({ request }) => {\r\n  return authenticator.authenticate(\"steam\", request, {\r\n    successRedirect: \"/\",\r\n    failureRedirect: \"/login\",\r\n  });\r\n};\r\n```\r\n\r\n### Utilization\r\n\r\nAfter that, navigate to `localhost:3000/auth/steam` to check if it works. Here is an example of checking if user is authenticated:\r\n`app/routes/index.tsx`:\r\n\r\n```tsx\r\nimport { LoaderFunction, useLoaderData } from \"remix\";\r\nimport { authenticator, User } from \"~/services/auth.server\";\r\n\r\nexport let loader: LoaderFunction = async ({ request }) => {\r\n  const user = await authenticator.isAuthenticated(request);\r\n  return user;\r\n};\r\n\r\nexport default function Index() {\r\n  const user: User | null = useLoaderData();\r\n\r\n  return (\r\n    <div style={{ fontFamily: \"system-ui, sans-serif\", lineHeight: \"1.4\" }}>\r\n      {user ? <h1>User name: {user!.nickname}</h1> : <h1>Not authenticated</h1>}\r\n    </div>\r\n  );\r\n}\r\n```\r\n\r\nIf you are logged in, you should see your username from Steam API, otherwise you will see `Not authenticated` message.\r\n\r\n# Contributing\r\n\r\nYour contributions are highly appreciated! Please, submit any pull requests or issues you found!\r\n","readmeFilename":"README.md"}