{"_id":"@blendededge/simple-koa-shopify-auth","_rev":"2-7708c2c93c4b762979c2a1913d9a453b","name":"@blendededge/simple-koa-shopify-auth","dist-tags":{"latest":"2.1.12"},"versions":{"2.1.10":{"name":"@blendededge/simple-koa-shopify-auth","version":"2.1.10","description":"A better, simplified version of the (no longer supported) @Shopify/koa-shopify-auth middleware library. It removes the use of cookies for sessions (which greatly smooths the auth process), replaces a deprecated API call, and supports v2 of the official @s","author":{"name":"TheSecurityDev"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/TheSecurityDev/simple-koa-shopify-auth.git"},"homepage":"https://github.com/TheSecurityDev/simple-koa-shopify-auth#readme","bugs":{"url":"https://github.com/TheSecurityDev/simple-koa-shopify-auth/issues"},"keywords":["shopify","koa","middleware","auth"],"main":"lib/index.js","scripts":{"build":"tsc","test":"echo \"Error: no test specified\" && exit 1","prepublish":"npm run build && npm version"},"dependencies":{},"peerDependencies":{"@shopify/shopify-api":"^2.1.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"devDependencies":{"@types/koa":"^2.13.4","typescript":"^4.8.3"},"types":"./lib/index.d.ts","gitHead":"94adc6be986302beacd53e49cc6f1f6070ac5147","_id":"@blendededge/simple-koa-shopify-auth@2.1.10","_nodeVersion":"14.19.1","_npmVersion":"9.2.0","dist":{"integrity":"sha512-ehIy7rZYOS6AuPjOWQlyTdUpiosLCT7wSdArOVAJ7covXLch39GIZm8kWSLwVNTPn8VMwSHGnB0vNpma7B6XUA==","shasum":"6ce1469301025a3e5d9137811adc23c67606fc8e","tarball":"https://registry.npmjs.org/@blendededge/simple-koa-shopify-auth/-/simple-koa-shopify-auth-2.1.10.tgz","fileCount":16,"unpackedSize":171750,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICuDOFsi4HV8EsSEZufWXBmPLkWLXCNKP4ij17fblCk8AiBBTR1xz4SvuJof0Yb1UIfcCwgeB2QGnoHtRt7DYROuUw=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj86g/ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoIDRAAifO9dZZFwrGlom+Pg4Piuhq/WkUp+vtYcOmeGyzrwX8tWnVY\r\nlev1D7Sk/H95s+xHlMfEe1s3EtjBFnZtHhBGCK1ioRPp8OlxIuexbyQ3LzfH\r\nE7CsTTQPRQ4dDdVwIflpf7lKnOvHqM00A45TZA7ppNEOcIaQ7WR9FHdjQjTZ\r\nhrEzx6YkPw3juujAuSfT5jH55YrLk9Soeh/3m/1lSeTKZYP0340xbv3Xbq12\r\nAXktoAoA1re+fHSjS7US+ju2UgmOpp0ZLFUX85tAEtrMA8tk3IPBlWSvaQBu\r\nCp6gwOk/UzsvXVxFcDPq1mk/9UuuvjhA0nHmwFxd5muZn2AuZtyqy4WG/Fgu\r\nAi6h1l72tGhYl9CYPRn+PqvdUUdlDBGHexfrfXJ6FQG8x+u5Fgn+E+QvELsS\r\nw4FlaW08sWH6t0vc8IvCZVaI8mg1zmhaVy6crhv1XDtv0iSdqKiampdAax+J\r\nBhgtA1IxFJwE1jBfr1Ui1szcJFoZTflUR8yxn86KuvPAZY5MNUTTLSVJHpjU\r\nxotRmTKmGylRsZq9d1XzWF/f3eADIIUaimQSCV0zFjVAWOTK1B2awGOKWLvX\r\n7it8eaG8fWOxgj1+TZxpZg8KlF9poSvRlDXRi3Awgxhc9oZw9PH9l/9wy+rO\r\nLzcFTYWk75Wj9PuxWk51EO2HP7GLxSxgLEM=\r\n=rM0F\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"blendededge","email":"robb@blendededge.com"},"directories":{},"maintainers":[{"name":"blendededge","email":"robb@blendededge.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-koa-shopify-auth_2.1.10_1676912703812_0.5342951816928023"},"_hasShrinkwrap":false},"2.1.11":{"name":"@blendededge/simple-koa-shopify-auth","version":"2.1.11","description":"A better, simplified version of the (no longer supported) @Shopify/koa-shopify-auth middleware library. It removes the use of cookies for sessions (which greatly smooths the auth process), replaces a deprecated API call, and supports v2 of the official @s","author":{"name":"TheSecurityDev"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/TheSecurityDev/simple-koa-shopify-auth.git"},"homepage":"https://github.com/TheSecurityDev/simple-koa-shopify-auth#readme","bugs":{"url":"https://github.com/TheSecurityDev/simple-koa-shopify-auth/issues"},"keywords":["shopify","koa","middleware","auth"],"main":"lib/index.js","scripts":{"build":"tsc","test":"echo \"Error: no test specified\" && exit 1","prepublish":"npm run build"},"dependencies":{},"peerDependencies":{"@shopify/shopify-api":"^2.1.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"devDependencies":{"@types/koa":"^2.13.4","typescript":"^4.8.3"},"types":"./lib/index.d.ts","gitHead":"eb322f5c8be560ec6d7ec7c163fa84132f9b0cb8","_id":"@blendededge/simple-koa-shopify-auth@2.1.11","_nodeVersion":"14.19.1","_npmVersion":"9.2.0","dist":{"integrity":"sha512-PpV9vxeaAvpgBMsNa93EWZk9aTxuloXGcl5pDGV9hNwEkuOOPsCzLssU8avFEAzvC7z5T1hua7uU64UNleX8lw==","shasum":"abb307eedb4b016cc898695362dd70dc572bb035","tarball":"https://registry.npmjs.org/@blendededge/simple-koa-shopify-auth/-/simple-koa-shopify-auth-2.1.11.tgz","fileCount":16,"unpackedSize":171735,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBBPrO5OZqmECNIWoBEaicvmJEnG0eQ0PqOuFhO1e/lSAiBPRXHbpVt1PiXggfo+2vQiv8fg0P/aQwvwaRGLm1pd0Q=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj87xQACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo1uBAAlR87BZbYL6Ks0VK31uj3jzSQDRxu0euOUPiwAJV5zMQzuHqJ\r\nxizaGOqI7qjUdwEc7Dcreu+IQ1O8OqfZK/gv5xe2xgjLvOj19WOEl3/wjZUQ\r\nV0d2ntkJzm5S2Bw2AaJoKV0711X0oWP7hjE1y1+J1cj5ipNViNGVaFI5HaY8\r\nP7hiIR6ZP4m3HAL5iO7Dmts861I0YyDaF9wgliYJA4HHgdutCfh8vFkKLpHB\r\n/F6PbuRWKpD8JA6T/X0pjdNJHQv9UNH6VgMS4rdykXt6rIvzJCGwD+T6CoqU\r\nucKhiYZ4oB9DGSU0lMMefZ0fo2D+1iHvjiffbL6M9yPo7GoU2rj4GRUQKGsc\r\nS8VKReccxb0uQNRkg1Av+vMnZ/ZDE7CnLTUliNM3eJ8SYe63W2KixHG72zmf\r\nAQFyoaDNtRhYTVMHs+rhwjGKOynSqYGqHW83FUPmRg/9NirUZsvZRqvdSqxd\r\nu2STqRjktQl3ITZqnGYEVnLO9vPFkCXflCeouwkbNH99sXODzPWg3kf1gBp2\r\njGNF1O/2Yf7RC5drqHr3Yy6g9oLNNAxlgnm18YcB+viqBeTWNGv343YaXkG1\r\nLIgeoOgOKORVWNjc5ti8yxiPh81uPMshotqpBkNdauPNgh1XjB1dMkaT2lI3\r\nwkZ/9EaIbU/W62S0Fv3/cSgUL2zxE36yCIE=\r\n=vmJy\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"blendededge","email":"robb@blendededge.com"},"directories":{},"maintainers":[{"name":"blendededge","email":"robb@blendededge.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-koa-shopify-auth_2.1.11_1676917840231_0.5879751674017111"},"_hasShrinkwrap":false},"2.1.12":{"name":"@blendededge/simple-koa-shopify-auth","version":"2.1.12","description":"A better, simplified version of the (no longer supported) @Shopify/koa-shopify-auth middleware library. It removes the use of cookies for sessions (which greatly smooths the auth process), replaces a deprecated API call, and supports v2 of the official @s","author":{"name":"TheSecurityDev"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/TheSecurityDev/simple-koa-shopify-auth.git"},"homepage":"https://github.com/TheSecurityDev/simple-koa-shopify-auth#readme","bugs":{"url":"https://github.com/TheSecurityDev/simple-koa-shopify-auth/issues"},"keywords":["shopify","koa","middleware","auth"],"main":"lib/index.js","scripts":{"build":"tsc","test":"echo \"Error: no test specified\" && exit 1","prepublish":"npm run build"},"dependencies":{},"peerDependencies":{"@shopify/shopify-api":"^2.1.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"devDependencies":{"@types/koa":"^2.13.4","typescript":"^4.8.3"},"types":"./lib/index.d.ts","gitHead":"cc769ef4273fd6e346de55fdec395195cd72d856","_id":"@blendededge/simple-koa-shopify-auth@2.1.12","_nodeVersion":"14.19.1","_npmVersion":"9.2.0","dist":{"integrity":"sha512-7+zlKEvJBRoZp7PJDI7NUDMXFF0jftkIrThWQ+Bu6ms5Y4+V5M+QOPc08KNOMM71j9ZWvKvlhG7/W+W6ApdOCg==","shasum":"11b29e26fe5a9182b52bfa193c88d4e76c7ec8e2","tarball":"https://registry.npmjs.org/@blendededge/simple-koa-shopify-auth/-/simple-koa-shopify-auth-2.1.12.tgz","fileCount":16,"unpackedSize":171735,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDxhIUx8BoaBfMFcZOnnXWczJCZTMHRE+BcXQ1X7bqjvwIhAOXGCsbAQK8xWYZ4PhNFvPsDffkroFYi/+ffOeYDtkLD"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj8/BNACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp6vA//ZFKth6FG5TYiIco5e/CwEUm8BhCLysy/hC2A+40yvrzHS20t\r\nNBb6uIVaLIhedKTZejkj4gJimc2sYRgYXQywcoiPvyStHdFQWPbwKoQJy0Fh\r\njKe0G7kJcdEq809/ag2xzFEe9RxktiT5O0udkNOujQSaV/gzdGmEhBig/+71\r\nEdH0Hxs6F9hxNzK/G2PGrhQMV7OxhrnKyYe/tdngvMGyjHoHcrAJkCEkm/Cs\r\nLH6hCGH+G5NywgV9RQUrdxk/2VL5EfnmjgfHAAt+LvrcLTgXeIh9R/kxiC7v\r\nzr0wDkdnrSSYKDlwmqtX6UZ6xbEYTOfTsXFrEPg7e8m6+dAZSJl0vG/voZXV\r\n92/GatF2UJv8ulxxtSyuRElcuC4gZvwQc623uNy7c+rOSrTMgMsNH1iwkAHm\r\nFQJVRXMD8JG9bn8f63CEY5vzFT06xi79kEbAadr5jlE/8jLmkrn36sjazA43\r\n6k+gWkk/Yq9glHGF3bz8syJ4hgqgGAcroaNnFTNOSdgtnYTzLjSDRX2B0zU4\r\nmtue7hRvnKX80VECZ21am+pFKqkpz+s+Bs1Ab+ALVpitIEo7Wy7viPZsrg7f\r\nUFSPP9GyCBScyCqzV3sqLvRchJdKcjLh39irb+tGK/SK81XTCxkrEq4JONez\r\nqICT+3pwXQiQG/Piv3KyHoi868/O76O/1KQ=\r\n=YAu/\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"blendededge","email":"robb@blendededge.com"},"directories":{},"maintainers":[{"name":"blendededge","email":"robb@blendededge.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-koa-shopify-auth_2.1.12_1676931149244_0.5733755792597293"},"_hasShrinkwrap":false}},"time":{"created":"2023-02-20T17:05:03.742Z","2.1.10":"2023-02-20T17:05:03.962Z","modified":"2023-02-20T22:12:29.509Z","2.1.11":"2023-02-20T18:30:40.387Z","2.1.12":"2023-02-20T22:12:29.419Z"},"maintainers":[{"name":"blendededge","email":"robb@blendededge.com"}],"description":"A better, simplified version of the (no longer supported) @Shopify/koa-shopify-auth middleware library. It removes the use of cookies for sessions (which greatly smooths the auth process), replaces a deprecated API call, and supports v2 of the official @s","homepage":"https://github.com/TheSecurityDev/simple-koa-shopify-auth#readme","keywords":["shopify","koa","middleware","auth"],"repository":{"type":"git","url":"git+https://github.com/TheSecurityDev/simple-koa-shopify-auth.git"},"author":{"name":"TheSecurityDev"},"bugs":{"url":"https://github.com/TheSecurityDev/simple-koa-shopify-auth/issues"},"license":"MIT","readme":"# simple-koa-shopify-auth\n\nhttps://www.npmjs.com/package/simple-koa-shopify-auth\n\n#### NOTE: This package is not maintained by or affiliated with Shopify.\n\n## Description:\n\nA better, simplified version of the (no longer supported) [@Shopify/koa-shopify-auth](https://github.com/Shopify/koa-shopify-auth) middleware library. It removes the use of cookies for sessions (which greatly smooths the auth process by requiring fewer redirects in some cases), replaces a deprecated API call, and supports v5 of the official [@shopify/shopify-api](https://github.com/Shopify/shopify-node-api) package.\n\n## Installation:\n\n```\nnpm i simple-koa-shopify-auth\n```\n\n## Requirements:\n\n**This package assumes you have `@shopify/shopify-api` v5 already installed. If you are on a lower version you will need to upgrade to the latest version with `npm i @shopify/shopify-api@latest`.**\n\n#### WARNING:\n\n**Please [check the changelog](https://github.com/Shopify/shopify-api-node/blob/v5.0.1/CHANGELOG.md) to see all the changes, and update your code accordingly.**\n\n## Usage:\n\nThe usage is very similar to [@Shopify/koa-shopify-auth](https://github.com/Shopify/koa-shopify-auth#readme) (which you should check for more examples), **but there are a few differences, so it isn't a drop-in replacement.**\n\n### Import the middleware functions (ES6 syntax):\n\n```js\nimport { createShopifyAuth, verifyRequest } from \"simple-koa-shopify-auth\";\n```\n\n_Importing differs slightly from the official library in that the `createShopifyAuth` function is not a default import here, and has been renamed._\n\n### Using verifyRequest for verifying session token on routes:\n\n#### NOTE:\n\n**If the session is invalid it will return a `401 Unauthorized` status code, that you can handle on the client side. _This is a breaking change from the official library, which returns `403 Forbidden`._**\n\nFor requests, create the middleware like this:\n\n```js\n// For requests from the frontend, we want to return headers, so we can check if we need to reauth on the client side\nconst verifyApiRequest = verifyRequest({ returnHeader: true });\nconst verifyPageRequest = verifyRequest();\n```\n\nThe `verifyRequest` middleware function only accepts the following parameters (default values shown):\n\n_NOTE: These parameters differ from the ones in the official library._\n\n```js\n{\n  accessMode: \"online\",  // The access mode of the token to check\n  authRoute: \"/auth\",  // Where to redirect if the session is invalid\n  returnHeader: false,  // If true, set headers instead of redirecting if session is invalid\n}\n```\n\n#### For more help on how to use the middleware functions, [check the examples](https://github.com/Shopify/koa-shopify-auth#example-app) from the official library.\n\n### Registering middleware for handling auth routes:\n\nThe `createShopifyAuth` middleware function only accepts the following parameters (default values shown):\n\n_NOTE: These parameters differ from the ones in the official library._\n\n```js\n{\n  accessMode: \"online\",  // What kind of token we want to fetch\n  authPath: \"/auth\",  // The path to handle the request on\n  async afterAuth(ctx) { }  // Callback function after auth is completed (the token is available at ctx.state.shopify)\n}\n```\n\nThis is a simple example that you can use to help understand how to implement it.\n\n```js\nconst server = new Koa();\n\n// Installation route (get offline, permanent access token)\nserver.use(\n  createShopifyAuth({\n    accessMode: \"offline\",\n    authPath: \"/install/auth\",\n    async afterAuth(ctx) {\n      const { shop, accessToken } = ctx.state.shopify;\n      const { host } = ctx.query;\n      if (!accessToken) {\n        // This can happen if the browser interferes with the auth flow\n        ctx.response.status = 500;\n        ctx.response.body = \"Failed to get access token! Please try again.\";\n        return;\n      }\n      // Redirect to user auth endpoint, to get user's online token\n      ctx.redirect(`/auth?shop=${shop}&host=${host}`);\n    },\n  })\n);\n\n// User auth route (get online session token)\nserver.use(\n  createShopifyAuth({\n    accessMode: \"online\",\n    authPath: \"/auth\",\n    async afterAuth(ctx) {\n      const { shop } = ctx.state.shopify;\n      const { host } = ctx.query;\n      // Check if the app is installed\n      // NOTE: You can replace with your own function to check if the shop is installed, or you can just remove it, but this is an extra check that can help prevent auth issues\n      if (isShopActive(shop)) {\n        // Redirect to app\n        ctx.redirect(`/?shop=${shop}&host=${host}`);\n      } else {\n        // Redirect to installation endpoint to get permanent access token\n        ctx.redirect(`/install/auth/?shop=${shop}&host=${host}`);\n      }\n    },\n  })\n);\n```\n","readmeFilename":"README.md"}