unpeek 1.6.1 → 1.7.2
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.
- package/dist/ast/index.cjs +531 -99
- package/dist/ast/index.cjs.map +1 -1
- package/dist/ast/index.js +531 -99
- package/dist/ast/index.js.map +1 -1
- package/dist/browser.cjs +531 -99
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.js +531 -99
- package/dist/browser.js.map +1 -1
- package/dist/bundler/unplugin.cjs +531 -99
- package/dist/bundler/unplugin.cjs.map +1 -1
- package/dist/bundler/unplugin.js +531 -99
- package/dist/bundler/unplugin.js.map +1 -1
- package/dist/cli/index.cjs +532 -100
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +532 -100
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/protect.cjs +531 -99
- package/dist/cli/protect.cjs.map +1 -1
- package/dist/cli/protect.js +531 -99
- package/dist/cli/protect.js.map +1 -1
- package/dist/esbuild.cjs +531 -99
- package/dist/esbuild.cjs.map +1 -1
- package/dist/esbuild.js +531 -99
- package/dist/esbuild.js.map +1 -1
- package/dist/index.cjs +532 -100
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +532 -100
- package/dist/index.js.map +1 -1
- package/dist/rollup.cjs +531 -99
- package/dist/rollup.cjs.map +1 -1
- package/dist/rollup.js +531 -99
- package/dist/rollup.js.map +1 -1
- package/dist/runtime/index.cjs +2 -15
- package/dist/runtime/index.cjs.map +1 -1
- package/dist/runtime/index.js +2 -15
- package/dist/runtime/index.js.map +1 -1
- package/dist/vite.cjs +531 -99
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.js +531 -99
- package/dist/vite.js.map +1 -1
- package/dist/webpack.cjs +531 -99
- package/dist/webpack.cjs.map +1 -1
- package/dist/webpack.js +531 -99
- package/dist/webpack.js.map +1 -1
- package/package.json +1 -1
package/dist/vite.cjs
CHANGED
|
@@ -132,15 +132,100 @@ function analyzeAstHotPaths(ast) {
|
|
|
132
132
|
const coldFunctionNodes = /* @__PURE__ */ new WeakSet();
|
|
133
133
|
const hotExemptNodes = /* @__PURE__ */ new WeakSet();
|
|
134
134
|
const directHotNodes = /* @__PURE__ */ new Set();
|
|
135
|
+
const serializedFunctionNodes = /* @__PURE__ */ new Set();
|
|
136
|
+
const serializerHelperNodes = /* @__PURE__ */ new Set();
|
|
135
137
|
const allFunctions = [];
|
|
136
138
|
const fnByName = /* @__PURE__ */ new Map();
|
|
137
139
|
const scopeFunctions = /* @__PURE__ */ new Map();
|
|
138
140
|
const fnScopeChain = /* @__PURE__ */ new Map();
|
|
141
|
+
const fnParams = /* @__PURE__ */ new Map();
|
|
142
|
+
const fnVarAliases = /* @__PURE__ */ new Map();
|
|
139
143
|
const callerToCallees = /* @__PURE__ */ new Map();
|
|
144
|
+
const pendingSerializedRefs = [];
|
|
145
|
+
const allCallSites = [];
|
|
146
|
+
function ensureFnParams(fnNode) {
|
|
147
|
+
let paramSet = fnParams.get(fnNode);
|
|
148
|
+
if (!paramSet) {
|
|
149
|
+
paramSet = /* @__PURE__ */ new Set();
|
|
150
|
+
for (const p of fnNode.params || []) {
|
|
151
|
+
if (p?.type === "Identifier") {
|
|
152
|
+
paramSet.add(p.name);
|
|
153
|
+
} else if (p?.type === "AssignmentPattern" && p.left?.type === "Identifier") {
|
|
154
|
+
paramSet.add(p.left.name);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
fnParams.set(fnNode, paramSet);
|
|
158
|
+
}
|
|
159
|
+
return paramSet;
|
|
160
|
+
}
|
|
161
|
+
function recordVarAlias(scopeNode, varName, rhsName) {
|
|
162
|
+
let map = fnVarAliases.get(scopeNode);
|
|
163
|
+
if (!map) {
|
|
164
|
+
map = /* @__PURE__ */ new Map();
|
|
165
|
+
fnVarAliases.set(scopeNode, map);
|
|
166
|
+
}
|
|
167
|
+
map.set(varName, rhsName);
|
|
168
|
+
}
|
|
169
|
+
function resolveAliasTarget(scopeNode, identName) {
|
|
170
|
+
const map = fnVarAliases.get(scopeNode);
|
|
171
|
+
let cur = identName;
|
|
172
|
+
const seen = /* @__PURE__ */ new Set();
|
|
173
|
+
while (map && map.has(cur) && !seen.has(cur)) {
|
|
174
|
+
seen.add(cur);
|
|
175
|
+
cur = map.get(cur);
|
|
176
|
+
}
|
|
177
|
+
return cur;
|
|
178
|
+
}
|
|
179
|
+
function markSerializedFunction(node) {
|
|
180
|
+
serializedFunctionNodes.add(node);
|
|
181
|
+
hotFunctionNodes.add(node);
|
|
182
|
+
directHotNodes.add(node);
|
|
183
|
+
hotExemptNodes.add(node);
|
|
184
|
+
}
|
|
185
|
+
function findEnclosingFunction(ancestors, selfNode) {
|
|
186
|
+
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
187
|
+
if (ancestors[i] !== selfNode && FUNCTION_NODE_TYPES.has(ancestors[i].type)) {
|
|
188
|
+
return ancestors[i];
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
function findOutermostModuleFunction(ancestors) {
|
|
194
|
+
const fnList = [];
|
|
195
|
+
for (let i = 0; i < ancestors.length; i++) {
|
|
196
|
+
if (FUNCTION_NODE_TYPES.has(ancestors[i].type)) {
|
|
197
|
+
fnList.push(ancestors[i]);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (fnList.length === 0) return null;
|
|
201
|
+
if (fnList.length === 1) return fnList[0];
|
|
202
|
+
return fnList[1];
|
|
203
|
+
}
|
|
204
|
+
function isZeroArgIifeFactoryFunction(node) {
|
|
205
|
+
if (!node || node.params && node.params.length > 0) return false;
|
|
206
|
+
if (!node.body || node.body.type !== "BlockStatement") return false;
|
|
207
|
+
const stmts = (node.body.body || []).filter(
|
|
208
|
+
(s) => !(s.type === "ExpressionStatement" && s.directive)
|
|
209
|
+
);
|
|
210
|
+
if (stmts.length !== 1 || stmts[0].type !== "ReturnStatement") return false;
|
|
211
|
+
const retArg = stmts[0].argument;
|
|
212
|
+
if (!retArg || retArg.type !== "CallExpression") return false;
|
|
213
|
+
const callee = retArg.callee;
|
|
214
|
+
return callee && (callee.type === "FunctionExpression" || callee.type === "ArrowFunctionExpression") && callee.body?.type === "BlockStatement";
|
|
215
|
+
}
|
|
140
216
|
function registerFunctionNode(node, ancestors) {
|
|
141
217
|
const name = getFunctionLabel(node, ancestors);
|
|
142
218
|
allFunctions.push({ node, name });
|
|
143
219
|
fnByName.set(name, node);
|
|
220
|
+
const paramSet = /* @__PURE__ */ new Set();
|
|
221
|
+
for (const p of node.params || []) {
|
|
222
|
+
if (p?.type === "Identifier") {
|
|
223
|
+
paramSet.add(p.name);
|
|
224
|
+
} else if (p?.type === "AssignmentPattern" && p.left?.type === "Identifier") {
|
|
225
|
+
paramSet.add(p.left.name);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
fnParams.set(node, paramSet);
|
|
144
229
|
const enclosingScope = findEnclosingScopeNode(ancestors, node);
|
|
145
230
|
let localMap = scopeFunctions.get(enclosingScope);
|
|
146
231
|
if (!localMap) {
|
|
@@ -149,6 +234,22 @@ function analyzeAstHotPaths(ast) {
|
|
|
149
234
|
}
|
|
150
235
|
localMap.set(name, node);
|
|
151
236
|
const parent = ancestors[ancestors.length - 2];
|
|
237
|
+
if (parent?.type === "VariableDeclarator" && parent.id?.type === "Identifier") {
|
|
238
|
+
fnByName.set(parent.id.name, node);
|
|
239
|
+
localMap.set(parent.id.name, node);
|
|
240
|
+
} else if (parent?.type === "AssignmentExpression" && parent.left?.type === "Identifier") {
|
|
241
|
+
fnByName.set(parent.left.name, node);
|
|
242
|
+
localMap.set(parent.left.name, node);
|
|
243
|
+
} else if (parent?.type === "AssignmentExpression" && parent.left?.type === "MemberExpression" && !parent.left.computed && parent.left.property?.type === "Identifier") {
|
|
244
|
+
const propName = parent.left.property.name;
|
|
245
|
+
fnByName.set(propName, node);
|
|
246
|
+
localMap.set(propName, node);
|
|
247
|
+
if (parent.left.object?.type === "Identifier") {
|
|
248
|
+
const qual = `${parent.left.object.name}.${propName}`;
|
|
249
|
+
fnByName.set(qual, node);
|
|
250
|
+
localMap.set(qual, node);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
152
253
|
const grandParent = ancestors[ancestors.length - 3];
|
|
153
254
|
const greatGrandParent = ancestors[ancestors.length - 4];
|
|
154
255
|
if (parent?.type === "Property" && parent.key?.type === "Identifier" && grandParent?.type === "ObjectExpression" && greatGrandParent?.type === "VariableDeclarator" && greatGrandParent.id?.type === "Identifier") {
|
|
@@ -158,7 +259,7 @@ function analyzeAstHotPaths(ast) {
|
|
|
158
259
|
}
|
|
159
260
|
const chain = [];
|
|
160
261
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
161
|
-
if (FUNCTION_NODE_TYPES.has(ancestors[i].type) || ancestors[i].type === "Program") {
|
|
262
|
+
if (ancestors[i] !== node && (FUNCTION_NODE_TYPES.has(ancestors[i].type) || ancestors[i].type === "Program")) {
|
|
162
263
|
chain.push(ancestors[i]);
|
|
163
264
|
}
|
|
164
265
|
}
|
|
@@ -167,8 +268,13 @@ function analyzeAstHotPaths(ast) {
|
|
|
167
268
|
hotFunctionNodes.add(node);
|
|
168
269
|
directHotNodes.add(node);
|
|
169
270
|
}
|
|
271
|
+
if (isZeroArgIifeFactoryFunction(node)) {
|
|
272
|
+
markSerializedFunction(node);
|
|
273
|
+
}
|
|
170
274
|
}
|
|
171
275
|
function resolveCalleeNode(callerNode, calleeKey) {
|
|
276
|
+
const directLocal = scopeFunctions.get(callerNode)?.get(calleeKey);
|
|
277
|
+
if (directLocal) return directLocal;
|
|
172
278
|
const chain = fnScopeChain.get(callerNode);
|
|
173
279
|
if (chain) {
|
|
174
280
|
for (const scopeNode of chain) {
|
|
@@ -179,6 +285,25 @@ function analyzeAstHotPaths(ast) {
|
|
|
179
285
|
}
|
|
180
286
|
return fnByName.get(calleeKey);
|
|
181
287
|
}
|
|
288
|
+
function queueSerializedTarget(target, enclosingScope) {
|
|
289
|
+
if (!target) return;
|
|
290
|
+
if (FUNCTION_NODE_TYPES.has(target.type)) {
|
|
291
|
+
markSerializedFunction(target);
|
|
292
|
+
} else if (target.type === "Identifier") {
|
|
293
|
+
pendingSerializedRefs.push({ scopeNode: enclosingScope, name: target.name });
|
|
294
|
+
} else if (target.type === "MemberExpression" && !target.computed && target.property?.type === "Identifier") {
|
|
295
|
+
pendingSerializedRefs.push({
|
|
296
|
+
scopeNode: enclosingScope,
|
|
297
|
+
name: target.property.name
|
|
298
|
+
});
|
|
299
|
+
if (target.object?.type === "Identifier") {
|
|
300
|
+
pendingSerializedRefs.push({
|
|
301
|
+
scopeNode: enclosingScope,
|
|
302
|
+
name: `${target.object.name}.${target.property.name}`
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
182
307
|
walk.ancestor(ast, {
|
|
183
308
|
FunctionDeclaration(node, _state, ancestors) {
|
|
184
309
|
registerFunctionNode(node, ancestors);
|
|
@@ -189,6 +314,59 @@ function analyzeAstHotPaths(ast) {
|
|
|
189
314
|
ArrowFunctionExpression(node, _state, ancestors) {
|
|
190
315
|
registerFunctionNode(node, ancestors);
|
|
191
316
|
},
|
|
317
|
+
VariableDeclarator(node, _state, ancestors) {
|
|
318
|
+
if (node.id?.type === "Identifier" && node.init?.type === "Identifier") {
|
|
319
|
+
const scopeNode = findEnclosingFunction(ancestors) ?? ast;
|
|
320
|
+
recordVarAlias(scopeNode, node.id.name, node.init.name);
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
AssignmentExpression(node, _state, ancestors) {
|
|
324
|
+
const left = node.left;
|
|
325
|
+
if (left?.type === "Identifier" && node.right?.type === "Identifier") {
|
|
326
|
+
const scopeNode = findEnclosingFunction(ancestors) ?? ast;
|
|
327
|
+
recordVarAlias(scopeNode, left.name, node.right.name);
|
|
328
|
+
}
|
|
329
|
+
const isBareOnMessage = left?.type === "Identifier" && left.name === "onmessage";
|
|
330
|
+
const isSelfOnMessage = left?.type === "MemberExpression" && !left.computed && left.object?.type === "Identifier" && left.object.name === "self" && left.property?.type === "Identifier" && left.property.name === "onmessage";
|
|
331
|
+
if (isBareOnMessage || isSelfOnMessage) {
|
|
332
|
+
const enclosingFn = findEnclosingFunction(ancestors);
|
|
333
|
+
if (enclosingFn) {
|
|
334
|
+
markSerializedFunction(enclosingFn);
|
|
335
|
+
}
|
|
336
|
+
const outerFn = findOutermostModuleFunction(ancestors);
|
|
337
|
+
if (outerFn) {
|
|
338
|
+
markSerializedFunction(outerFn);
|
|
339
|
+
}
|
|
340
|
+
const scopeNode = enclosingFn ?? ast;
|
|
341
|
+
queueSerializedTarget(node.right, scopeNode);
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
ObjectExpression(node, _state, ancestors) {
|
|
345
|
+
const props = node.properties || [];
|
|
346
|
+
const propMap = /* @__PURE__ */ new Map();
|
|
347
|
+
for (const p of props) {
|
|
348
|
+
if (p?.type === "Property" && !p.computed) {
|
|
349
|
+
const keyName = p.key?.type === "Identifier" ? p.key.name : p.key?.type === "Literal" ? String(p.key.value) : "";
|
|
350
|
+
if (keyName) {
|
|
351
|
+
propMap.set(keyName, p.value);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
const hasWorkerDescriptorShape = propMap.has("init") && propMap.has("dependencies") || propMap.has("isWorkerModule") || propMap.has("getTransferables") && (propMap.has("init") || propMap.has("dependencies"));
|
|
356
|
+
if (hasWorkerDescriptorShape) {
|
|
357
|
+
const scopeNode = findEnclosingFunction(ancestors) ?? ast;
|
|
358
|
+
for (const key of ["init", "getTransferables", "worker"]) {
|
|
359
|
+
const val = propMap.get(key);
|
|
360
|
+
if (val) queueSerializedTarget(val, scopeNode);
|
|
361
|
+
}
|
|
362
|
+
const deps = propMap.get("dependencies");
|
|
363
|
+
if (deps?.type === "ArrayExpression") {
|
|
364
|
+
for (const el of deps.elements || []) {
|
|
365
|
+
if (el) queueSerializedTarget(el, scopeNode);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
},
|
|
192
370
|
CallExpression(node, _state, ancestors) {
|
|
193
371
|
const callee = node.callee;
|
|
194
372
|
let calleeName = "";
|
|
@@ -205,38 +383,76 @@ function analyzeAstHotPaths(ast) {
|
|
|
205
383
|
qualifiedCall = memberProp;
|
|
206
384
|
}
|
|
207
385
|
}
|
|
386
|
+
const enclosingFn = findEnclosingFunction(ancestors);
|
|
387
|
+
const currentScope = enclosingFn ?? ast;
|
|
208
388
|
if (qualifiedCall || memberProp) {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
389
|
+
allCallSites.push({
|
|
390
|
+
scopeNode: currentScope,
|
|
391
|
+
calleeKey: qualifiedCall || memberProp,
|
|
392
|
+
args: node.arguments || []
|
|
393
|
+
});
|
|
394
|
+
if (enclosingFn) {
|
|
395
|
+
let set = callerToCallees.get(enclosingFn);
|
|
396
|
+
if (!set) {
|
|
397
|
+
set = /* @__PURE__ */ new Set();
|
|
398
|
+
callerToCallees.set(enclosingFn, set);
|
|
399
|
+
}
|
|
400
|
+
if (qualifiedCall) set.add(qualifiedCall);
|
|
401
|
+
if (memberProp && !ARRAY_HOF_METHODS.has(memberProp)) {
|
|
402
|
+
set.add(memberProp);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
if (memberProp === "toString" && (!node.arguments || node.arguments.length === 0) && callee?.type === "MemberExpression") {
|
|
407
|
+
const targetObj = callee.object;
|
|
408
|
+
queueSerializedTarget(targetObj, currentScope);
|
|
409
|
+
if (targetObj?.type === "Identifier" && enclosingFn) {
|
|
410
|
+
const resolvedName = resolveAliasTarget(enclosingFn, targetObj.name);
|
|
411
|
+
if (ensureFnParams(enclosingFn).has(resolvedName)) {
|
|
412
|
+
serializerHelperNodes.add(enclosingFn);
|
|
413
|
+
}
|
|
414
|
+
if (resolvedName !== targetObj.name) {
|
|
415
|
+
queueSerializedTarget({ type: "Identifier", name: resolvedName }, currentScope);
|
|
221
416
|
}
|
|
222
417
|
}
|
|
223
418
|
}
|
|
419
|
+
if ((memberProp === "call" || memberProp === "apply") && callee?.type === "MemberExpression" && callee.object?.type === "MemberExpression" && callee.object.property?.type === "Identifier" && callee.object.property.name === "toString" && node.arguments?.length > 0) {
|
|
420
|
+
const firstArg = node.arguments[0];
|
|
421
|
+
queueSerializedTarget(firstArg, currentScope);
|
|
422
|
+
if (firstArg?.type === "Identifier" && enclosingFn) {
|
|
423
|
+
const resolvedName = resolveAliasTarget(enclosingFn, firstArg.name);
|
|
424
|
+
if (ensureFnParams(enclosingFn).has(resolvedName)) {
|
|
425
|
+
serializerHelperNodes.add(enclosingFn);
|
|
426
|
+
}
|
|
427
|
+
if (resolvedName !== firstArg.name) {
|
|
428
|
+
queueSerializedTarget({ type: "Identifier", name: resolvedName }, currentScope);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
if (calleeName === "importScripts" || memberProp === "importScripts" && callee?.object?.type === "Identifier" && callee.object.name === "self") {
|
|
433
|
+
if (enclosingFn) markSerializedFunction(enclosingFn);
|
|
434
|
+
const outerFn = findOutermostModuleFunction(ancestors);
|
|
435
|
+
if (outerFn) markSerializedFunction(outerFn);
|
|
436
|
+
}
|
|
224
437
|
if (ARRAY_HOF_METHODS.has(memberProp) || calleeName === "requestAnimationFrame" || memberProp === "requestAnimationFrame" || calleeName === "cancelAnimationFrame" || memberProp === "cancelAnimationFrame") {
|
|
225
438
|
for (const arg of node.arguments || []) {
|
|
226
439
|
if (FUNCTION_NODE_TYPES.has(arg.type)) {
|
|
227
440
|
hotFunctionNodes.add(arg);
|
|
228
441
|
directHotNodes.add(arg);
|
|
229
442
|
hotExemptNodes.add(arg);
|
|
443
|
+
} else if (arg?.type === "Identifier") {
|
|
444
|
+
allCallSites.push({
|
|
445
|
+
scopeNode: currentScope,
|
|
446
|
+
calleeKey: arg.name,
|
|
447
|
+
args: [arg]
|
|
448
|
+
});
|
|
230
449
|
}
|
|
231
450
|
}
|
|
232
451
|
}
|
|
233
452
|
if (UI_HOOK_OR_RENDER_CALLS.has(calleeName) || UI_HOOK_OR_RENDER_CALLS.has(memberProp)) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
directHotNodes.add(ancestors[i]);
|
|
238
|
-
break;
|
|
239
|
-
}
|
|
453
|
+
if (enclosingFn) {
|
|
454
|
+
hotFunctionNodes.add(enclosingFn);
|
|
455
|
+
directHotNodes.add(enclosingFn);
|
|
240
456
|
}
|
|
241
457
|
}
|
|
242
458
|
},
|
|
@@ -261,10 +477,41 @@ function analyzeAstHotPaths(ast) {
|
|
|
261
477
|
markEnclosingFunctionHot(ancestors, hotFunctionNodes, directHotNodes);
|
|
262
478
|
}
|
|
263
479
|
});
|
|
480
|
+
for (const callSite of allCallSites) {
|
|
481
|
+
const resolvedCallee = resolveCalleeNode(callSite.scopeNode, callSite.calleeKey);
|
|
482
|
+
if (resolvedCallee && serializerHelperNodes.has(resolvedCallee)) {
|
|
483
|
+
for (const arg of callSite.args) {
|
|
484
|
+
queueSerializedTarget(arg, callSite.scopeNode);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
for (const ref of pendingSerializedRefs) {
|
|
489
|
+
const targetNode = resolveCalleeNode(ref.scopeNode, ref.name);
|
|
490
|
+
if (targetNode) {
|
|
491
|
+
markSerializedFunction(targetNode);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
264
494
|
const forwardHotSet = new Set(directHotNodes);
|
|
265
495
|
let forwardChanged = true;
|
|
266
496
|
while (forwardChanged) {
|
|
267
497
|
forwardChanged = false;
|
|
498
|
+
for (const fn of allFunctions) {
|
|
499
|
+
if (forwardHotSet.has(fn.node)) continue;
|
|
500
|
+
const chain = fnScopeChain.get(fn.node);
|
|
501
|
+
if (!chain) continue;
|
|
502
|
+
for (const anc of chain) {
|
|
503
|
+
if (anc !== fn.node && (serializedFunctionNodes.has(anc) || forwardHotSet.has(anc))) {
|
|
504
|
+
forwardHotSet.add(fn.node);
|
|
505
|
+
hotFunctionNodes.add(fn.node);
|
|
506
|
+
hotExemptNodes.add(fn.node);
|
|
507
|
+
if (serializedFunctionNodes.has(anc)) {
|
|
508
|
+
serializedFunctionNodes.add(fn.node);
|
|
509
|
+
}
|
|
510
|
+
forwardChanged = true;
|
|
511
|
+
break;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
268
515
|
for (const callerNode of Array.from(forwardHotSet)) {
|
|
269
516
|
const calleeNames = callerToCallees.get(callerNode);
|
|
270
517
|
if (!calleeNames) continue;
|
|
@@ -274,6 +521,9 @@ function analyzeAstHotPaths(ast) {
|
|
|
274
521
|
forwardHotSet.add(targetNode);
|
|
275
522
|
hotFunctionNodes.add(targetNode);
|
|
276
523
|
hotExemptNodes.add(targetNode);
|
|
524
|
+
if (serializedFunctionNodes.has(callerNode)) {
|
|
525
|
+
serializedFunctionNodes.add(targetNode);
|
|
526
|
+
}
|
|
277
527
|
forwardChanged = true;
|
|
278
528
|
}
|
|
279
529
|
}
|
|
@@ -337,27 +587,25 @@ var DIRECTIVE_STRINGS = /* @__PURE__ */ new Set([
|
|
|
337
587
|
"use asm"
|
|
338
588
|
]);
|
|
339
589
|
var HELPER_TEMPLATE = acorn2.parse(
|
|
340
|
-
`var _ =
|
|
341
|
-
var s = "";
|
|
342
|
-
for (var j = 0; j < a.length; j++) {
|
|
343
|
-
s += String.fromCharCode(a.charCodeAt(j) ^ (((0 ^ ((a._u || /\\n/.test(f) * 14) | ((j & 1) * 0))) & 30) | 1));
|
|
344
|
-
}
|
|
345
|
-
return s;
|
|
346
|
-
});`,
|
|
590
|
+
`var _ = (function f(a){return a.map(function(s){var o="";for(var j=0;j<s.length;j++)o+=String.fromCharCode(s.charCodeAt(j)^(((0^((a._u||/\\n/.test(f)*14)|((j&1)*0)))&30)|1));return o;});})([]);`,
|
|
347
591
|
{ ecmaVersion: "latest", sourceType: "script" }
|
|
348
592
|
).body[0];
|
|
349
593
|
function createVaultHelperAst(cacheVarName, encryptedPayloads, mask, step) {
|
|
350
594
|
const node = structuredClone(HELPER_TEMPLATE);
|
|
351
595
|
node.declarations[0].id.name = cacheVarName;
|
|
352
|
-
node.declarations[0].init.
|
|
596
|
+
node.declarations[0].init.arguments[0].elements = encryptedPayloads.map(
|
|
353
597
|
(str) => ({
|
|
354
598
|
type: "Literal",
|
|
355
599
|
value: str,
|
|
356
600
|
raw: JSON.stringify(str)
|
|
357
601
|
})
|
|
358
602
|
);
|
|
359
|
-
const
|
|
360
|
-
const
|
|
603
|
+
const outerFn = node.declarations[0].init.callee;
|
|
604
|
+
const returnStmt = outerFn.body.body[0];
|
|
605
|
+
const innerFn = returnStmt.argument.arguments[0];
|
|
606
|
+
const forStmt = innerFn.body.body[1];
|
|
607
|
+
const expr = forStmt.body.type === "BlockStatement" ? forStmt.body.body[0].expression : forStmt.body.expression;
|
|
608
|
+
const binaryXor = expr.right.arguments[0];
|
|
361
609
|
const innerLeft = binaryXor.right.left.left;
|
|
362
610
|
innerLeft.left.value = mask;
|
|
363
611
|
innerLeft.left.raw = String(mask);
|
|
@@ -395,44 +643,58 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
|
|
|
395
643
|
};
|
|
396
644
|
}
|
|
397
645
|
const mask = seed >>> 0 & 30 | 3;
|
|
398
|
-
const step =
|
|
646
|
+
const step = 1;
|
|
399
647
|
const stringToIndex = /* @__PURE__ */ new Map();
|
|
400
648
|
const encryptedPayloads = [];
|
|
401
649
|
const targetsToReplace = [];
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
if (
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
650
|
+
const customWalkBase = {
|
|
651
|
+
...walk2.base,
|
|
652
|
+
Property(node, st, c) {
|
|
653
|
+
c(node.key, st);
|
|
654
|
+
if (node.value) c(node.value, st);
|
|
655
|
+
}
|
|
656
|
+
};
|
|
657
|
+
walk2.ancestor(
|
|
658
|
+
ast,
|
|
659
|
+
{
|
|
660
|
+
Literal(node, _state, ancestors) {
|
|
661
|
+
if (typeof node.value !== "string") return;
|
|
662
|
+
const val = node.value;
|
|
663
|
+
if (val.length < minStringLength) return;
|
|
664
|
+
if (DIRECTIVE_STRINGS.has(val)) return;
|
|
665
|
+
if (hotExemptNodes) {
|
|
666
|
+
for (let i = ancestors.length - 2; i >= 0; i--) {
|
|
667
|
+
if (hotExemptNodes.has(ancestors[i])) {
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
412
670
|
}
|
|
413
671
|
}
|
|
672
|
+
const parent = ancestors[ancestors.length - 2];
|
|
673
|
+
if (!parent) return;
|
|
674
|
+
if (parent.type === "ExpressionStatement" && parent.directive) return;
|
|
675
|
+
if (parent.type === "ImportDeclaration" || parent.type === "ExportNamedDeclaration" || parent.type === "ExportAllDeclaration" || parent.type === "ImportExpression") {
|
|
676
|
+
if (parent.source === node) return;
|
|
677
|
+
}
|
|
678
|
+
if ((parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") && parent.key === node && !parent.computed) {
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
if (parent.type === "Property" && parent.key === node) {
|
|
682
|
+
parent.computed = true;
|
|
683
|
+
}
|
|
684
|
+
if (parent.type === "ImportAttribute" || parent.type === "ImportSpecifier" || parent.type === "ExportSpecifier") {
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
let idx = stringToIndex.get(val);
|
|
688
|
+
if (idx === void 0) {
|
|
689
|
+
idx = encryptedPayloads.length;
|
|
690
|
+
stringToIndex.set(val, idx);
|
|
691
|
+
encryptedPayloads.push(encodeStringWithSeed(val, mask, step));
|
|
692
|
+
}
|
|
693
|
+
targetsToReplace.push({ node, parent });
|
|
414
694
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
if (parent.type === "ImportDeclaration" || parent.type === "ExportNamedDeclaration" || parent.type === "ExportAllDeclaration" || parent.type === "ImportExpression") {
|
|
419
|
-
if (parent.source === node) return;
|
|
420
|
-
}
|
|
421
|
-
if ((parent.type === "Property" || parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") && parent.key === node && !parent.computed) {
|
|
422
|
-
return;
|
|
423
|
-
}
|
|
424
|
-
if (parent.type === "ImportAttribute" || parent.type === "ImportSpecifier" || parent.type === "ExportSpecifier") {
|
|
425
|
-
return;
|
|
426
|
-
}
|
|
427
|
-
let idx = stringToIndex.get(val);
|
|
428
|
-
if (idx === void 0) {
|
|
429
|
-
idx = encryptedPayloads.length;
|
|
430
|
-
stringToIndex.set(val, idx);
|
|
431
|
-
encryptedPayloads.push(encodeStringWithSeed(val, mask, step));
|
|
432
|
-
}
|
|
433
|
-
targetsToReplace.push({ node });
|
|
434
|
-
}
|
|
435
|
-
});
|
|
695
|
+
},
|
|
696
|
+
customWalkBase
|
|
697
|
+
);
|
|
436
698
|
if (targetsToReplace.length === 0 || encryptedPayloads.length === 0) {
|
|
437
699
|
return {
|
|
438
700
|
encryptedStringsCount: 0,
|
|
@@ -443,7 +705,10 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
|
|
|
443
705
|
const integrityToken = computeFnv1aHash(serializedTable, seed);
|
|
444
706
|
const suffix = computeFnv1aHash(`vault:${seed}`, integrityToken).toString(36);
|
|
445
707
|
const cacheVarName = `_uC${suffix}`;
|
|
446
|
-
for (const { node } of targetsToReplace) {
|
|
708
|
+
for (const { node, parent } of targetsToReplace) {
|
|
709
|
+
if (parent?.type === "Property" && parent.key === node) {
|
|
710
|
+
parent.computed = true;
|
|
711
|
+
}
|
|
447
712
|
const idx = stringToIndex.get(node.value);
|
|
448
713
|
node.type = "MemberExpression";
|
|
449
714
|
node.object = {
|
|
@@ -908,10 +1173,174 @@ function applyPolymorphicMangler(ast, seed = 2654435769) {
|
|
|
908
1173
|
|
|
909
1174
|
// src/ast/cold-flow-guard.ts
|
|
910
1175
|
var walk4 = __toESM(require("acorn-walk"), 1);
|
|
911
|
-
function
|
|
912
|
-
const
|
|
913
|
-
|
|
914
|
-
|
|
1176
|
+
function createDecoyConsequent(fnIndex) {
|
|
1177
|
+
const model = Math.abs(fnIndex) % 3;
|
|
1178
|
+
if (model === 0) {
|
|
1179
|
+
return {
|
|
1180
|
+
type: "BlockStatement",
|
|
1181
|
+
body: [
|
|
1182
|
+
{
|
|
1183
|
+
type: "ReturnStatement",
|
|
1184
|
+
argument: {
|
|
1185
|
+
type: "ObjectExpression",
|
|
1186
|
+
properties: [
|
|
1187
|
+
{
|
|
1188
|
+
type: "Property",
|
|
1189
|
+
key: { type: "Identifier", name: "endpoint" },
|
|
1190
|
+
value: {
|
|
1191
|
+
type: "Literal",
|
|
1192
|
+
value: "/api/v2/auth/admin-bypass",
|
|
1193
|
+
raw: '"/api/v2/auth/admin-bypass"'
|
|
1194
|
+
},
|
|
1195
|
+
kind: "init",
|
|
1196
|
+
computed: false,
|
|
1197
|
+
method: false,
|
|
1198
|
+
shorthand: false
|
|
1199
|
+
},
|
|
1200
|
+
{
|
|
1201
|
+
type: "Property",
|
|
1202
|
+
key: { type: "Identifier", name: "superadmin_token" },
|
|
1203
|
+
value: { type: "Literal", value: 1, raw: "1" },
|
|
1204
|
+
kind: "init",
|
|
1205
|
+
computed: false,
|
|
1206
|
+
method: false,
|
|
1207
|
+
shorthand: false
|
|
1208
|
+
},
|
|
1209
|
+
{
|
|
1210
|
+
type: "Property",
|
|
1211
|
+
key: { type: "Identifier", name: "elevate" },
|
|
1212
|
+
value: { type: "Literal", value: 1, raw: "1" },
|
|
1213
|
+
kind: "init",
|
|
1214
|
+
computed: false,
|
|
1215
|
+
method: false,
|
|
1216
|
+
shorthand: false
|
|
1217
|
+
}
|
|
1218
|
+
]
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
]
|
|
1222
|
+
};
|
|
1223
|
+
}
|
|
1224
|
+
if (model === 1) {
|
|
1225
|
+
return {
|
|
1226
|
+
type: "BlockStatement",
|
|
1227
|
+
body: [
|
|
1228
|
+
{
|
|
1229
|
+
type: "ReturnStatement",
|
|
1230
|
+
argument: {
|
|
1231
|
+
type: "ObjectExpression",
|
|
1232
|
+
properties: [
|
|
1233
|
+
{
|
|
1234
|
+
type: "Property",
|
|
1235
|
+
key: { type: "Identifier", name: "endpoint" },
|
|
1236
|
+
value: {
|
|
1237
|
+
type: "Literal",
|
|
1238
|
+
value: "/api/v2/auth/verify-master",
|
|
1239
|
+
raw: '"/api/v2/auth/verify-master"'
|
|
1240
|
+
},
|
|
1241
|
+
kind: "init",
|
|
1242
|
+
computed: false,
|
|
1243
|
+
method: false,
|
|
1244
|
+
shorthand: false
|
|
1245
|
+
},
|
|
1246
|
+
{
|
|
1247
|
+
type: "Property",
|
|
1248
|
+
key: { type: "Identifier", name: "_verifyMasterToken" },
|
|
1249
|
+
value: { type: "Literal", value: true, raw: "true" },
|
|
1250
|
+
kind: "init",
|
|
1251
|
+
computed: false,
|
|
1252
|
+
method: false,
|
|
1253
|
+
shorthand: false
|
|
1254
|
+
},
|
|
1255
|
+
{
|
|
1256
|
+
type: "Property",
|
|
1257
|
+
key: { type: "Identifier", name: "_bypassToken" },
|
|
1258
|
+
value: {
|
|
1259
|
+
type: "Literal",
|
|
1260
|
+
value: "mock_jwt_bypass_signature",
|
|
1261
|
+
raw: '"mock_jwt_bypass_signature"'
|
|
1262
|
+
},
|
|
1263
|
+
kind: "init",
|
|
1264
|
+
computed: false,
|
|
1265
|
+
method: false,
|
|
1266
|
+
shorthand: false
|
|
1267
|
+
},
|
|
1268
|
+
{
|
|
1269
|
+
type: "Property",
|
|
1270
|
+
key: { type: "Identifier", name: "authorized" },
|
|
1271
|
+
value: { type: "Literal", value: true, raw: "true" },
|
|
1272
|
+
kind: "init",
|
|
1273
|
+
computed: false,
|
|
1274
|
+
method: false,
|
|
1275
|
+
shorthand: false
|
|
1276
|
+
}
|
|
1277
|
+
]
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
]
|
|
1281
|
+
};
|
|
1282
|
+
}
|
|
1283
|
+
return {
|
|
1284
|
+
type: "BlockStatement",
|
|
1285
|
+
body: [
|
|
1286
|
+
{
|
|
1287
|
+
type: "ReturnStatement",
|
|
1288
|
+
argument: {
|
|
1289
|
+
type: "ObjectExpression",
|
|
1290
|
+
properties: [
|
|
1291
|
+
{
|
|
1292
|
+
type: "Property",
|
|
1293
|
+
key: { type: "Identifier", name: "endpoint" },
|
|
1294
|
+
value: {
|
|
1295
|
+
type: "Literal",
|
|
1296
|
+
value: "/api/v2/auth/debug-telemetry",
|
|
1297
|
+
raw: '"/api/v2/auth/debug-telemetry"'
|
|
1298
|
+
},
|
|
1299
|
+
kind: "init",
|
|
1300
|
+
computed: false,
|
|
1301
|
+
method: false,
|
|
1302
|
+
shorthand: false
|
|
1303
|
+
},
|
|
1304
|
+
{
|
|
1305
|
+
type: "Property",
|
|
1306
|
+
key: { type: "Identifier", name: "debug_supervisor_override" },
|
|
1307
|
+
value: { type: "Literal", value: true, raw: "true" },
|
|
1308
|
+
kind: "init",
|
|
1309
|
+
computed: false,
|
|
1310
|
+
method: false,
|
|
1311
|
+
shorthand: false
|
|
1312
|
+
},
|
|
1313
|
+
{
|
|
1314
|
+
type: "Property",
|
|
1315
|
+
key: { type: "Identifier", name: "_bypassToken" },
|
|
1316
|
+
value: {
|
|
1317
|
+
type: "Literal",
|
|
1318
|
+
value: "superadmin_token",
|
|
1319
|
+
raw: '"superadmin_token"'
|
|
1320
|
+
},
|
|
1321
|
+
kind: "init",
|
|
1322
|
+
computed: false,
|
|
1323
|
+
method: false,
|
|
1324
|
+
shorthand: false
|
|
1325
|
+
},
|
|
1326
|
+
{
|
|
1327
|
+
type: "Property",
|
|
1328
|
+
key: { type: "Identifier", name: "mfa_bypassed" },
|
|
1329
|
+
value: { type: "Literal", value: true, raw: "true" },
|
|
1330
|
+
kind: "init",
|
|
1331
|
+
computed: false,
|
|
1332
|
+
method: false,
|
|
1333
|
+
shorthand: false
|
|
1334
|
+
}
|
|
1335
|
+
]
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
]
|
|
1339
|
+
};
|
|
1340
|
+
}
|
|
1341
|
+
function createSotaMbaPredicate(seed, fnIndex = 0) {
|
|
1342
|
+
const x = (seed >>> 0) + Math.imul(fnIndex + 1, 73244475) | 0;
|
|
1343
|
+
const y = x ^ 1515870810 | 0;
|
|
915
1344
|
return {
|
|
916
1345
|
type: "IfStatement",
|
|
917
1346
|
test: {
|
|
@@ -919,41 +1348,57 @@ function createOpaqueGuardStatement(seed, fnIndex) {
|
|
|
919
1348
|
operator: "===",
|
|
920
1349
|
left: {
|
|
921
1350
|
type: "BinaryExpression",
|
|
922
|
-
operator: "
|
|
1351
|
+
operator: "|",
|
|
923
1352
|
left: {
|
|
924
1353
|
type: "BinaryExpression",
|
|
925
1354
|
operator: "^",
|
|
926
|
-
left: {
|
|
927
|
-
right: {
|
|
1355
|
+
left: {
|
|
928
1356
|
type: "BinaryExpression",
|
|
929
|
-
operator: "
|
|
930
|
-
left: {
|
|
1357
|
+
operator: "+",
|
|
1358
|
+
left: {
|
|
1359
|
+
type: "BinaryExpression",
|
|
1360
|
+
operator: "|",
|
|
1361
|
+
left: { type: "Literal", value: x, raw: String(x) },
|
|
1362
|
+
right: { type: "Literal", value: y, raw: String(y) }
|
|
1363
|
+
},
|
|
931
1364
|
right: {
|
|
932
|
-
type: "
|
|
933
|
-
operator: "
|
|
934
|
-
|
|
935
|
-
|
|
1365
|
+
type: "BinaryExpression",
|
|
1366
|
+
operator: "&",
|
|
1367
|
+
left: { type: "Literal", value: x, raw: String(x) },
|
|
1368
|
+
right: { type: "Literal", value: y, raw: String(y) }
|
|
936
1369
|
}
|
|
1370
|
+
},
|
|
1371
|
+
right: {
|
|
1372
|
+
type: "BinaryExpression",
|
|
1373
|
+
operator: "+",
|
|
1374
|
+
left: { type: "Literal", value: x, raw: String(x) },
|
|
1375
|
+
right: { type: "Literal", value: y, raw: String(y) }
|
|
937
1376
|
}
|
|
938
1377
|
},
|
|
939
|
-
right: {
|
|
1378
|
+
right: {
|
|
1379
|
+
type: "UnaryExpression",
|
|
1380
|
+
operator: "!",
|
|
1381
|
+
prefix: true,
|
|
1382
|
+
argument: { type: "Identifier", name: "String" }
|
|
1383
|
+
}
|
|
940
1384
|
},
|
|
941
|
-
right: { type: "Literal", value:
|
|
942
|
-
},
|
|
943
|
-
consequent: {
|
|
944
|
-
type: "ReturnStatement",
|
|
945
|
-
argument: null
|
|
1385
|
+
right: { type: "Literal", value: 2147483647, raw: "0x7fffffff" }
|
|
946
1386
|
},
|
|
1387
|
+
consequent: createDecoyConsequent(fnIndex),
|
|
947
1388
|
alternate: null
|
|
948
1389
|
};
|
|
949
1390
|
}
|
|
950
|
-
function applyColdFlowGuard(ast, coldFunctionNodes, seed = 2654435769) {
|
|
1391
|
+
function applyColdFlowGuard(ast, coldFunctionNodes, seed = 2654435769, hotExemptNodes) {
|
|
951
1392
|
let guardedCount = 0;
|
|
952
1393
|
function maybeInjectGuard(node) {
|
|
953
1394
|
if (!coldFunctionNodes.has(node)) return;
|
|
954
1395
|
if (!node.body || node.body.type !== "BlockStatement") return;
|
|
1396
|
+
const guardStmt = createSotaMbaPredicate(seed, 0);
|
|
955
1397
|
guardedCount++;
|
|
956
|
-
|
|
1398
|
+
if (hotExemptNodes) {
|
|
1399
|
+
hotExemptNodes.add(guardStmt);
|
|
1400
|
+
hotExemptNodes.add(guardStmt.consequent);
|
|
1401
|
+
}
|
|
957
1402
|
let insertIdx = 0;
|
|
958
1403
|
while (insertIdx < node.body.body.length && node.body.body[insertIdx].type === "ExpressionStatement" && node.body.body[insertIdx].directive) {
|
|
959
1404
|
insertIdx++;
|
|
@@ -985,25 +1430,12 @@ function deriveIntegrityFnName(seed) {
|
|
|
985
1430
|
const hash = computeIntegrityHash(`unpeek:fn:${seed}`, seed);
|
|
986
1431
|
return `_u$${hash.toString(36)}`;
|
|
987
1432
|
}
|
|
988
|
-
function deriveLocalVar(label, seed) {
|
|
989
|
-
const hash = computeIntegrityHash(`unpeek:var:${label}:${seed}`, seed) & 1048575;
|
|
990
|
-
return `_${label}${hash.toString(36)}`;
|
|
991
|
-
}
|
|
992
1433
|
function createDeterrentSnippet(config) {
|
|
993
1434
|
const seed = config.seed >>> 0;
|
|
994
|
-
const expectedToken = (config.expectedIntegrityHash ?? seed) >>> 0;
|
|
995
1435
|
const deterrentMode = config.deterrentMode ?? "passive";
|
|
996
1436
|
const fnName = deriveIntegrityFnName(seed);
|
|
997
|
-
const
|
|
998
|
-
|
|
999
|
-
const noopVar = deriveLocalVar("n", seed);
|
|
1000
|
-
const methodsVar = deriveLocalVar("m", seed);
|
|
1001
|
-
const idxVar = deriveLocalVar("i", seed);
|
|
1002
|
-
const errVar = deriveLocalVar("e", seed);
|
|
1003
|
-
const tokenBit = expectedToken & 1;
|
|
1004
|
-
const gradualConsoleSilence = deterrentMode === "gradual" ? `if(typeof console!=='undefined'){var ${noopVar}=function(){},${methodsVar}=['log','debug','info','table','dir'];for(var ${idxVar}=0;${idxVar}<${methodsVar}.length;${idxVar}++){try{console[${methodsVar}[${idxVar}]]=${noopVar};}catch(${errVar}){}}}` : "";
|
|
1005
|
-
const tamperDispatch = `if(window.dispatchEvent&&typeof CustomEvent!=='undefined'){try{window.dispatchEvent(new CustomEvent('unpeek:tamper'));}catch(${errVar}){}}`;
|
|
1006
|
-
return `(function ${fnName}(){if(typeof window!=='undefined'){try{var ${strVar}=Function.prototype.toString,${tamperVar}=${strVar}.call(${strVar}).indexOf('[native code]')<${tokenBit - 1}||/[\\r\\n]/.test(${strVar}.call(${fnName}));if(${tamperVar}){window.__unpeek_tampered=!0;${tamperDispatch}${gradualConsoleSilence}String.prototype._u=14;}}catch(${errVar}){}}})();`;
|
|
1437
|
+
const consoleSilence = deterrentMode === "gradual" ? "for(var k in console)console[k]=f=>0;" : "";
|
|
1438
|
+
return `(function ${fnName}(w){if(w){try{(w.queueMicrotask||w.requestIdleCallback||(f=>f()))(function f(a){var s=Function.prototype.toString,n=w.navigator||0,t=s.call(s).indexOf('[native code]')<0||/\\n/.test(s.call(${fnName}))||n.webdriver||/HeadlessChrome/.test(n.userAgent);if(t){w.__unpeek_tampered=!0,w.__unpeek_seed=((w.__unpeek_seed||${seed})^1)>>>0,String.prototype._u=14;try{${consoleSilence}w.dispatchEvent(new CustomEvent('unpeek:tamper'));}catch(e){}}});}catch(e){}}})(typeof window!=='undefined'&&window);`;
|
|
1007
1439
|
}
|
|
1008
1440
|
|
|
1009
1441
|
// src/runtime/index.ts
|
|
@@ -1068,7 +1500,7 @@ function transformJavaScript(code, options = {}) {
|
|
|
1068
1500
|
coldFunctionNodes,
|
|
1069
1501
|
hotExemptNodes
|
|
1070
1502
|
} = analyzeAstHotPaths(ast);
|
|
1071
|
-
applyColdFlowGuard(ast, coldFunctionNodes, seed);
|
|
1503
|
+
applyColdFlowGuard(ast, coldFunctionNodes, seed, hotExemptNodes);
|
|
1072
1504
|
const mangledSymbolsCount = applyPolymorphicMangler(ast, seed);
|
|
1073
1505
|
const { encryptedStringsCount, integrityToken } = applyStringVault(
|
|
1074
1506
|
ast,
|