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