{"_id":"@bongione/redux-fetch-apptoken","_rev":"5-974fd34a984305cf6bdcb2f4ed064405","name":"@bongione/redux-fetch-apptoken","description":"Redux middleware that wraps ES6 fetch calls with an app token header","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.0":{"name":"@bongione/redux-fetch-apptoken","version":"0.1.0","description":"Redux middleware that wraps ES6 fetch calls with an app token header","main":"lib/index.js","scripts":{"clean":"rimraf lib","build":"babel src --out-dir lib","lint":"eslint src","test":"mocha --compilers js:babel-register --recursive","prepublish":"npm run clean && npm run build && npm run lint && npm run test"},"repository":{"type":"git","url":"git+https://github.com/mindiply/redux-fetch-apptoken.git"},"keywords":["redux","middleware","token"],"author":{"name":"Paolo Ferdinando Bongiovanni","email":"paolo.bongiovanni@mindiply.com"},"license":"\tApache-2.0","bugs":{"url":"https://github.com/mindiply/redux-fetch-apptoken/issues"},"homepage":"https://github.com/mindiply/redux-fetch-apptoken#readme","devDependencies":{"babel-cli":"^6.18.0","babel-core":"^6.18.2","babel-plugin-transform-es2015-modules-commonjs":"^6.18.0","babel-preset-es2015":"^6.18.0","babel-register":"^6.16.3","chai":"^3.5.0","chai-passport-strategy":"^1.0.0","cross-env":"^3.1.3","eslint":"^3.9.1","eslint-config-standard":"^6.2.1","eslint-plugin-promise":"^3.3.0","eslint-plugin-standard":"^2.0.1","install":"^0.8.2","mocha":"^3.1.2","moment":"^2.15.2","npm":"^3.10.9","rimraf":"^2.5.4"},"dependencies":{"es6-promise":"^4.0.5","isomorphic-fetch":"^2.2.1","redux":"^3.6.0"},"peerDependencies":{"redux":"^3.6.0"},"gitHead":"fb08ddbf094695fd0c16b31c15c520a4dd12b976","_id":"@bongione/redux-fetch-apptoken@0.1.0","_shasum":"3867700bae4c682b8d35c45ad463320e1d597c72","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.4.0","_npmUser":{"name":"bongione","email":"paolo.bongiovanni@mindiply.com"},"dist":{"shasum":"3867700bae4c682b8d35c45ad463320e1d597c72","tarball":"https://registry.npmjs.org/@bongione/redux-fetch-apptoken/-/redux-fetch-apptoken-0.1.0.tgz","integrity":"sha512-DgjHqHdMEYM/DyMKug1mbdhEDP/FlN6WBFbXvHbwlLtLUeVPPFJcfE+blAGX/OD5zCTxqSUhW3mizWC5bvGxcw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCINwXKOWRfdZjK1Tl5xrGu22ZtRoXXdP4CSt7HGOrxAAIhAP/TvATFXt8aZClemhxDc3xM3v5XrI5bC97LyBPPrtoP"}]},"maintainers":[{"name":"bongione","email":"paolo.bongiovanni@mindiply.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/redux-fetch-apptoken-0.1.0.tgz_1478261588636_0.7692543053999543"}},"0.1.1":{"name":"@bongione/redux-fetch-apptoken","version":"0.1.1","description":"Redux middleware that wraps ES6 fetch calls with an app token header","main":"lib/index.js","scripts":{"clean":"rimraf lib","build":"babel src --out-dir lib","lint":"eslint src","test":"mocha --compilers js:babel-register --recursive","prepublish":"npm run clean && npm run build && npm run lint && npm run test"},"repository":{"type":"git","url":"git+https://github.com/mindiply/redux-fetch-apptoken.git"},"keywords":["redux","middleware","token"],"author":{"name":"Paolo Ferdinando Bongiovanni","email":"paolo.bongiovanni@mindiply.com"},"license":"\tApache-2.0","bugs":{"url":"https://github.com/mindiply/redux-fetch-apptoken/issues"},"homepage":"https://github.com/mindiply/redux-fetch-apptoken#readme","devDependencies":{"babel-cli":"^6.18.0","babel-core":"^6.18.2","babel-plugin-transform-es2015-modules-commonjs":"^6.18.0","babel-preset-es2015":"^6.18.0","babel-register":"^6.16.3","chai":"^3.5.0","chai-passport-strategy":"^1.0.0","cross-env":"^3.1.3","eslint":"^3.9.1","eslint-config-standard":"^6.2.1","eslint-plugin-promise":"^3.3.0","eslint-plugin-standard":"^2.0.1","install":"^0.8.2","mocha":"^3.1.2","moment":"^2.15.2","npm":"^3.10.9","rimraf":"^2.5.4"},"dependencies":{"es6-promise":"^4.0.5","isomorphic-fetch":"^2.2.1","redux":"^3.6.0"},"peerDependencies":{"redux":"^3.6.0"},"gitHead":"78a16917e1e038dab5fa70a5ff49659f06d9ab98","_id":"@bongione/redux-fetch-apptoken@0.1.1","_shasum":"746d523cbf17eb50588af81bee77df17ce5bfcc4","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.4.0","_npmUser":{"name":"bongione","email":"paolo.bongiovanni@mindiply.com"},"dist":{"shasum":"746d523cbf17eb50588af81bee77df17ce5bfcc4","tarball":"https://registry.npmjs.org/@bongione/redux-fetch-apptoken/-/redux-fetch-apptoken-0.1.1.tgz","integrity":"sha512-4Kl6JSgetBUclX8mzrKcb6GWH+1njsg+Y4Ysf+4A2F6jkvK8zCaDtTWxyQPeZZvghgXUOUaEMjmkWqu4aJGdNQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHDYBxEyY6a5dUMUvo2eJW93savrRYOKHABpXhHHHcCiAiBw3FujQ/QdRdPM0ULraE+FX7ec4CDvphkDUOhUt0G/JQ=="}]},"maintainers":[{"name":"bongione","email":"paolo.bongiovanni@mindiply.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/redux-fetch-apptoken-0.1.1.tgz_1478262141580_0.34777070628479123"}},"0.1.2":{"name":"@bongione/redux-fetch-apptoken","version":"0.1.2","description":"Redux middleware that wraps ES6 fetch calls with an app token header","main":"lib/index.js","files":["lib"],"scripts":{"clean":"rimraf lib","build":"babel src --out-dir lib","lint":"eslint src","test":"mocha --compilers js:babel-register --recursive","prepublish":"npm run clean && npm run build && npm run lint && npm run test"},"repository":{"type":"git","url":"git+https://github.com/mindiply/redux-fetch-apptoken.git"},"keywords":["redux","middleware","token"],"author":{"name":"Paolo Ferdinando Bongiovanni","email":"paolo.bongiovanni@mindiply.com"},"license":"\tApache-2.0","bugs":{"url":"https://github.com/mindiply/redux-fetch-apptoken/issues"},"homepage":"https://github.com/mindiply/redux-fetch-apptoken#readme","devDependencies":{"babel-cli":"^6.18.0","babel-core":"^6.18.2","babel-plugin-transform-es2015-modules-commonjs":"^6.18.0","babel-preset-es2015":"^6.18.0","babel-register":"^6.16.3","chai":"^3.5.0","chai-passport-strategy":"^1.0.0","cross-env":"^3.1.3","eslint":"^3.9.1","eslint-config-standard":"^6.2.1","eslint-plugin-promise":"^3.3.0","eslint-plugin-standard":"^2.0.1","install":"^0.8.2","mocha":"^3.1.2","moment":"^2.15.2","npm":"^3.10.9","rimraf":"^2.5.4"},"dependencies":{"es6-promise":"^4.0.5","isomorphic-fetch":"^2.2.1","redux":"^3.6.0"},"peerDependencies":{"redux":"^3.6.0"},"gitHead":"78a16917e1e038dab5fa70a5ff49659f06d9ab98","_id":"@bongione/redux-fetch-apptoken@0.1.2","_shasum":"02faecab6312c61b93cb7023069b14ce34a7fb88","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.4.0","_npmUser":{"name":"bongione","email":"paolo.bongiovanni@mindiply.com"},"dist":{"shasum":"02faecab6312c61b93cb7023069b14ce34a7fb88","tarball":"https://registry.npmjs.org/@bongione/redux-fetch-apptoken/-/redux-fetch-apptoken-0.1.2.tgz","integrity":"sha512-/Fgs70PngjsvZOQbUeAAzPeXByZM76WI4U+O4XIVDx96IQPDmhgExt4a0WYCMPE6hxfW2kaihYWQNCB49uz3pQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCaHqFM8fRvM1fdxlfQo+8g6WPHzpNhB5x3vwqz0K8AjwIgcc6o3BetkEinn9oveFnYQ0rkC5q8PhkwOt+F59UX32Q="}]},"maintainers":[{"name":"bongione","email":"paolo.bongiovanni@mindiply.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/redux-fetch-apptoken-0.1.2.tgz_1478265419531_0.7528365182224661"}}},"readme":"# Redux fetch app token\n\nRedux middleware that wraps fetch calls with a http header that bears\nand app token.\n\nUseful for non-full fledged HTTP bearer token OAuth2 implementations, \nlike for microservice architecture that have a central authorization\nmicroservice that grants temporary app tokens to other microservices.\n\n\n# Usage\n\n~~~\nnpm install --save @bongione/redux-fetch-apptoken\n~~~\n\n\n## When setting up your redux store\n\n~~~\nlet {createStore, applyMiddleware} = require('redux')\nimport {fetchWithAppTokenMiddleware} from '@bongione/redux-fetch-apptoken'\n\nconst options = {\n    tokenFetchRequest: (url, scopes) => { ... },\n    tokenFetchUrl: '/auth/users/app_token',\n    httpAppTokenHeader: 'SENECA-APP-TOKEN'\n}\n\nconst store = createStore(testApp, applyMiddleware(\n        fetchWithAppTokenMiddleware(options)\n    ))\n~~~\n\nThe options object attributes are:\n* **tokenFetchRequest** a function with signature (url = '', scope = [])\n  to retrieve the app tokens once the user has been authenticated\n* **tokenFetchUrl** the url used to retrieve the tokens\n* **httpAppTokenHeader** The HTTP header name to use where the token is\n  attached to.\n  \nThe middleware expects the token provider to return a json object of the\nformat\n~~~\n{\n    token: 'TOKENSTRING',\n    expires_is_s: 3600\n}\n~~~\n\n## When you would usually call a fetch statement from an action\n\n~~~\nimport {fetchWithAppToken} from '@bongione/redux-fetch-apptoken'\n\nfunction testPostFetchAction (fetch, dispatch) {\n    fetch\n        .then(response => response.json())\n        .then(json => {\n            dispatch(saveData(json))\n        })\n        .catch(err => {\n            console.log(err)\n        })\n}\n\n\nstore.dispatch(fetchWithAppToken('test_url', {}, 'TEST', testPostFetchAction))\n~~~\n\n**fetchWithAppToken (url, fetch_options, scope, action)** takes the following parameters:\n* **url** url to fetch from\n* **fetch_options** options you would use for your fetch called, like method,\n  credentials, body...\n* **scope** The scope of the API you are calling. We expect the backend to\n  be served by multiple microservices\n* **action** the action to perform after the fetch. Action should be \n  a function with the following signature: \n~~~\naction(fetchPromise, dispatch)\n~~~  \n  \n  \nThe middleware will queue fetch requests until a valid token has been\nretrieved from the backend.\n  \n  \n  \n","maintainers":[{"name":"bongione","email":"paolo.bongiovanni@mindiply.com"}],"time":{"modified":"2022-06-12T15:25:36.945Z","created":"2016-11-04T12:13:09.138Z","0.1.0":"2016-11-04T12:13:09.138Z","0.1.1":"2016-11-04T12:22:22.150Z","0.1.2":"2016-11-04T13:17:00.035Z"},"homepage":"https://github.com/mindiply/redux-fetch-apptoken#readme","keywords":["redux","middleware","token"],"repository":{"type":"git","url":"git+https://github.com/mindiply/redux-fetch-apptoken.git"},"author":{"name":"Paolo Ferdinando Bongiovanni","email":"paolo.bongiovanni@mindiply.com"},"bugs":{"url":"https://github.com/mindiply/redux-fetch-apptoken/issues"},"license":"\tApache-2.0","readmeFilename":"README.md"}