{"_id":"@simpleview/auth-client","_rev":"43-80256b6bba64beb9ba3c17a3e6261eca","name":"@simpleview/auth-client","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.0":{"name":"@simpleview/auth-client","version":"1.0.0","author":{"name":"Owen Allen","email":"owenallenaz@gmail.com"},"license":"MIT","_id":"@simpleview/auth-client@1.0.0","maintainers":[{"name":"owenallenaz","email":"owenallenaz@gmail.com"}],"homepage":"https://github.com/simpleviewinc/sv-npm-assertlib#readme","bugs":{"url":"https://github.com/simpleviewinc/sv-npm-assertlib/issues"},"dist":{"shasum":"f3e5c0822dc6d27ee972af164b33465a07b6caf3","tarball":"https://registry.npmjs.org/@simpleview/auth-client/-/auth-client-1.0.0.tgz","fileCount":14,"integrity":"sha512-bhM6veLsySzKLXCW6ssHS2sA2jAiiuFD3PooHOY7n+z+jtwAfIJ5fksxepqZJz/UAOdFI4KMhHWiQ6bXYvbwBQ==","signatures":[{"sig":"MEQCICLJBBFvi4uHpGgJrgdQ5KRz7MTVrCBDGy2MMbCFma97AiAtvTNufq4vGVBeAulDW/pViAqenfhlueT6DPFNapQJ6w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14451,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcT+fdCRA9TVsSAnZWagAAyHsP/3yxrAVEMkZiATc6l928\nQRNekh0lwPmYTPQ4a56eMoeiOnt+28Og0czKwcj86iepK27LfiioSMY9SN7/\nwzVx/kNxnykcSbBpQuJlSQryplzdyGieW8H8EKSgjWdqpNCyXdLCHfzNSFZC\nqxmhpx5WyMvNYs6rk9MntSKp7NWatGDhETrGimhYNoNnkwST4buSns2nsXeL\nI+iQtt1aWtKoi//ws/s/rSY37o6qk5bQUxqlx66Sxw6xkQe6hfWbSX663vyC\nhQzTbXkHVo41GYjZfJ6yYdIlUJdNi3dDgJ4WEnviWgUKfHhYYINkoWF1H3D2\nYZJTTAc+hGOjW0Ch2ivpKfrLney+h08SN7iL5WAqBO+cFxCSU3fsw0kx+Bdn\nxpOP0MqppRL9BuwhmRymplSTGc57MOogu5kllzXB10z9InjUajnrC5zbcBKY\nANbjFX3kxpf83MVm3lQzxC0RLNapthR2PEphriZyOks/2vwl9O+wmzrqUkkC\nra67U1m0/5C0dvQTZ1TGu4nNkj4/Wwlr3ckHXUgJ+m7brXZ4X1RfsTJJuJTm\najjE7zB95+s5GahVapT95uWaHqjzLafiC0hPTjQ4somJiY1PmLYh0vDeKf88\nkdHwy2zDfQjHAy1lfGg6tZHOEe44u1TrXolfOdwuSE5Ac8FgfGqnZV05ULVy\nYBrI\r\n=Kzfd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"src/index.js","gitHead":"e34f3edfe1f44b36bfe76b2d2e70fba6a9162e4a","scripts":{"test":"mocha testing","docker":"./docker/build && ./docker/run || true"},"_npmUser":{"name":"owenallenaz","email":"owenallenaz@gmail.com"},"repository":{"url":"git+https://github.com/simpleviewinc/sv-npm-assertlib.git","type":"git"},"_npmVersion":"5.6.0","description":"Client for communicating with sv-auth","directories":{},"_nodeVersion":"8.11.3","dependencies":{"axios":"0.18.0"},"_hasShrinkwrap":false,"devDependencies":{"mocha":"5.2.0"},"_npmOperationalInternal":{"tmp":"tmp/auth-client_1.0.0_1548740573204_0.7253149708898747","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@simpleview/auth-client","version":"1.0.1","author":{"name":"Owen Allen","email":"owenallenaz@gmail.com"},"license":"MIT","_id":"@simpleview/auth-client@1.0.1","maintainers":[{"name":"owenallenaz","email":"owenallenaz@gmail.com"},{"name":"seanmalbert","email":"smabert@gmail.com"}],"homepage":"https://github.com/simpleviewinc/sv-npm-assertlib#readme","bugs":{"url":"https://github.com/simpleviewinc/sv-npm-assertlib/issues"},"dist":{"shasum":"ffd7e0ab55769f05cece61b2122689b6504bffef","tarball":"https://registry.npmjs.org/@simpleview/auth-client/-/auth-client-1.0.1.tgz","fileCount":14,"integrity":"sha512-vvahdXxOuM9bHUP0mjz/YF+wUYr+iOLCTt6p1wiP7ahLxb9zy0w5S+ezQR+/CZBnczvwqmdWz0fHXn4JlEEibA==","signatures":[{"sig":"MEYCIQCrCBtmjzEokDFGyg6c4jEp8XGCUnT+GclSvIK96tv7cwIhALYu91Vquvy95FSvqymqsVYouP9t/lFBfFE/TlVTm2ZN","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15987,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcYaC4CRA9TVsSAnZWagAAxPUP/3wola8EomdPGQABFgf+\nf4FlaKaFrEJq4OUtSxfWLGh9AtNuo/uNpshkC4l2IY+cDnjymt686eCNRVmR\nEUFWdq0eWs/xBJvGZdA0PPma4l1gzXIUeC0xjIPN3IAPR0lJS6GZYWgdbkzQ\nhaemuBXCz/0FS5w+w4GGoCseZmcuvcCDV0DRAEyT+eQLPt7jhGc5usHNtjBZ\nKuOw/LAf6np31LKnBhTQF7padnd7KE8Lrf9E1N5+D4f30wJcIE3USCcT5Vml\nCtHR/Yojr0Vl6mBvzpvg5TUc4ZMpBPGyBNm3SVjo/TGkdRaWUzWIvti4F4+V\nEg/8nM8kOIwKpxXU9ldPGR6KMDydhgDM2gnZX2WPfkI3igX3aj7WdhHjNyIv\nbE97MHr95mOPAWALG6WFduuUNZLVmUMk9rtgEWeDST4Eg1WH9frUPRtRI8pP\nsUaA8iArt+nUCyw8a8sWD6QYunTociWOwsaaZf6mm4KA9Mrp/343Q67byqQC\n5Kcum3SsQByKk3wUSfc7UipU05o3H0VrvwZ/O1PiWnZIkHyeiucaFQV7kfkr\n7SvZnhPEfMNhIvgiGRa11FizkywVcQcMGH8ACN0USRXW+pQh18uMyfY2ymGA\nzIcN1smVvcihG1C8p6LR+oD+fPFDZ59azue31C7QPay5KTRK7LOhRLZU4UoK\n709z\r\n=3U+G\r\n-----END PGP SIGNATURE-----\r\n"},"main":"src/index.js","gitHead":"f425f3b348f2bfb3fc51dc41d21c448341e2d72d","scripts":{"test":"mocha testing","docker":"./docker/build && ./docker/run || true"},"_npmUser":{"name":"owenallenaz","email":"owenallenaz@gmail.com"},"repository":{"url":"git+https://github.com/simpleviewinc/sv-npm-assertlib.git","type":"git"},"_npmVersion":"5.6.0","description":"Client for communicating with sv-auth","directories":{},"_nodeVersion":"8.11.3","dependencies":{"axios":"0.18.0"},"_hasShrinkwrap":false,"devDependencies":{"mocha":"5.2.0"},"_npmOperationalInternal":{"tmp":"tmp/auth-client_1.0.1_1549902008018_0.44712213571672765","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"@simpleview/auth-client","version":"1.0.2","author":{"name":"Owen Allen","email":"owenallenaz@gmail.com"},"license":"MIT","_id":"@simpleview/auth-client@1.0.2","maintainers":[{"name":"owenallenaz","email":"owenallenaz@gmail.com"},{"name":"seanmalbert","email":"smabert@gmail.com"}],"homepage":"https://github.com/simpleviewinc/sv-npm-assertlib#readme","bugs":{"url":"https://github.com/simpleviewinc/sv-npm-assertlib/issues"},"dist":{"shasum":"d15703bfa7006bc953a33424b90901418fd6e20e","tarball":"https://registry.npmjs.org/@simpleview/auth-client/-/auth-client-1.0.2.tgz","fileCount":14,"integrity":"sha512-VC8CddssxFd3hPHcJZ7NWQ8L9erZ+r7VURMrSyqDF7CvOfvjHFDhj500YUiSNjbDWDtpiJWVNSUhOo0MlS7GLQ==","signatures":[{"sig":"MEQCIEXtCn3G6Od//keVaqkEYP19zgyVJJLmefbErURZg1U2AiB3R+xRyMyg8ulZls2MDg1kFfHSwxDC2pjI3L1BXxPSIw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15998,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcYggICRA9TVsSAnZWagAAQJ4P/R6UaABsz8Ciwr2ynFjE\nYfBDh9LzWYuPkEPHuv3TqdIV+KPllia0YMNj0RwQ8Ro8kwIZxNNbm1+Ldm27\nbNxu4KbssERuOXHeIxnRGsY+MRUEhu4aWK80hCzFEaNFPlDIGk7RoNQl4lMG\nB/ZXnH4Nnnpsqvu3F3bjXciZUDyJYq9f4Yor+bmP70oR6+8zwaHZzWYsYVte\n6CKKJc5P5KDajrFpsfTuzrevLUUESMZu7XUkcKkpJ6SjlPM+BEz/4y1P6184\neifL8NPveIsfLGAdg2uiERGLzHubgHlu94LEy7tFPa82i1Vhr6y8SJOYqH0i\nGPuErrh11hogcd4sku007eNnctgneXzbBHI97O6vHSN0yTa+IfBOayOCy7lQ\nJa/+cfyggOMuf8GK27txMXWfesnWL59P59E1hhvKhwxkdbo0BqgL4OZhDs8T\nWp5xZg7o360fy5VXWGMU6CO+mnV/F7EEHFdV6DaouxsyLJBsjTrNGk90vFHm\nXTc9xwKKtHd7+Ww5HK+Ong3AhddK7vNRXdhrH3TJuRW6aS2rgJZCS5ykBBNx\nzWLhqoDdg6ZYkujU/x3jm0c9qYrcHsMUn345BLM+QVeTtEIPz9QCbUjvGfvh\nwRi+LZM5zzmqtz4wzaphMT3six/4FynbSPwAjTOZ4pUuroLiCfWn1cIcQ+/s\nCiw7\r\n=OXlH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"src/index.js","gitHead":"c5d1d17718466df5e9676f7d355dd157a0be039b","scripts":{"test":"mocha testing","docker":"./docker/build && ./docker/run || true"},"_npmUser":{"name":"owenallenaz","email":"owenallenaz@gmail.com"},"repository":{"url":"git+https://github.com/simpleviewinc/sv-npm-assertlib.git","type":"git"},"_npmVersion":"5.6.0","description":"Client for communicating with sv-auth","directories":{},"_nodeVersion":"8.11.3","dependencies":{"axios":"0.18.0"},"_hasShrinkwrap":false,"devDependencies":{"mocha":"5.2.0"},"_npmOperationalInternal":{"tmp":"tmp/auth-client_1.0.2_1549928455504_0.3082572268958319","host":"s3://npm-registry-packages"}},"1.0.3":{"name":"@simpleview/auth-client","version":"1.0.3","author":{"name":"Owen Allen","email":"owenallenaz@gmail.com"},"license":"MIT","_id":"@simpleview/auth-client@1.0.3","maintainers":[{"name":"owenallenaz","email":"owenallenaz@gmail.com"},{"name":"seanmalbert","email":"smabert@gmail.com"}],"homepage":"https://github.com/simpleviewinc/sv-npm-assertlib#readme","bugs":{"url":"https://github.com/simpleviewinc/sv-npm-assertlib/issues"},"dist":{"shasum":"a4bcb8d2521c614ac027f20d3da09c7620c0bf3b","tarball":"https://registry.npmjs.org/@simpleview/auth-client/-/auth-client-1.0.3.tgz","fileCount":14,"integrity":"sha512-3ycerZcfkn7N3tNxco6iGgIUDklf5LOTY6VFAG6CkHo8Quea7Uwha2KAFfmkBcJB/0CMQXAnws4niWvgqalrpg==","signatures":[{"sig":"MEQCIH/wdewtO1Pm+kWQCmEDUIln5tE5mi4hOEZIVvGk1tfQAiARMvZGZQ9PTsu2tXkIsWYQ4+hIuRO3oueCAiCrugP0dw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16030,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcYg90CRA9TVsSAnZWagAABCwQAITd+ncabLC8cXUpEali\nW9WAt2ZottUJ89zkCveenPR7DGignFnAuzi9VYDaj/sTwc4P/p1tWjx6qjle\n2rSYlCqWFWLjd4k610UOfgzhr/KUAUN26FPA+jvoIhzrl6ChC+X/1dM01bDV\ndzryHw2ybMlfKesCGVoUwlAFYPlsw/AjjuTKx92XtDmz2qt90xoO3xbTLl9E\nyjUQu7S0jhOz5LPZCfapfvM8ioexkb9HjY3J8f0bvFjRkRetF+unfTjoEV/v\nMR5Skb2NodL9uP6K6/g3DO02oSjrKbFGwzAKjTsYIt3ATq4eH6w2YNtNvXy7\n1db3PibgpixaOlHZFc/QVSObNTKFcEIq1lk3wwS+6V3LhcJWTDyza3kk86PG\n/lhNBMuH2HdBfSPS7cO/Wi7v/Yza5VkaXXuEtDYG6GY+QEqtZXzfJ8Csw4xt\npfN/Nuc4OpzK2JmPgRwuWzl69oJB7/4Y17+navuTobk+L8xjFM+aghalFWSi\nZNznZu9NK2nwJ1f+21PN9LEH+sXId/1v58qmndZz0Cm11FyiNQECOsD8Vcz6\nGo6zyEPbDJFfPhzINS3K+26o0SBlJ4ThEzeva+Ejw3A0gHbsBcp9yb/Xk6zM\nnXTw69EXs+xkTQ4AEHpl3zJ8SzUEoq41Ei+kOMaypzGlzoZ90XsLSff8YLcv\nMbao\r\n=sgJN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"src/index.js","gitHead":"8e8311dd945f663eef61e66107883384d518061e","scripts":{"test":"mocha testing","docker":"./docker/build && ./docker/run || true"},"_npmUser":{"name":"owenallenaz","email":"owenallenaz@gmail.com"},"repository":{"url":"git+https://github.com/simpleviewinc/sv-npm-assertlib.git","type":"git"},"_npmVersion":"5.6.0","description":"Client for communicating with sv-auth","directories":{},"_nodeVersion":"8.11.3","dependencies":{"axios":"0.18.0"},"_hasShrinkwrap":false,"devDependencies":{"mocha":"5.2.0"},"_npmOperationalInternal":{"tmp":"tmp/auth-client_1.0.3_1549930356368_0.0003404779988311901","host":"s3://npm-registry-packages"}}},"time":{"created":"2019-01-29T05:42:53.021Z","modified":"2025-10-16T19:54:33.454Z","1.0.0":"2019-01-29T05:42:53.310Z","1.0.1":"2019-02-11T16:20:08.116Z","1.0.2":"2019-02-11T23:40:55.614Z","1.0.3":"2019-02-12T00:12:36.494Z"},"bugs":{"url":"https://github.com/simpleviewinc/sv-npm-assertlib/issues"},"author":{"name":"Owen Allen","email":"owenallenaz@gmail.com"},"license":"MIT","homepage":"https://github.com/simpleviewinc/sv-npm-assertlib#readme","repository":{"url":"git+https://github.com/simpleviewinc/sv-npm-assertlib.git","type":"git"},"description":"Client for communicating with sv-auth","maintainers":[{"email":"owenallenaz@gmail.com","name":"owenallenaz"},{"email":"gotshogi@gmail.com","name":"qman33"},{"email":"jmoor@simpleviewinc.com","name":"svjoshua"},{"email":"george.batt@simpleviewinc.com","name":"georgeyb-sv"},{"email":"mike@formativewebsolutions.com","name":"mkes99"},{"email":"colin.booen@simpleviewinc.com","name":"colin.booen"},{"email":"sean.smith@simpleviewinc.com","name":"ssmith_sv"},{"email":"aglazebrook@simpleviewinc.com","name":"aglazebrook"},{"email":"rmaynes@simpleviewinc.com","name":"rmaynes"},{"email":"Michael.Harrington@simpleviewinc.com","name":"mikesan789"},{"email":"Kristian.Gonzalez@simpleviewinc.com","name":"kristian.gonzalez"},{"email":"paul.riding@simpleviewinc.com","name":"paul.riding"},{"email":"amir.muntasser@simpleviewinc.com","name":"arkmuntasser"},{"email":"ed.downard@simpleviewinc.com","name":"actionawesome"},{"email":"mcutshall0@gmail.com","name":"mcutshall"},{"email":"mikael.ramirez@simpleviewinc.com","name":"sv-mikael"},{"email":"kory.chinn@simpleviewinc.com","name":"korychinn_sv"},{"email":"dan-npmjs@dlford.io","name":"dlford"},{"email":"s.loutrel@gmail.com","name":"sloutrel"}],"readme":"# sv-auth-client\nClient for communicating with sv-auth\n\n# installation\n\n```\nnpm install @simpleview/auth-client\n```\n\n# Usage in GraphQL\n\nAdd the token from the header into your context.\n```js\nconst { getTokenFromHeaders } = require(\"@simpleview/auth-client\");\nconst server = new ApolloServer({\n\t...\n\tcontext: ({ req }) => {\n\t\treturn {\n\t\t\t...\n\t\t\ttoken : getTokenFromHeaders(req.headers)\n\t\t};\n\t}\n});\n```\n\nIn a resolver utilize `AuthClient.getUser()` to convert that token into a user. If you look at the `sv-auth` project you can see an example of this pattern. In that project TODO ADD URL, `admin` requires an acct_id and all child-resolvers will have the user already attached to the context.\n\n# API\n\n## AuthClient\n\n`AuthClient` is a class for converting a `token` and an `acct_id` into an `auth_user` with permissions.\n\n```js\nconst { AuthClient } = require(\"@simpleview/auth-client\");\n// the GRAPH_URL is the graphQL server that you wish to communicate with. Get the proper URL from the sv-auth repository to align with the appropriate live/dev/staging resource.\nconst authClient = new AuthClient({ graphUrl : GRAPH_URL });\n```\n\n### AuthClient.getUser\n\nThis method wraps the call to `auth.users_current` in a caching layer to ensure that it's optimal performance and is properly updating if a user's permissions have changed.\n\nGenerally you will want to make this call very early in your GraphQL stack in order to make the user available on context for all calls to access.\n\n* args\n\t* token - string - The jwt token retrieved from the the auth system.\n\t* acct_id - string - The acct_id that you need to retrieve the user for.\n\nReturns `auth_user`.\n\n```js\nconst user = authClient.getUser({\n\ttoken,\n\tacct_id : \"0\"\n});\n```\n\n### AuthClient.close\n\nIf you are finished with an AuthClient instance, call `authClient.close()` in order to shut it down. Generally this is only needed in unit tests, otherwise there is an internal `setInterval` which will keep the process open.\n\n## getTokenFromHeaders\n\nExtracts the token from the `authorization` header.\n\n```js\nconst { getTokenFromHeaders } = require(\"@simpleview/auth-client\");\n\nconst server = new ApolloServer({\n\t...\n\tcontext: ({ req }) => {\n\t\treturn {\n\t\t\ttoken : getTokenFromHeaders(req.headers)\n\t\t};\n\t}\n});\n```\n\n## GraphServer\n\n`GraphServer` is an API interface to communicate with the auth/admin system's graphQL server to make it a little bit easier to call the various methods.\n\n\n* args\n\t* graphUrl - string - Fully qualified URL pointing to the graphURL server.\n\t* context - object - Context object used for handling token/acct_id\n\t\t* acct_id - string - The acct_id that the user is attempting to access. `acct_id` is required for any endpoints on `admin`.\n\t\t* token - string - The token returned from the auth system. Token is required for accessing any of the non-login mechanics.\n\nIf you need to set the context at run-time, you can manually update the context via setting `graphServer.context.acct_id = \"x\"`. You cannot set the `context` key to a new object or it will not function, manually updated or `Object.assign` you're changes in.\n\n```\nconst { GraphServer } = require(\"@simpleview/auth-client\");\n// the GRAPH_URL is the graphQL server that you wish to communicate with. Get the proper URL from the sv-auth repository to align with the appropriate live/dev/staging resource.\nconst graphServer = new GraphServer({\n\tgraphUrl : GRAPH_URL\n});\n```\n\nThe easiest way to find the endpoints on GraphServer is to either check the `src/graphql` or simply new the instance and console log.\n\nExamples\n\n```js\nconst result = await graphServer.users.login({\n\temail : \"x\",\n\tpassword : \"y\",\n\tfields : \"success message\"\n});\n\nconst result = await graphServer.roles.find({\n\tfilter : {\n\t\tacct_id : \"0\"\n\t},\n\tfields : `\n\t\tdocs {\n\t\t\tid\n\t\t\tname\n\t\t\t...\n\t\t}\n\t\tcount\n\t`\n});\n```\n\nFor the available fields on each call you can reference the GraphQL schema via the schema browser.","readmeFilename":"README.md"}