unpeek 1.6.2 → 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 +262 -85
- package/dist/ast/index.cjs.map +1 -1
- package/dist/ast/index.js +262 -85
- package/dist/ast/index.js.map +1 -1
- package/dist/browser.cjs +262 -85
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.js +262 -85
- package/dist/browser.js.map +1 -1
- package/dist/bundler/unplugin.cjs +262 -85
- package/dist/bundler/unplugin.cjs.map +1 -1
- package/dist/bundler/unplugin.js +262 -85
- package/dist/bundler/unplugin.js.map +1 -1
- package/dist/cli/index.cjs +263 -86
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +263 -86
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/protect.cjs +262 -85
- package/dist/cli/protect.cjs.map +1 -1
- package/dist/cli/protect.js +262 -85
- package/dist/cli/protect.js.map +1 -1
- package/dist/esbuild.cjs +262 -85
- package/dist/esbuild.cjs.map +1 -1
- package/dist/esbuild.js +262 -85
- package/dist/esbuild.js.map +1 -1
- package/dist/index.cjs +263 -86
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +263 -86
- package/dist/index.js.map +1 -1
- package/dist/rollup.cjs +262 -85
- package/dist/rollup.cjs.map +1 -1
- package/dist/rollup.js +262 -85
- 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 +262 -85
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.js +262 -85
- package/dist/vite.js.map +1 -1
- package/dist/webpack.cjs +262 -85
- package/dist/webpack.cjs.map +1 -1
- package/dist/webpack.js +262 -85
- package/dist/webpack.js.map +1 -1
- package/package.json +1 -1
package/dist/ast/index.cjs
CHANGED
|
@@ -594,27 +594,25 @@ var DIRECTIVE_STRINGS = /* @__PURE__ */ new Set([
|
|
|
594
594
|
"use asm"
|
|
595
595
|
]);
|
|
596
596
|
var HELPER_TEMPLATE = acorn2.parse(
|
|
597
|
-
`var _ =
|
|
598
|
-
var s = "";
|
|
599
|
-
for (var j = 0; j < a.length; j++) {
|
|
600
|
-
s += String.fromCharCode(a.charCodeAt(j) ^ (((0 ^ ((a._u || /\\n/.test(f) * 14) | ((j & 1) * 0))) & 30) | 1));
|
|
601
|
-
}
|
|
602
|
-
return s;
|
|
603
|
-
});`,
|
|
597
|
+
`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;});})([]);`,
|
|
604
598
|
{ ecmaVersion: "latest", sourceType: "script" }
|
|
605
599
|
).body[0];
|
|
606
600
|
function createVaultHelperAst(cacheVarName, encryptedPayloads, mask, step) {
|
|
607
601
|
const node = structuredClone(HELPER_TEMPLATE);
|
|
608
602
|
node.declarations[0].id.name = cacheVarName;
|
|
609
|
-
node.declarations[0].init.
|
|
603
|
+
node.declarations[0].init.arguments[0].elements = encryptedPayloads.map(
|
|
610
604
|
(str) => ({
|
|
611
605
|
type: "Literal",
|
|
612
606
|
value: str,
|
|
613
607
|
raw: JSON.stringify(str)
|
|
614
608
|
})
|
|
615
609
|
);
|
|
616
|
-
const
|
|
617
|
-
const
|
|
610
|
+
const outerFn = node.declarations[0].init.callee;
|
|
611
|
+
const returnStmt = outerFn.body.body[0];
|
|
612
|
+
const innerFn = returnStmt.argument.arguments[0];
|
|
613
|
+
const forStmt = innerFn.body.body[1];
|
|
614
|
+
const expr = forStmt.body.type === "BlockStatement" ? forStmt.body.body[0].expression : forStmt.body.expression;
|
|
615
|
+
const binaryXor = expr.right.arguments[0];
|
|
618
616
|
const innerLeft = binaryXor.right.left.left;
|
|
619
617
|
innerLeft.left.value = mask;
|
|
620
618
|
innerLeft.left.raw = String(mask);
|
|
@@ -652,44 +650,58 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
|
|
|
652
650
|
};
|
|
653
651
|
}
|
|
654
652
|
const mask = seed >>> 0 & 30 | 3;
|
|
655
|
-
const step =
|
|
653
|
+
const step = 1;
|
|
656
654
|
const stringToIndex = /* @__PURE__ */ new Map();
|
|
657
655
|
const encryptedPayloads = [];
|
|
658
656
|
const targetsToReplace = [];
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
if (
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
657
|
+
const customWalkBase = {
|
|
658
|
+
...walk2.base,
|
|
659
|
+
Property(node, st, c) {
|
|
660
|
+
c(node.key, st);
|
|
661
|
+
if (node.value) c(node.value, st);
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
walk2.ancestor(
|
|
665
|
+
ast,
|
|
666
|
+
{
|
|
667
|
+
Literal(node, _state, ancestors) {
|
|
668
|
+
if (typeof node.value !== "string") return;
|
|
669
|
+
const val = node.value;
|
|
670
|
+
if (val.length < minStringLength) return;
|
|
671
|
+
if (DIRECTIVE_STRINGS.has(val)) return;
|
|
672
|
+
if (hotExemptNodes) {
|
|
673
|
+
for (let i = ancestors.length - 2; i >= 0; i--) {
|
|
674
|
+
if (hotExemptNodes.has(ancestors[i])) {
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
669
677
|
}
|
|
670
678
|
}
|
|
679
|
+
const parent = ancestors[ancestors.length - 2];
|
|
680
|
+
if (!parent) return;
|
|
681
|
+
if (parent.type === "ExpressionStatement" && parent.directive) return;
|
|
682
|
+
if (parent.type === "ImportDeclaration" || parent.type === "ExportNamedDeclaration" || parent.type === "ExportAllDeclaration" || parent.type === "ImportExpression") {
|
|
683
|
+
if (parent.source === node) return;
|
|
684
|
+
}
|
|
685
|
+
if ((parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") && parent.key === node && !parent.computed) {
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
if (parent.type === "Property" && parent.key === node) {
|
|
689
|
+
parent.computed = true;
|
|
690
|
+
}
|
|
691
|
+
if (parent.type === "ImportAttribute" || parent.type === "ImportSpecifier" || parent.type === "ExportSpecifier") {
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
let idx = stringToIndex.get(val);
|
|
695
|
+
if (idx === void 0) {
|
|
696
|
+
idx = encryptedPayloads.length;
|
|
697
|
+
stringToIndex.set(val, idx);
|
|
698
|
+
encryptedPayloads.push(encodeStringWithSeed(val, mask, step));
|
|
699
|
+
}
|
|
700
|
+
targetsToReplace.push({ node, parent });
|
|
671
701
|
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
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 === "Property" || parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") && parent.key === node && !parent.computed) {
|
|
679
|
-
return;
|
|
680
|
-
}
|
|
681
|
-
if (parent.type === "ImportAttribute" || parent.type === "ImportSpecifier" || parent.type === "ExportSpecifier") {
|
|
682
|
-
return;
|
|
683
|
-
}
|
|
684
|
-
let idx = stringToIndex.get(val);
|
|
685
|
-
if (idx === void 0) {
|
|
686
|
-
idx = encryptedPayloads.length;
|
|
687
|
-
stringToIndex.set(val, idx);
|
|
688
|
-
encryptedPayloads.push(encodeStringWithSeed(val, mask, step));
|
|
689
|
-
}
|
|
690
|
-
targetsToReplace.push({ node });
|
|
691
|
-
}
|
|
692
|
-
});
|
|
702
|
+
},
|
|
703
|
+
customWalkBase
|
|
704
|
+
);
|
|
693
705
|
if (targetsToReplace.length === 0 || encryptedPayloads.length === 0) {
|
|
694
706
|
return {
|
|
695
707
|
encryptedStringsCount: 0,
|
|
@@ -700,7 +712,10 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
|
|
|
700
712
|
const integrityToken = computeFnv1aHash(serializedTable, seed);
|
|
701
713
|
const suffix = computeFnv1aHash(`vault:${seed}`, integrityToken).toString(36);
|
|
702
714
|
const cacheVarName = `_uC${suffix}`;
|
|
703
|
-
for (const { node } of targetsToReplace) {
|
|
715
|
+
for (const { node, parent } of targetsToReplace) {
|
|
716
|
+
if (parent?.type === "Property" && parent.key === node) {
|
|
717
|
+
parent.computed = true;
|
|
718
|
+
}
|
|
704
719
|
const idx = stringToIndex.get(node.value);
|
|
705
720
|
node.type = "MemberExpression";
|
|
706
721
|
node.object = {
|
|
@@ -1165,10 +1180,174 @@ function applyPolymorphicMangler(ast, seed = 2654435769) {
|
|
|
1165
1180
|
|
|
1166
1181
|
// src/ast/cold-flow-guard.ts
|
|
1167
1182
|
var walk4 = __toESM(require("acorn-walk"), 1);
|
|
1168
|
-
function
|
|
1169
|
-
const
|
|
1170
|
-
|
|
1171
|
-
|
|
1183
|
+
function createDecoyConsequent(fnIndex) {
|
|
1184
|
+
const model = Math.abs(fnIndex) % 3;
|
|
1185
|
+
if (model === 0) {
|
|
1186
|
+
return {
|
|
1187
|
+
type: "BlockStatement",
|
|
1188
|
+
body: [
|
|
1189
|
+
{
|
|
1190
|
+
type: "ReturnStatement",
|
|
1191
|
+
argument: {
|
|
1192
|
+
type: "ObjectExpression",
|
|
1193
|
+
properties: [
|
|
1194
|
+
{
|
|
1195
|
+
type: "Property",
|
|
1196
|
+
key: { type: "Identifier", name: "endpoint" },
|
|
1197
|
+
value: {
|
|
1198
|
+
type: "Literal",
|
|
1199
|
+
value: "/api/v2/auth/admin-bypass",
|
|
1200
|
+
raw: '"/api/v2/auth/admin-bypass"'
|
|
1201
|
+
},
|
|
1202
|
+
kind: "init",
|
|
1203
|
+
computed: false,
|
|
1204
|
+
method: false,
|
|
1205
|
+
shorthand: false
|
|
1206
|
+
},
|
|
1207
|
+
{
|
|
1208
|
+
type: "Property",
|
|
1209
|
+
key: { type: "Identifier", name: "superadmin_token" },
|
|
1210
|
+
value: { type: "Literal", value: 1, raw: "1" },
|
|
1211
|
+
kind: "init",
|
|
1212
|
+
computed: false,
|
|
1213
|
+
method: false,
|
|
1214
|
+
shorthand: false
|
|
1215
|
+
},
|
|
1216
|
+
{
|
|
1217
|
+
type: "Property",
|
|
1218
|
+
key: { type: "Identifier", name: "elevate" },
|
|
1219
|
+
value: { type: "Literal", value: 1, raw: "1" },
|
|
1220
|
+
kind: "init",
|
|
1221
|
+
computed: false,
|
|
1222
|
+
method: false,
|
|
1223
|
+
shorthand: false
|
|
1224
|
+
}
|
|
1225
|
+
]
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
]
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1231
|
+
if (model === 1) {
|
|
1232
|
+
return {
|
|
1233
|
+
type: "BlockStatement",
|
|
1234
|
+
body: [
|
|
1235
|
+
{
|
|
1236
|
+
type: "ReturnStatement",
|
|
1237
|
+
argument: {
|
|
1238
|
+
type: "ObjectExpression",
|
|
1239
|
+
properties: [
|
|
1240
|
+
{
|
|
1241
|
+
type: "Property",
|
|
1242
|
+
key: { type: "Identifier", name: "endpoint" },
|
|
1243
|
+
value: {
|
|
1244
|
+
type: "Literal",
|
|
1245
|
+
value: "/api/v2/auth/verify-master",
|
|
1246
|
+
raw: '"/api/v2/auth/verify-master"'
|
|
1247
|
+
},
|
|
1248
|
+
kind: "init",
|
|
1249
|
+
computed: false,
|
|
1250
|
+
method: false,
|
|
1251
|
+
shorthand: false
|
|
1252
|
+
},
|
|
1253
|
+
{
|
|
1254
|
+
type: "Property",
|
|
1255
|
+
key: { type: "Identifier", name: "_verifyMasterToken" },
|
|
1256
|
+
value: { type: "Literal", value: true, raw: "true" },
|
|
1257
|
+
kind: "init",
|
|
1258
|
+
computed: false,
|
|
1259
|
+
method: false,
|
|
1260
|
+
shorthand: false
|
|
1261
|
+
},
|
|
1262
|
+
{
|
|
1263
|
+
type: "Property",
|
|
1264
|
+
key: { type: "Identifier", name: "_bypassToken" },
|
|
1265
|
+
value: {
|
|
1266
|
+
type: "Literal",
|
|
1267
|
+
value: "mock_jwt_bypass_signature",
|
|
1268
|
+
raw: '"mock_jwt_bypass_signature"'
|
|
1269
|
+
},
|
|
1270
|
+
kind: "init",
|
|
1271
|
+
computed: false,
|
|
1272
|
+
method: false,
|
|
1273
|
+
shorthand: false
|
|
1274
|
+
},
|
|
1275
|
+
{
|
|
1276
|
+
type: "Property",
|
|
1277
|
+
key: { type: "Identifier", name: "authorized" },
|
|
1278
|
+
value: { type: "Literal", value: true, raw: "true" },
|
|
1279
|
+
kind: "init",
|
|
1280
|
+
computed: false,
|
|
1281
|
+
method: false,
|
|
1282
|
+
shorthand: false
|
|
1283
|
+
}
|
|
1284
|
+
]
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
]
|
|
1288
|
+
};
|
|
1289
|
+
}
|
|
1290
|
+
return {
|
|
1291
|
+
type: "BlockStatement",
|
|
1292
|
+
body: [
|
|
1293
|
+
{
|
|
1294
|
+
type: "ReturnStatement",
|
|
1295
|
+
argument: {
|
|
1296
|
+
type: "ObjectExpression",
|
|
1297
|
+
properties: [
|
|
1298
|
+
{
|
|
1299
|
+
type: "Property",
|
|
1300
|
+
key: { type: "Identifier", name: "endpoint" },
|
|
1301
|
+
value: {
|
|
1302
|
+
type: "Literal",
|
|
1303
|
+
value: "/api/v2/auth/debug-telemetry",
|
|
1304
|
+
raw: '"/api/v2/auth/debug-telemetry"'
|
|
1305
|
+
},
|
|
1306
|
+
kind: "init",
|
|
1307
|
+
computed: false,
|
|
1308
|
+
method: false,
|
|
1309
|
+
shorthand: false
|
|
1310
|
+
},
|
|
1311
|
+
{
|
|
1312
|
+
type: "Property",
|
|
1313
|
+
key: { type: "Identifier", name: "debug_supervisor_override" },
|
|
1314
|
+
value: { type: "Literal", value: true, raw: "true" },
|
|
1315
|
+
kind: "init",
|
|
1316
|
+
computed: false,
|
|
1317
|
+
method: false,
|
|
1318
|
+
shorthand: false
|
|
1319
|
+
},
|
|
1320
|
+
{
|
|
1321
|
+
type: "Property",
|
|
1322
|
+
key: { type: "Identifier", name: "_bypassToken" },
|
|
1323
|
+
value: {
|
|
1324
|
+
type: "Literal",
|
|
1325
|
+
value: "superadmin_token",
|
|
1326
|
+
raw: '"superadmin_token"'
|
|
1327
|
+
},
|
|
1328
|
+
kind: "init",
|
|
1329
|
+
computed: false,
|
|
1330
|
+
method: false,
|
|
1331
|
+
shorthand: false
|
|
1332
|
+
},
|
|
1333
|
+
{
|
|
1334
|
+
type: "Property",
|
|
1335
|
+
key: { type: "Identifier", name: "mfa_bypassed" },
|
|
1336
|
+
value: { type: "Literal", value: true, raw: "true" },
|
|
1337
|
+
kind: "init",
|
|
1338
|
+
computed: false,
|
|
1339
|
+
method: false,
|
|
1340
|
+
shorthand: false
|
|
1341
|
+
}
|
|
1342
|
+
]
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
]
|
|
1346
|
+
};
|
|
1347
|
+
}
|
|
1348
|
+
function createSotaMbaPredicate(seed, fnIndex = 0) {
|
|
1349
|
+
const x = (seed >>> 0) + Math.imul(fnIndex + 1, 73244475) | 0;
|
|
1350
|
+
const y = x ^ 1515870810 | 0;
|
|
1172
1351
|
return {
|
|
1173
1352
|
type: "IfStatement",
|
|
1174
1353
|
test: {
|
|
@@ -1176,46 +1355,57 @@ function createOpaqueGuardStatement(seed, fnIndex) {
|
|
|
1176
1355
|
operator: "===",
|
|
1177
1356
|
left: {
|
|
1178
1357
|
type: "BinaryExpression",
|
|
1179
|
-
operator: "
|
|
1358
|
+
operator: "|",
|
|
1180
1359
|
left: {
|
|
1181
1360
|
type: "BinaryExpression",
|
|
1182
1361
|
operator: "^",
|
|
1183
|
-
left: {
|
|
1184
|
-
right: {
|
|
1362
|
+
left: {
|
|
1185
1363
|
type: "BinaryExpression",
|
|
1186
|
-
operator: "
|
|
1187
|
-
left: {
|
|
1364
|
+
operator: "+",
|
|
1365
|
+
left: {
|
|
1366
|
+
type: "BinaryExpression",
|
|
1367
|
+
operator: "|",
|
|
1368
|
+
left: { type: "Literal", value: x, raw: String(x) },
|
|
1369
|
+
right: { type: "Literal", value: y, raw: String(y) }
|
|
1370
|
+
},
|
|
1188
1371
|
right: {
|
|
1189
|
-
type: "
|
|
1190
|
-
operator: "
|
|
1191
|
-
|
|
1192
|
-
|
|
1372
|
+
type: "BinaryExpression",
|
|
1373
|
+
operator: "&",
|
|
1374
|
+
left: { type: "Literal", value: x, raw: String(x) },
|
|
1375
|
+
right: { type: "Literal", value: y, raw: String(y) }
|
|
1193
1376
|
}
|
|
1377
|
+
},
|
|
1378
|
+
right: {
|
|
1379
|
+
type: "BinaryExpression",
|
|
1380
|
+
operator: "+",
|
|
1381
|
+
left: { type: "Literal", value: x, raw: String(x) },
|
|
1382
|
+
right: { type: "Literal", value: y, raw: String(y) }
|
|
1194
1383
|
}
|
|
1195
1384
|
},
|
|
1196
|
-
right: {
|
|
1385
|
+
right: {
|
|
1386
|
+
type: "UnaryExpression",
|
|
1387
|
+
operator: "!",
|
|
1388
|
+
prefix: true,
|
|
1389
|
+
argument: { type: "Identifier", name: "String" }
|
|
1390
|
+
}
|
|
1197
1391
|
},
|
|
1198
|
-
right: { type: "Literal", value:
|
|
1199
|
-
},
|
|
1200
|
-
consequent: {
|
|
1201
|
-
type: "ExpressionStatement",
|
|
1202
|
-
expression: {
|
|
1203
|
-
type: "UnaryExpression",
|
|
1204
|
-
operator: "void",
|
|
1205
|
-
prefix: true,
|
|
1206
|
-
argument: { type: "Literal", value: 0, raw: "0" }
|
|
1207
|
-
}
|
|
1392
|
+
right: { type: "Literal", value: 2147483647, raw: "0x7fffffff" }
|
|
1208
1393
|
},
|
|
1394
|
+
consequent: createDecoyConsequent(fnIndex),
|
|
1209
1395
|
alternate: null
|
|
1210
1396
|
};
|
|
1211
1397
|
}
|
|
1212
|
-
function applyColdFlowGuard(ast, coldFunctionNodes, seed = 2654435769) {
|
|
1398
|
+
function applyColdFlowGuard(ast, coldFunctionNodes, seed = 2654435769, hotExemptNodes) {
|
|
1213
1399
|
let guardedCount = 0;
|
|
1214
1400
|
function maybeInjectGuard(node) {
|
|
1215
1401
|
if (!coldFunctionNodes.has(node)) return;
|
|
1216
1402
|
if (!node.body || node.body.type !== "BlockStatement") return;
|
|
1403
|
+
const guardStmt = createSotaMbaPredicate(seed, 0);
|
|
1217
1404
|
guardedCount++;
|
|
1218
|
-
|
|
1405
|
+
if (hotExemptNodes) {
|
|
1406
|
+
hotExemptNodes.add(guardStmt);
|
|
1407
|
+
hotExemptNodes.add(guardStmt.consequent);
|
|
1408
|
+
}
|
|
1219
1409
|
let insertIdx = 0;
|
|
1220
1410
|
while (insertIdx < node.body.body.length && node.body.body[insertIdx].type === "ExpressionStatement" && node.body.body[insertIdx].directive) {
|
|
1221
1411
|
insertIdx++;
|
|
@@ -1247,25 +1437,12 @@ function deriveIntegrityFnName(seed) {
|
|
|
1247
1437
|
const hash = computeIntegrityHash(`unpeek:fn:${seed}`, seed);
|
|
1248
1438
|
return `_u$${hash.toString(36)}`;
|
|
1249
1439
|
}
|
|
1250
|
-
function deriveLocalVar(label, seed) {
|
|
1251
|
-
const hash = computeIntegrityHash(`unpeek:var:${label}:${seed}`, seed) & 1048575;
|
|
1252
|
-
return `_${label}${hash.toString(36)}`;
|
|
1253
|
-
}
|
|
1254
1440
|
function createDeterrentSnippet(config) {
|
|
1255
1441
|
const seed = config.seed >>> 0;
|
|
1256
|
-
const expectedToken = (config.expectedIntegrityHash ?? seed) >>> 0;
|
|
1257
1442
|
const deterrentMode = config.deterrentMode ?? "passive";
|
|
1258
1443
|
const fnName = deriveIntegrityFnName(seed);
|
|
1259
|
-
const
|
|
1260
|
-
|
|
1261
|
-
const noopVar = deriveLocalVar("n", seed);
|
|
1262
|
-
const methodsVar = deriveLocalVar("m", seed);
|
|
1263
|
-
const idxVar = deriveLocalVar("i", seed);
|
|
1264
|
-
const errVar = deriveLocalVar("e", seed);
|
|
1265
|
-
const tokenBit = expectedToken & 1;
|
|
1266
|
-
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}){}}}` : "";
|
|
1267
|
-
const tamperDispatch = `if(window.dispatchEvent&&typeof CustomEvent!=='undefined'){try{window.dispatchEvent(new CustomEvent('unpeek:tamper'));}catch(${errVar}){}}`;
|
|
1268
|
-
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}){}}})();`;
|
|
1444
|
+
const consoleSilence = deterrentMode === "gradual" ? "for(var k in console)console[k]=f=>0;" : "";
|
|
1445
|
+
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);`;
|
|
1269
1446
|
}
|
|
1270
1447
|
|
|
1271
1448
|
// src/runtime/index.ts
|
|
@@ -1330,7 +1507,7 @@ function transformJavaScript(code, options = {}) {
|
|
|
1330
1507
|
coldFunctionNodes,
|
|
1331
1508
|
hotExemptNodes
|
|
1332
1509
|
} = analyzeAstHotPaths(ast);
|
|
1333
|
-
applyColdFlowGuard(ast, coldFunctionNodes, seed);
|
|
1510
|
+
applyColdFlowGuard(ast, coldFunctionNodes, seed, hotExemptNodes);
|
|
1334
1511
|
const mangledSymbolsCount = applyPolymorphicMangler(ast, seed);
|
|
1335
1512
|
const { encryptedStringsCount, integrityToken } = applyStringVault(
|
|
1336
1513
|
ast,
|