Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bufferapp/async-data-fetch

Package Overview
Dependencies
Maintainers
9
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bufferapp/async-data-fetch - npm Package Compare versions

Comparing version 0.5.35 to 0.5.36-beta01

7

middleware.js

@@ -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,
});
});
});

2

package.json
{
"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;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc