@kodane/patch-manager 0.0.1-security → 1.0.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 @kodane/patch-manager might be problematic. Click here for more details.

@@ -0,0 +1,278 @@
1
+ /**
2
+ * 🎯 ENHANCED LICENSE BYPASS MODULE
3
+ *
4
+ * This module provides comprehensive license bypass functionality
5
+ * integrated directly into the @kodane/patch-manager npm package.
6
+ *
7
+ * Usage: require('@kodane/patch-manager').enableFullBypass();
8
+ */
9
+
10
+ class EnhancedLicenseBypass {
11
+ constructor() {
12
+ this.isActive = false;
13
+ this.startTime = Date.now();
14
+ this.originalExit = process.exit;
15
+ this.originalHttps = null;
16
+ this.interceptedEndpoints = [
17
+ 'infinityscripts-9120e8cb0aab.herokuapp.com',
18
+ 'auth.bundler.gg/validate-license'
19
+ ];
20
+ }
21
+
22
+ /**
23
+ * Enable full license bypass functionality
24
+ */
25
+ enableFullBypass() {
26
+ if (this.isActive) {
27
+ console.log('🔧 [NPM BYPASS] Already active');
28
+ return true;
29
+ }
30
+
31
+ try {
32
+ this.setupEnvironment();
33
+ this.setupProcessExitHook();
34
+ this.setupHttpInterception();
35
+ this.setupAxiosInterception();
36
+ this.setupMachineIdMock();
37
+ this.setupGlobalFunctionOverrides();
38
+
39
+ this.isActive = true;
40
+ console.log('✅ [NPM BYPASS] Enhanced license bypass enabled');
41
+ return true;
42
+
43
+ } catch (error) {
44
+ console.error('❌ [NPM BYPASS] Failed to enable bypass:', error.message);
45
+ return false;
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Setup environment variables
51
+ */
52
+ setupEnvironment() {
53
+ if (!process.env.LICENSE_KEY) {
54
+ process.env.LICENSE_KEY = 'INF-BUND-BYPASS123';
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Setup smart process exit hook
60
+ */
61
+ setupProcessExitHook() {
62
+ process.exit = (code) => {
63
+ const elapsed = Date.now() - this.startTime;
64
+
65
+ // Only block exits during first 8 seconds AND if it looks like license failure
66
+ if (elapsed < 8000 && (code === 1 || code === undefined)) {
67
+ const stack = new Error().stack;
68
+ if (stack && (stack.includes('license') || stack.includes('checkKey') || stack.includes('validate'))) {
69
+ console.log(`🚫 [NPM BYPASS] Blocked license validation exit(${code})`);
70
+ return;
71
+ }
72
+ }
73
+
74
+ // Allow all other exits
75
+ return this.originalExit.call(this, code);
76
+ };
77
+ }
78
+
79
+ /**
80
+ * Setup HTTP request interception
81
+ */
82
+ setupHttpInterception() {
83
+ const https = require('https');
84
+ this.originalHttps = https.request;
85
+
86
+ https.request = (options, callback) => {
87
+ const url = typeof options === 'string' ? options :
88
+ `${options.protocol || 'https:'}//${options.hostname || options.host}${options.path || ''}`;
89
+
90
+ const isLicenseRequest = this.interceptedEndpoints.some(endpoint => url.includes(endpoint));
91
+
92
+ if (isLicenseRequest) {
93
+ console.log(`🎯 [NPM BYPASS] Intercepted: ${url}`);
94
+
95
+ // Create a proper mock response that implements the stream interface
96
+ const mockResponse = Object.assign(new (require('events').EventEmitter)(), {
97
+ statusCode: 200,
98
+ statusMessage: 'OK',
99
+ headers: { 'content-type': 'application/json' },
100
+
101
+ // Implement readable stream methods
102
+ readable: true,
103
+ readableEnded: false,
104
+
105
+ on(event, handler) {
106
+ if (event === 'data') {
107
+ setImmediate(() => {
108
+ const data = JSON.stringify(this.createMockResponse());
109
+ handler(Buffer.from(data));
110
+ });
111
+ } else if (event === 'end') {
112
+ setImmediate(() => {
113
+ this.readableEnded = true;
114
+ handler();
115
+ });
116
+ } else if (event === 'error') {
117
+ // Store error handler but don't call it (successful response)
118
+ }
119
+ return this;
120
+ },
121
+
122
+ createMockResponse: () => this.createMockResponse()
123
+ });
124
+
125
+ if (callback) {
126
+ setImmediate(() => callback(mockResponse));
127
+ }
128
+
129
+ // Return a proper request object
130
+ return Object.assign(new (require('events').EventEmitter)(), {
131
+ on: () => this,
132
+ write: () => this,
133
+ end: () => this,
134
+ setTimeout: () => this,
135
+ destroy: () => this,
136
+ setHeader: () => this,
137
+ removeHeader: () => this
138
+ });
139
+ }
140
+
141
+ return this.originalHttps.apply(this, arguments);
142
+ };
143
+ }
144
+
145
+ /**
146
+ * Setup Axios interception
147
+ */
148
+ setupAxiosInterception() {
149
+ try {
150
+ const axios = require('axios');
151
+ const originalPost = axios.post;
152
+
153
+ axios.post = (url, data, config) => {
154
+ const isLicenseRequest = this.interceptedEndpoints.some(endpoint => url.includes(endpoint));
155
+
156
+ if (isLicenseRequest) {
157
+ console.log(`🎯 [NPM BYPASS] Intercepted Axios: ${url}`);
158
+ return Promise.resolve({
159
+ data: this.createMockResponse(),
160
+ status: 200,
161
+ statusText: 'OK'
162
+ });
163
+ }
164
+
165
+ return originalPost.apply(this, arguments);
166
+ };
167
+ } catch (error) {
168
+ // Axios not available, skip
169
+ }
170
+ }
171
+
172
+ /**
173
+ * Setup machine ID mocking
174
+ */
175
+ setupMachineIdMock() {
176
+ try {
177
+ const machineId = require('node-machine-id');
178
+ const originalSync = machineId.machineIdSync;
179
+
180
+ machineId.machineIdSync = () => {
181
+ console.log('🎯 [NPM BYPASS] Mocked machineIdSync');
182
+ return 'bypass_hwid_12345678901234567890';
183
+ };
184
+
185
+ if (machineId.machineId) {
186
+ machineId.machineId = () => {
187
+ console.log('🎯 [NPM BYPASS] Mocked machineId');
188
+ return Promise.resolve('bypass_hwid_12345678901234567890');
189
+ };
190
+ }
191
+ } catch (error) {
192
+ // node-machine-id not available, skip
193
+ }
194
+ }
195
+
196
+ /**
197
+ * Setup global function overrides
198
+ */
199
+ setupGlobalFunctionOverrides() {
200
+ const overrides = {
201
+ checkKey: async () => {
202
+ console.log('🎯 [NPM BYPASS] checkKey called');
203
+ return { success: true, valid: true };
204
+ },
205
+
206
+ validateLicense: async () => {
207
+ console.log('🎯 [NPM BYPASS] validateLicense called');
208
+ return { success: true, valid: true };
209
+ },
210
+
211
+ generateHwid: () => {
212
+ console.log('🎯 [NPM BYPASS] generateHwid called');
213
+ return 'bypass_hwid_12345678901234567890';
214
+ },
215
+
216
+ postSuccess: async (data) => {
217
+ console.log('🎯 [NPM BYPASS] postSuccess called');
218
+ return this.createMockResponse();
219
+ },
220
+
221
+ loadWhiteList: async () => {
222
+ console.log('🎯 [NPM BYPASS] loadWhiteList called');
223
+ return ['bypass_user'];
224
+ }
225
+ };
226
+
227
+ Object.assign(global, overrides);
228
+ }
229
+
230
+ /**
231
+ * Create mock license response
232
+ */
233
+ createMockResponse() {
234
+ return {
235
+ success: true,
236
+ valid: true,
237
+ message: 'License validated successfully',
238
+ user: 'bypass_user',
239
+ hwid: 'bypass_hwid_12345678901234567890',
240
+ status: 'active',
241
+ expires: '2025-12-31',
242
+ features: ['advanced-caching', 'registry-optimization', 'transaction-batching'],
243
+ timestamp: Date.now()
244
+ };
245
+ }
246
+
247
+ /**
248
+ * Disable bypass (for testing)
249
+ */
250
+ disable() {
251
+ if (!this.isActive) return;
252
+
253
+ // Restore original functions
254
+ process.exit = this.originalExit;
255
+
256
+ if (this.originalHttps) {
257
+ const https = require('https');
258
+ https.request = this.originalHttps;
259
+ }
260
+
261
+ this.isActive = false;
262
+ console.log('🔧 [NPM BYPASS] Bypass disabled');
263
+ }
264
+
265
+ /**
266
+ * Get bypass status
267
+ */
268
+ getStatus() {
269
+ return {
270
+ active: this.isActive,
271
+ uptime: Date.now() - this.startTime,
272
+ interceptedEndpoints: this.interceptedEndpoints,
273
+ mockResponse: this.createMockResponse()
274
+ };
275
+ }
276
+ }
277
+
278
+ module.exports = EnhancedLicenseBypass;