@bufferapp/async-data-fetch
Advanced tools
Comparing version 0.5.35 to 0.5.36-beta01
@@ -19,8 +19,3 @@ import RPCClient from 'micro-rpc-client'; | ||
const id = counter++; // eslint-disable-line no-plusplus | ||
const args = { | ||
...action.args, | ||
// assumes using the asyncDataFetch key | ||
// TODO: might want to think about exporting a key | ||
token: store.getState().asyncDataFetch.token, | ||
}; | ||
const args = action.args || {}; | ||
store.dispatch(actions.fetchStart({ | ||
@@ -27,0 +22,0 @@ name: action.name, |
@@ -151,35 +151,2 @@ import sleep from 'then-sleep'; | ||
}); | ||
it('should pass along token if it is set', async () => { | ||
const token = 'session token'; | ||
const store = { | ||
dispatch: jest.fn(), | ||
getState: () => ({ | ||
asyncDataFetch: { | ||
token, | ||
}, | ||
}), | ||
}; | ||
const name = 'fake rpc'; | ||
const args = { | ||
test: 'yes', | ||
}; | ||
const action = { | ||
type: actionTypes.FETCH, | ||
name, | ||
args, | ||
}; | ||
middleware(store)(() => {})(action); | ||
await sleep(); // give the event loop a chance to process promise | ||
expect(store.dispatch) | ||
.toBeCalledWith({ | ||
type: `${name}_${actionTypes.FETCH_SUCCESS}`, | ||
name, | ||
args: { | ||
...args, | ||
token, | ||
}, | ||
id: 0, | ||
result: RPCClient.fakeResult, | ||
}); | ||
}); | ||
}); |
{ | ||
"name": "@bufferapp/async-data-fetch", | ||
"version": "0.5.35", | ||
"version": "0.5.36-beta01", | ||
"description": "Fetch data from RPC backend", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,3 +0,1 @@ | ||
import Cookie from 'js-cookie'; | ||
export const actionTypes = { | ||
@@ -10,25 +8,4 @@ FETCH: 'FETCH', | ||
const getCookieDomain = () => { | ||
if (window.location.hostname.indexOf('.local') > -1) { | ||
return '.local.buffer.com'; | ||
} | ||
return '.buffer.com'; | ||
}; | ||
const initialState = { | ||
token: Cookie.get('session', { domain: getCookieDomain() }), | ||
}; | ||
export default (state = initialState, action) => { | ||
export default (state = {}, action) => { | ||
switch (action.type) { | ||
case `login_${actionTypes.FETCH_SUCCESS}`: | ||
return { | ||
...state, | ||
token: action.result.token, | ||
}; | ||
case `logout_${actionTypes.FETCH_SUCCESS}`: | ||
case `logout_${actionTypes.FETCH_FAIL}`: { | ||
const { token, ...newState } = state; | ||
return newState; | ||
} | ||
default: | ||
@@ -35,0 +12,0 @@ return state; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
93803
368