{"_id":"@apim/auth0-lock-redux","_rev":"4-bbb8b22aa5ae4ff892b9f85f6ef29a53","name":"@apim/auth0-lock-redux","description":"Auth Lock Redux Middleware","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@apim/auth0-lock-redux","version":"1.0.0","private":false,"description":"Auth Lock Redux Middleware","author":{"name":"Luis Gomez","email":"lgomez@gmail.com","url":"http://luis.io"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/apim-io/auth0-lock-redux.git"},"bugs":{"url":"https://github.com/apim-io/eventsourced/issues"},"files":["reducer.js","middleware.js","constants.js","actions.js","index.js","README.md","es","umd"],"main":"index.js","module":"es/index.js","scripts":{"build":"node ./tools/build.js","prepublish":"node ./tools/build.js","watch":"babel ./modules -d . --ignore __tests__ --watch","clean":"git clean -fdX .","lint":"eslint modules","test":"jest"},"keywords":["redux","auth0","middleware","react"],"dependencies":{"auth0-lock":"^10.16.0","babel-cli":"^6.24.1","babel-core":"^6.24.1","babel-eslint":"^7.2.3","babel-jest":"^20.0.1","babel-plugin-transform-react-remove-prop-types":"^0.4.5","babel-preset-es2015":"^6.24.1","babel-preset-react":"^6.24.1","babel-preset-stage-1":"^6.24.1","eslint":"^3.19.0","eslint-plugin-import":"^2.2.0","eslint-plugin-react":"^7.0.1","gzip-size":"^3.0.0","in-publish":"^2.0.0","jest":"^20.0.1","pretty-bytes":"^4.0.2","react":"^15.5.4","react-dom":"^15.5.4","react-redux":"^5.0.4","react-test-renderer":"^15.5.4","redux":"^3.6.0","rollup":"^0.41.6","rollup-plugin-babel":"^2.7.1","rollup-plugin-uglify":"^1.0.2"},"devDependencies":{},"gitHead":"899ee6cb93931c3d81af5130f1117b784ee45578","homepage":"https://github.com/apim-io/auth0-lock-redux#readme","_id":"@apim/auth0-lock-redux@1.0.0","_shasum":"50de9756f8e2af58ba626259b270bea52f5a1f15","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.10.0","_npmUser":{"name":"lgomez","email":"lgomez@gmail.com"},"dist":{"shasum":"50de9756f8e2af58ba626259b270bea52f5a1f15","tarball":"https://registry.npmjs.org/@apim/auth0-lock-redux/-/auth0-lock-redux-1.0.0.tgz","integrity":"sha512-O3nHCMPoqbsZYNirDpplY9MTEeEBzjmWYfuLVfSG6aYJa03tX1ooISKIHyCsf/oPXNHDolIOexIfL4CEB1hVIg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDoRO0+UZX14tFJlkl+bSOSkulqgmfkJMJ8lOUk+JdP+AIhAKKDuRBsQshwvjsjfhEPS0Vt4jKujyu6nrfB7lQjb3T7"}]},"maintainers":[{"name":"lgomez","email":"lgomez@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/auth0-lock-redux-1.0.0.tgz_1494746589909_0.8928825638722628"}},"1.0.1":{"name":"@apim/auth0-lock-redux","version":"1.0.1","private":false,"description":"Auth Lock Redux Middleware","author":{"name":"Luis Gomez","email":"lgomez@gmail.com","url":"http://luis.io"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/apim-io/auth0-lock-redux.git"},"bugs":{"url":"https://github.com/apim-io/eventsourced/issues"},"files":["reducer.js","middleware.js","constants.js","actions.js","index.js","README.md","es","umd"],"main":"index.js","module":"es/index.js","scripts":{"build":"node ./tools/build.js","prepublish":"node ./tools/build.js","watch":"babel ./modules -d . --ignore __tests__ --watch","clean":"git clean -fdX .","lint":"eslint modules","test":"jest"},"keywords":["redux","auth0","middleware","react"],"dependencies":{"auth0-lock":"^10.16.0","babel-cli":"^6.24.1","babel-core":"^6.24.1","babel-eslint":"^7.2.3","babel-jest":"^20.0.1","babel-plugin-transform-react-remove-prop-types":"^0.4.5","babel-preset-es2015":"^6.24.1","babel-preset-react":"^6.24.1","babel-preset-stage-1":"^6.24.1","eslint":"^3.19.0","eslint-plugin-import":"^2.2.0","eslint-plugin-react":"^7.0.1","gzip-size":"^3.0.0","in-publish":"^2.0.0","jest":"^20.0.1","pretty-bytes":"^4.0.2","react":"^15.5.4","react-dom":"^15.5.4","react-redux":"^5.0.4","react-test-renderer":"^15.5.4","redux":"^3.6.0","rollup":"^0.41.6","rollup-plugin-babel":"^2.7.1","rollup-plugin-uglify":"^1.0.2"},"devDependencies":{},"gitHead":"7e968a521b6cf3499a0d9ab8096e4a4f9e52b5b6","homepage":"https://github.com/apim-io/auth0-lock-redux#readme","_id":"@apim/auth0-lock-redux@1.0.1","_shasum":"e3a6267092d06844bdac3da0e66206e1882bc2af","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.10.0","_npmUser":{"name":"lgomez","email":"lgomez@gmail.com"},"dist":{"shasum":"e3a6267092d06844bdac3da0e66206e1882bc2af","tarball":"https://registry.npmjs.org/@apim/auth0-lock-redux/-/auth0-lock-redux-1.0.1.tgz","integrity":"sha512-flfJTjbSn2mE0pJiJABVNn9Etg0hVlAJ3KzEhyinPf/m1YykXO3EXzkSpztEEWIjMTDK8EDreDF17LCi/ajtbA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCeSgrWQBN99VCZC9w4hUCfVhFm3fCnYR5tjF+vH+aiIgIhANgRqWwzQwwHNOcZ7RAsRqG4B7ZbQTSi6ufMiwO4WvUa"}]},"maintainers":[{"name":"lgomez","email":"lgomez@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/auth0-lock-redux-1.0.1.tgz_1494746920963_0.9044207187835127"}},"1.0.2":{"name":"@apim/auth0-lock-redux","version":"1.0.2","private":false,"description":"Auth Lock Redux Middleware","author":{"name":"Luis Gomez","email":"lgomez@gmail.com","url":"http://luis.io"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/apim-io/auth0-lock-redux.git"},"bugs":{"url":"https://github.com/apim-io/eventsourced/issues"},"files":["reducer.js","middleware.js","constants.js","actions.js","index.js","README.md","es","umd"],"main":"index.js","module":"es/index.js","scripts":{"build":"node ./tools/build.js","prepublish":"node ./tools/build.js","watch":"babel ./modules -d . --ignore __tests__ --watch","clean":"git clean -fdX .","lint":"eslint modules","test":"jest"},"keywords":["redux","auth0","middleware","react"],"dependencies":{"auth0-lock":"^10.16.0","babel-cli":"^6.24.1","babel-core":"^6.24.1","babel-eslint":"^7.2.3","babel-jest":"^20.0.1","babel-plugin-transform-react-remove-prop-types":"^0.4.5","babel-preset-es2015":"^6.24.1","babel-preset-react":"^6.24.1","babel-preset-stage-1":"^6.24.1","eslint":"^3.19.0","eslint-plugin-import":"^2.2.0","eslint-plugin-react":"^7.0.1","gzip-size":"^3.0.0","in-publish":"^2.0.0","jest":"^20.0.1","pretty-bytes":"^4.0.2","react":"^15.5.4","react-dom":"^15.5.4","react-redux":"^5.0.4","react-test-renderer":"^15.5.4","redux":"^3.6.0","rollup":"^0.41.6","rollup-plugin-babel":"^2.7.1","rollup-plugin-uglify":"^1.0.2"},"devDependencies":{},"gitHead":"26224e3e64b9e129feb3b59fe31220596e4686a7","homepage":"https://github.com/apim-io/auth0-lock-redux#readme","_id":"@apim/auth0-lock-redux@1.0.2","_shasum":"1f99c4701890ec55705683496f34f1e35c439aa3","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.10.0","_npmUser":{"name":"lgomez","email":"lgomez@gmail.com"},"dist":{"shasum":"1f99c4701890ec55705683496f34f1e35c439aa3","tarball":"https://registry.npmjs.org/@apim/auth0-lock-redux/-/auth0-lock-redux-1.0.2.tgz","integrity":"sha512-QzDnIqN/k5S4o99Q/Z2ifjTzsJS3BEPicdVaxwi+/eU7Ft0lVXAEai/5EJ/NWflgcnb5j3HSt7hRTvXYbeaF2A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCN9omckLaSMKWomq+htDOc/kkvgLPiXRAb4iqE1NvESwIhAITY7HiYCdD8vXpDEysmWGXqD1s7EXfy3OoZvSLS4iLV"}]},"maintainers":[{"name":"lgomez","email":"lgomez@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/auth0-lock-redux-1.0.2.tgz_1494747484481_0.39713400113396347"}}},"readme":"# auth0-lock-redux\n[![npm](https://img.shields.io/npm/dt/@apim/auth0-lock-redux.svg)](https://www.npmjs.com/package/@apim/auth0-lock-redux) [![GitHub issues](https://img.shields.io/github/issues/apim-io/auth0-lock-redux.svg)](https://github.com/apim-io/auth0-lock-redux/issues) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/apim-io/auth0-lock-redux/master/LICENSE)\n\n> Auth Lock Redux Middleware\n\nThis middleware facilitates Auth0 Lock & Redux integration.\n\n## Installation\n\n```\nnpm install --save @apim/auth0-lock-redux\n```\n\n## Features\n\n* Use your own action to trigger authentication by passing the right meta information.\n* Right after authentication, the user's profile is fetched automatically and made available for reduction. Use the bundled reducer to grab the full profile or write your own.\n* Auth0 Lock first gives us an authentication payload (with the token and auth-only data) and then gives us profile data (via another call). This middleware returns both in one object by moving the auth object to be under `profile.auth`\n* All Auth0 Lock events are mapped to actions. Only \"authenticated\" is really being used but I am planning to add more.\n* Nicely formatted for `redux-logger`.\n* I intentionally leave out any routing changes and localStorage. Use your own middleware to do either. Yes, I consider this a feature.\n\n## Usage\n### Middleware Setup\n```javascript\nimport auth0LockReduxMiddleware from '@apim/auth0-lock-redux'\n\n// Auth0 Lock key (see auth0-lock docs)\nconst options = {\n  key: '...',\n  domain: '...',\n  options: {}\n}\n\n// Add it to your middleware array\nconst middlewares = [\n  auth0LockReduxMiddleware(options)\n]\n\n// Apply as usual\napplyMiddleware(...middlewares)\n```\nAlternatively, if you already have an instance of `auth0-lock` with your settings, pass the instance and it'll be used instead:\n```javascript\nimport Auth0Lock from 'auth0-lock'\nimport auth0LockReduxMiddleware from '@apim/auth0-lock-redux'\n\nconst auth0lock = new Auth0Lock(/* key */, /* domain */, /* options */)\n\n// Add it to your middleware array\nconst middlewares = [\n  auth0LockReduxMiddleware(auth0lock)\n]\n\n// Apply as usual\napplyMiddleware(...middlewares)\n```\n### Triggering Authentication\nFor now, the way to trigger authentication if you don't do it directly with your own instance of `auth0-lock` is to set the meta value for your action of choice to the value of the `AUTHENTICATE` constant.\n```javascript\nimport { AUTHENTICATE } from '@apim/auth0-lock-redux'\n\nconst SIGN_IN = () => ({\n  type: 'SIGN_IN',\n  meta: AUTHENTICATE // Internally it looks like this: '@@auth0Lock/AUTHENTICATE'\n})\n```\n### Reducer (optional)\nAdd a reducer to reduce the received user profile. You have two options:\n#### Use the bundled reducer and get the full object:\n```javascript\nimport { AUTHENTICATED, auth0LockReducer } from '@apim/auth0-lock-redux'\nconst reducers = combineReducers({\n  user: auth0LockReducer\n})\n```\n#### Add your own reducer to the PROFILE action:\nThis lets you customize the reduction. I'm using `redux-actions` in this example.\n```javascript\nimport {\n  AUTHENTICATED,\n  REVOKED,\n  PROFILE,\n  auth0LockReducer\n} from '@apim/auth0-lock-redux'\n\nconst user = handleActions({\n  [REVOKED]: () => null,\n  [PROFILE]: (state, action) => ({\n    ...state,\n    token: action.payload.auth.accessToken, // Grab only the token\n    name: action.payload.name // ...and the user's name\n  })\n}, state.user)\n\n```\n### Reduce noise in `redux-logger`\nAdd a reducer to reduce the received user profile. You have two options:\n```javascript\n// Collapse these entries...\ncreateLogger({\n  collapsed: (getState, action) => /auth0Lock/.test(action.type)\n});\n\n// Or omit it completely...\ncreateLogger({\n  predicate: (getState, action) => !/router/.test(action.type)\n});\n```\n\n### Constants\n```javascript\n// [TODO] Some initialization may be added in the future.\nconst INITIALIZE = '@@auth0Lock/INITIALIZE'\n// Trigger authentication.\nconst AUTHENTICATE = '@@auth0Lock/AUTHENTICATE'\n// When profile is received.\nconst PROFILE = '@@auth0Lock/PROFILE'\n// When profile load fails.\nconst PROFILE_ERROR = '@@auth0Lock/PROFILE_ERROR'\n// [TODO] Dispatched when token revoked (aka: sign out)\nconst REVOKED = '@@auth0Lock/REVOKED'\n// [TODO] Dispatched when token is checked.\nconst CHECK = '@@auth0Lock/CHECK'\n// Dispatched when sign in form is shown.*\nconst SHOW = '@@auth0Lock/SHOW'\n// Dispatched when sign in form is hidden.*\nconst HIDE = '@@auth0Lock/HIDE'\n// Dispatched when lock emits an unrecoverable_error.*\nconst UNRECOVERABLE_ERROR = '@@auth0Lock/UNRECOVERABLE_ERROR'\n// Dispatched when token is received.*\nconst AUTHENTICATED = '@@auth0Lock/AUTHENTICATED'\n// Dispatched when authentication fails.*\nconst AUTHORIZATION_ERROR = '@@auth0Lock/AUTHORIZATION_ERROR'\n// Dispatched when a hash parse attempt is done.*\nconst HASH_PARSED = '@@auth0Lock/HASH_PARSED'\n```\n* Note: these are straight maddings of Auth0 Lock's own events. See their docs.\n","maintainers":[{"name":"lgomez","email":"lgomez@gmail.com"}],"time":{"modified":"2022-06-12T14:43:48.886Z","created":"2017-05-14T07:23:10.169Z","1.0.0":"2017-05-14T07:23:10.169Z","1.0.1":"2017-05-14T07:28:43.067Z","1.0.2":"2017-05-14T07:38:04.728Z"},"homepage":"https://github.com/apim-io/auth0-lock-redux#readme","keywords":["redux","auth0","middleware","react"],"repository":{"type":"git","url":"git+https://github.com/apim-io/auth0-lock-redux.git"},"author":{"name":"Luis Gomez","email":"lgomez@gmail.com","url":"http://luis.io"},"bugs":{"url":"https://github.com/apim-io/eventsourced/issues"},"license":"MIT","readmeFilename":"README.md"}