{"_id":"@digitalframe.ws/df-koa-shopify-auth","_rev":"3-11d2c2e0a0b8602095fa9c2c044abb56","name":"@digitalframe.ws/df-koa-shopify-auth","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.0":{"name":"@digitalframe.ws/df-koa-shopify-auth","version":"0.1.0","sideEffects":false,"types":"src/index.d.ts","main":"src/index.js","scripts":{"test":"mocha --reporter spec"},"repository":{"type":"git","url":"git+https://github.com/rpineda/df-koa-shopify-auth.git"},"keywords":["shopify","app","auth"],"author":{"name":"Ricardo Pineda","email":"ricardo@digitalframe.ws","url":"http://digitalframe.ws"},"license":"MIT","bugs":{"url":"https://github.com/rpineda/df-koa-shopify-auth/issues"},"homepage":"https://github.com/rpineda/df-koa-shopify-auth#readme","bundleDependencies":false,"dependencies":{"nonce":"^1.0.4","safe-compare":"^1.1.2","tslib":"^1.9.3"},"deprecated":false,"description":"[![Build Status](https://travis-ci.org/Shopify/quilt.svg?branch=master)](https://travis-ci.org/Shopify/quilt) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE.md) [![npm version](https://badge.fury.io/js/%40shopify%2Fkoa-shopi","devDependencies":{"@shopify/jest-dom-mocks":"^2.7.1","@shopify/jest-koa-mocks":"^2.1.3","@types/koa":"^2.0.44","@types/safe-compare":"^1.1.0","koa":"^2.5.0","typescript":"~3.2.1","dotenv":"^6.2.0"},"gitHead":"dd401033d391d2d75de936e757dce68d3b334244","_id":"@digitalframe.ws/df-koa-shopify-auth@0.1.0","_nodeVersion":"8.15.1","_npmVersion":"6.9.0","dist":{"integrity":"sha512-TJhUbhy2X9qC1B5qprbVNP9tZn56o3Jxfv2CznHcpaaAAgtFsLHDX8gplzuru80uCI3fWKFsxLZ2rlVBq5f4yw==","shasum":"dcefbafc61c377c9200c62ec695f740541375470","tarball":"https://registry.npmjs.org/@digitalframe.ws/df-koa-shopify-auth/-/df-koa-shopify-auth-0.1.0.tgz","fileCount":29,"unpackedSize":52265,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdLuP7CRA9TVsSAnZWagAAXhQP/2zE2bTw16hNiP19FGmP\nZnuYE0aIoNe54/VQlum9KTFyNNDzuxamx8zPl4PvuhNyaAcBLAdlBV6lC1DS\nDTYdt3m4pmqbA1Or7WZ5T1shwX75bmaS/T/dntVqaI4dwuFzBQ5KMzN4id6+\nOlbkWspS5NF9ZXpFDFHFfihvT6UjDrocnjPy0F8bcyDttKNcQYIlWnT98DZb\nD76djRGGe/HTyZSG/QTsMKTr7ZDDzhwcuK+6Q3OfCDL63b1HJwtwdNTmEu4Y\npFGA+JIPkzYmuisHmJzQbwUgSQReQ4a9UrU5KDsmMhIzeBght6tqOnn8JgUv\nfEUx1gfnHm5Y2HujWS3pgc+COgiYKTZs5VFZxkb95W87Yl4Zx2fZ4lja2lqT\nEvTY3ASJ8TfOXaL/LCUDMDGCnf/Q+MY0AFabVYuH8uwPYOIDM1Itk50n7WJJ\na7Zi/YCAx/r/dGuCz9NceCcbxRnjAnX7YcTaTTEr+G4u2l3ObR1enW5yVp/K\nqtB22+nc9/0lHTbncBEJGe3kDd7EfKeh4N2ND9vRaCB4CYjHBMXDkZW/NA3a\nvY+0p7kLOXMYYTMFAti3CW75VXt4N4GGscWwLnPO3TvojJ249dn4hUrMt4Qm\nSDV9lhmMp6Kryz6KH/yWV2ekmFMXtsyZKMH1fERzEnPk0VC/pcGZ+StXf+R6\nXLIv\r\n=mSyI\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD9Nb33occ8haaxDRsI8fRIbJfWmeRd8PQVpqtgEYDhlgIhAPR9JuS0uz+xiOpChM/GkmGEh9OpYH9dggk4dwWRDiav"}]},"maintainers":[{"name":"digitalframe.ws","email":"ricardo@digitalframe.ws"}],"_npmUser":{"name":"digitalframe.ws","email":"ricardo@digitalframe.ws"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/df-koa-shopify-auth_0.1.0_1563354106343_0.32431888519783647"},"_hasShrinkwrap":false},"0.1.1":{"name":"@digitalframe.ws/df-koa-shopify-auth","version":"0.1.1","sideEffects":false,"types":"src/types.js","main":"src/index.js","scripts":{"test":"mocha --reporter spec"},"repository":{"type":"git","url":"git+https://github.com/rpineda/df-koa-shopify-auth.git"},"keywords":["shopify","app","auth"],"author":{"name":"Ricardo Pineda","email":"ricardo@digitalframe.ws","url":"http://digitalframe.ws"},"license":"MIT","bugs":{"url":"https://github.com/rpineda/df-koa-shopify-auth/issues"},"homepage":"https://github.com/rpineda/df-koa-shopify-auth#readme","bundleDependencies":false,"dependencies":{"nonce":"^1.0.4","safe-compare":"^1.1.2","tslib":"^1.9.3"},"deprecated":false,"description":"[![Build Status](https://travis-ci.org/Shopify/quilt.svg?branch=master)](https://travis-ci.org/Shopify/quilt) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE.md) [![npm version](https://badge.fury.io/js/%40shopify%2Fkoa-shopi","devDependencies":{"@shopify/jest-dom-mocks":"^2.7.1","@shopify/jest-koa-mocks":"^2.1.3","@types/koa":"^2.0.44","@types/safe-compare":"^1.1.0","koa":"^2.5.0","typescript":"~3.2.1","dotenv":"^6.2.0"},"gitHead":"a07f96583423eca260b9ed162f289b2bced85a30","_id":"@digitalframe.ws/df-koa-shopify-auth@0.1.1","_nodeVersion":"8.15.1","_npmVersion":"6.9.0","dist":{"integrity":"sha512-G32Lzue7Zt9zYtkDI69+qqqsjt+oQfih1ed99ZR3nTUUhlD1jvXzJuuJmA7YzwL374/diGmx21uHdZgS3K3+lg==","shasum":"93803102fa0ba3f7a1371655f985bcd52e8e9e7f","tarball":"https://registry.npmjs.org/@digitalframe.ws/df-koa-shopify-auth/-/df-koa-shopify-auth-0.1.1.tgz","fileCount":29,"unpackedSize":52263,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdLufUCRA9TVsSAnZWagAA7ikQAI8KBQMFD/IoliY/Vlcp\ngDka4skU40GoSdg1rYJ6iUZjTAjZ9+vCnB1V4/DWkL7PCzugheX0J2H61aur\nuE3IPltqKWJkVdcBLwJsB0ijy4+dw3c8o1eZFxMkqPeQwVTTp6TYRmtdZ/dg\nQPHGOou5M7doDbN+dlIANFv3SUCfYdU4mU24FYNpXX2jtbLQNvlkYTjXqozr\n9meGGiqa7SI+dcY/51JPSX83IIHegTnZlho1jG6UG4dWz2rGmIozlkVYFPQc\ngLrFcepynFAFnq6DSZa10qUpB+aYQyWe5AtTe7TDHzy3sMfav7+7U850aHZQ\nawS/TdzQjaVT6KWPXVHcV71yQ0xmHFwCFrOlDwcjqhon4kWWZOKRB367UVyz\ndmJ5n0FS2hGaHsvH33YkBJdJeuLCFBA7WJnN5FQX7p7VD8cNtm/Q7EAf49Bp\nPAztB2CeLeDzojjdPpPE8rQzBHSp4nIaaN2wpy/ijOqC4/hGJNvMoLFnI4Xr\nBhNBX0N/4U68BsLEFvjYvBqxbqXWhjqzsoTgnw0fC7jVvAZemVSaAcn4e3wm\nhK/f9YHfdHsxi2zvM7+fU9HMRofUasTKdvAJbeXibNzWOq5w4gWgFtC0JeSs\nw6WF3mH8PiRcQzoj7kpmYXKuu7UF6rO9zptJvh95VGc84k738fyR/l9SsEU4\nTeul\r\n=dB4A\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHHjEFg6FiwE7kN8k6rfFIjoIlC1zWClSYjUbjWYUBV3AiBrgSYfp6GdYXabJv/pXVZeLlLm1C1FYBTHhXuTCfGDSQ=="}]},"maintainers":[{"name":"digitalframe.ws","email":"ricardo@digitalframe.ws"}],"_npmUser":{"name":"digitalframe.ws","email":"ricardo@digitalframe.ws"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/df-koa-shopify-auth_0.1.1_1563355092093_0.9177218271811745"},"_hasShrinkwrap":false},"0.1.2":{"name":"@digitalframe.ws/df-koa-shopify-auth","version":"0.1.2","sideEffects":false,"main":"src/index.js","scripts":{"test":"mocha --reporter spec"},"repository":{"type":"git","url":"git+https://github.com/rpineda/df-koa-shopify-auth.git"},"keywords":["shopify","app","auth"],"author":{"name":"Ricardo Pineda","email":"ricardo@digitalframe.ws","url":"http://digitalframe.ws"},"license":"MIT","bugs":{"url":"https://github.com/rpineda/df-koa-shopify-auth/issues"},"homepage":"https://github.com/rpineda/df-koa-shopify-auth#readme","bundleDependencies":false,"dependencies":{"nonce":"^1.0.4","safe-compare":"^1.1.2","tslib":"^1.9.3"},"deprecated":false,"description":"[![Build Status](https://travis-ci.org/Shopify/quilt.svg?branch=master)](https://travis-ci.org/Shopify/quilt) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE.md) [![npm version](https://badge.fury.io/js/%40shopify%2Fkoa-shopi","devDependencies":{"@shopify/jest-dom-mocks":"^2.7.1","@shopify/jest-koa-mocks":"^2.1.3","@types/koa":"^2.0.44","@types/safe-compare":"^1.1.0","koa":"^2.5.0","typescript":"~3.2.1","dotenv":"^6.2.0"},"gitHead":"9b526cbbc2b9c5cc591dcb4bca191db743cd7e0d","_id":"@digitalframe.ws/df-koa-shopify-auth@0.1.2","_nodeVersion":"8.15.1","_npmVersion":"6.9.0","dist":{"integrity":"sha512-0/GWFam+UOhwEXB8afM8HHGFY93ObIb8vcGxF5CrbSdjdbNaD2WANWZblIGqhoFrF/ZXuL2r8Rrwup6I+z+chw==","shasum":"54b0be5ed6dc3d680362b8c7cc589e50e6fbeaee","tarball":"https://registry.npmjs.org/@digitalframe.ws/df-koa-shopify-auth/-/df-koa-shopify-auth-0.1.2.tgz","fileCount":29,"unpackedSize":52236,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdLujyCRA9TVsSAnZWagAAqDYP/AmnunQvBZE5eldHBLgc\nRiPMJ3Q85YIi4DiZoNQer2KdMvMKaDwDfu2B/svpgBqZ4DoF947PJtDaZjrN\nFu+3WN3FYbtJ7SZ02iRl1mDL1dEJBhfCiRG67dma+R21CfWAqJUFJJWnCkV8\n+2c++MIX364/z+jl/dyXD0RHkmDWoDcKN9l/Yl4k5SnWKoXBILzYVtXNxXFM\ncP3Gr+l5SPiW7BJKpPKJYdkb8DRky6Z/tHGgIwr5S/Jjns7LUDSz33PkYj5c\n0XIALDETT6KPJFj6z0ftXo1TLifDRvoDFflpR2uS1QJYz+FV94PPDDPOdjMF\nTP5LjauPLoOr9KVz4QWTGP2mVUotm7I+KKQQH4TMav13XWoF1TSrzvkeD7e8\nHqNuXJ1cl64swrLCxTd68yfFFLhizTdoPo3d//+HGgbwvlzgBKN54aZET28F\nXDenZxVU5oetsAZia3BbalvHz9l85mMNBtbyL4EkgODCTJkTjh0W8Vw6NRB2\n9VAlKc7NbhVrG6hPJyZkMBwef1Vp3NIeFj3QU3IfZtfRRJcF8eOS9Epha+7F\n6LsAUOuaV2CjIlt6VBcA/7DlsoHyRHOlY2C7BjXv9OYeNt937A9l/1H/7NGq\nQRzNLFIML252x+WcX58hUvd/UNa8bgs8tQpsNcp5i75bRiHDK8X9C9V00kiy\nGP4p\r\n=1rPq\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIE8xT3ZyCj+TAsWpRzlPZwobQb8M4WDNytk40ldGjXUUAiAckuEqkxQegL8l/SlOM5o/dXvDiKmx8r+9MCbQrKIvig=="}]},"maintainers":[{"name":"digitalframe.ws","email":"ricardo@digitalframe.ws"}],"_npmUser":{"name":"digitalframe.ws","email":"ricardo@digitalframe.ws"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/df-koa-shopify-auth_0.1.2_1563355378063_0.5297338768663318"},"_hasShrinkwrap":false}},"time":{"created":"2019-07-17T09:01:46.130Z","0.1.0":"2019-07-17T09:01:46.487Z","modified":"2022-04-05T04:37:32.599Z","0.1.1":"2019-07-17T09:18:12.229Z","0.1.2":"2019-07-17T09:22:58.232Z"},"maintainers":[{"name":"digitalframe.ws","email":"ricardo@digitalframe.ws"}],"description":"[![Build Status](https://travis-ci.org/Shopify/quilt.svg?branch=master)](https://travis-ci.org/Shopify/quilt) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE.md) [![npm version](https://badge.fury.io/js/%40shopify%2Fkoa-shopi","homepage":"https://github.com/rpineda/df-koa-shopify-auth#readme","keywords":["shopify","app","auth"],"repository":{"type":"git","url":"git+https://github.com/rpineda/df-koa-shopify-auth.git"},"author":{"name":"Ricardo Pineda","email":"ricardo@digitalframe.ws","url":"http://digitalframe.ws"},"bugs":{"url":"https://github.com/rpineda/df-koa-shopify-auth/issues"},"license":"MIT","readme":"# `@shopify/koa-shopify-auth`\n\n[![Build Status](https://travis-ci.org/Shopify/quilt.svg?branch=master)](https://travis-ci.org/Shopify/quilt)\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE.md) [![npm version](https://badge.fury.io/js/%40shopify%2Fkoa-shopify-auth.svg)](https://badge.fury.io/js/%40shopify%2Fkoa-shopify-auth)\n\nMiddleware to authenticate a [Koa](http://koajs.com/) application with [Shopify](https://www.shopify.ca/).\n\nSister module to [`@shopify/shopify-express`](https://www.npmjs.com/package/@shopify/shopify-express), but simplified.\n\nFeatures you might know from the express module like the webhook middleware and proxy will be presented as their [own packages instead](https://github.com/Shopify/quilt/blob/master/packages/koa-shopify-graphql-proxy/README.md).\n\n## Installation\n\n```bash\n$ yarn add @shopify/koa-shopify-auth\n```\n\n## Usage\n\nThis package exposes `shopifyAuth` by default, and `verifyRequest` as a named export.\n\n```js\nimport shopifyAuth, {verifyRequest} from '@shopify/koa-shopify-auth';\n```\n\n### shopifyAuth\n\nReturns an authentication middleware taking up (by default) the routes `/auth` and `/auth/callback`.\n\n```js\napp.use(\n  shopifyAuth({\n    // if specified, mounts the routes off of the given path\n    // eg. /shopify/auth, /shopify/auth/callback\n    // defaults to ''\n    prefix: '/shopify',\n    // your shopify app api key\n    apiKey: SHOPIFY_API_KEY,\n    // your shopify app secret\n    secret: SHOPIFY_SECRET,\n    // scopes to request on the merchants store\n    scopes: ['write_orders, write_products'],\n    // set access mode, default is 'online'\n    accessMode: 'offline',\n    // callback for when auth is completed\n    afterAuth(ctx) {\n      const {shop, accessToken} = ctx.session;\n\n      console.log('We did it!', accessToken);\n\n      ctx.redirect('/');\n    },\n  }),\n);\n```\n\n#### `/auth`\n\nThis route starts the oauth process. It expects a `?shop` parameter and will error out if one is not present. To install it in a store just go to `/auth?shop=myStoreSubdomain`.\n\n### `/auth/callback`\n\nYou should never have to manually go here. This route is purely for shopify to send data back during the oauth process.\n\n### verifyRequest\n\nReturns a middleware to verify requests before letting them further in the chain.\n\n```javascript\napp.use(\n  verifyRequest({\n    // path to redirect to if verification fails\n    // defaults to '/auth'\n    authRoute: '/foo/auth',\n    // path to redirect to if verification fails and there is no shop on the query\n    // defaults to '/auth'\n    fallbackRoute: '/install',\n  }),\n);\n```\n\n### Example app\n\n```javascript\nimport 'isomorphic-fetch';\n\nimport Koa from 'koa';\nimport session from 'koa-session';\nimport shopifyAuth, {verifyRequest} from '@shopify/koa-shopify-auth';\n\nconst {SHOPIFY_API_KEY, SHOPIFY_SECRET} = process.env;\n\nconst app = new Koa();\napp.keys = [SHOPIFY_SECRET];\n\napp\n  // sets up secure session data on each request\n  .use(session(app))\n\n  // sets up shopify auth\n  .use(\n    shopifyAuth({\n      apiKey: SHOPIFY_API_KEY,\n      secret: SHOPIFY_SECRET,\n      scopes: ['write_orders, write_products'],\n      afterAuth(ctx) {\n        const {shop, accessToken} = ctx.session;\n\n        console.log('We did it!', accessToken);\n\n        ctx.redirect('/');\n      },\n    }),\n  )\n\n  // everything after this point will require authentication\n  .use(verifyRequest())\n\n  // application code\n  .use(ctx => {\n    ctx.body = '🎉';\n  });\n```\n\n## Gotchas\n\n### Fetch\n\nThis app uses `fetch` to make requests against shopify, and expects you to have it polyfilled. The example app code above includes a call to import it.\n\n### Session\n\nThough you can use `shopifyAuth` without a session middleware configured, `verifyRequest` expects you to have one. If you don't want to use one and have some other solution to persist your credentials, you'll need to build your own verifiction function.\n\n### Testing locally\n\nBy default this app requires that you use a `myshopify.com` host in the `shop` parameter. You can modify this to test against a local/staging environment via the `myShopifyDomain` option to `shopifyAuth` (e.g. `myshopify.io`).\n","readmeFilename":"README.md"}