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/rollup.js
CHANGED
|
@@ -550,27 +550,25 @@ var DIRECTIVE_STRINGS = /* @__PURE__ */ new Set([
|
|
|
550
550
|
"use asm"
|
|
551
551
|
]);
|
|
552
552
|
var HELPER_TEMPLATE = acorn2.parse(
|
|
553
|
-
`var _ =
|
|
554
|
-
var s = "";
|
|
555
|
-
for (var j = 0; j < a.length; j++) {
|
|
556
|
-
s += String.fromCharCode(a.charCodeAt(j) ^ (((0 ^ ((a._u || /\\n/.test(f) * 14) | ((j & 1) * 0))) & 30) | 1));
|
|
557
|
-
}
|
|
558
|
-
return s;
|
|
559
|
-
});`,
|
|
553
|
+
`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;});})([]);`,
|
|
560
554
|
{ ecmaVersion: "latest", sourceType: "script" }
|
|
561
555
|
).body[0];
|
|
562
556
|
function createVaultHelperAst(cacheVarName, encryptedPayloads, mask, step) {
|
|
563
557
|
const node = structuredClone(HELPER_TEMPLATE);
|
|
564
558
|
node.declarations[0].id.name = cacheVarName;
|
|
565
|
-
node.declarations[0].init.
|
|
559
|
+
node.declarations[0].init.arguments[0].elements = encryptedPayloads.map(
|
|
566
560
|
(str) => ({
|
|
567
561
|
type: "Literal",
|
|
568
562
|
value: str,
|
|
569
563
|
raw: JSON.stringify(str)
|
|
570
564
|
})
|
|
571
565
|
);
|
|
572
|
-
const
|
|
573
|
-
const
|
|
566
|
+
const outerFn = node.declarations[0].init.callee;
|
|
567
|
+
const returnStmt = outerFn.body.body[0];
|
|
568
|
+
const innerFn = returnStmt.argument.arguments[0];
|
|
569
|
+
const forStmt = innerFn.body.body[1];
|
|
570
|
+
const expr = forStmt.body.type === "BlockStatement" ? forStmt.body.body[0].expression : forStmt.body.expression;
|
|
571
|
+
const binaryXor = expr.right.arguments[0];
|
|
574
572
|
const innerLeft = binaryXor.right.left.left;
|
|
575
573
|
innerLeft.left.value = mask;
|
|
576
574
|
innerLeft.left.raw = String(mask);
|
|
@@ -608,44 +606,58 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
|
|
|
608
606
|
};
|
|
609
607
|
}
|
|
610
608
|
const mask = seed >>> 0 & 30 | 3;
|
|
611
|
-
const step =
|
|
609
|
+
const step = 1;
|
|
612
610
|
const stringToIndex = /* @__PURE__ */ new Map();
|
|
613
611
|
const encryptedPayloads = [];
|
|
614
612
|
const targetsToReplace = [];
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
if (
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
613
|
+
const customWalkBase = {
|
|
614
|
+
...walk2.base,
|
|
615
|
+
Property(node, st, c) {
|
|
616
|
+
c(node.key, st);
|
|
617
|
+
if (node.value) c(node.value, st);
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
walk2.ancestor(
|
|
621
|
+
ast,
|
|
622
|
+
{
|
|
623
|
+
Literal(node, _state, ancestors) {
|
|
624
|
+
if (typeof node.value !== "string") return;
|
|
625
|
+
const val = node.value;
|
|
626
|
+
if (val.length < minStringLength) return;
|
|
627
|
+
if (DIRECTIVE_STRINGS.has(val)) return;
|
|
628
|
+
if (hotExemptNodes) {
|
|
629
|
+
for (let i = ancestors.length - 2; i >= 0; i--) {
|
|
630
|
+
if (hotExemptNodes.has(ancestors[i])) {
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
625
633
|
}
|
|
626
634
|
}
|
|
635
|
+
const parent = ancestors[ancestors.length - 2];
|
|
636
|
+
if (!parent) return;
|
|
637
|
+
if (parent.type === "ExpressionStatement" && parent.directive) return;
|
|
638
|
+
if (parent.type === "ImportDeclaration" || parent.type === "ExportNamedDeclaration" || parent.type === "ExportAllDeclaration" || parent.type === "ImportExpression") {
|
|
639
|
+
if (parent.source === node) return;
|
|
640
|
+
}
|
|
641
|
+
if ((parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") && parent.key === node && !parent.computed) {
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
if (parent.type === "Property" && parent.key === node) {
|
|
645
|
+
parent.computed = true;
|
|
646
|
+
}
|
|
647
|
+
if (parent.type === "ImportAttribute" || parent.type === "ImportSpecifier" || parent.type === "ExportSpecifier") {
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
let idx = stringToIndex.get(val);
|
|
651
|
+
if (idx === void 0) {
|
|
652
|
+
idx = encryptedPayloads.length;
|
|
653
|
+
stringToIndex.set(val, idx);
|
|
654
|
+
encryptedPayloads.push(encodeStringWithSeed(val, mask, step));
|
|
655
|
+
}
|
|
656
|
+
targetsToReplace.push({ node, parent });
|
|
627
657
|
}
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
if (parent.type === "ImportDeclaration" || parent.type === "ExportNamedDeclaration" || parent.type === "ExportAllDeclaration" || parent.type === "ImportExpression") {
|
|
632
|
-
if (parent.source === node) return;
|
|
633
|
-
}
|
|
634
|
-
if ((parent.type === "Property" || parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") && parent.key === node && !parent.computed) {
|
|
635
|
-
return;
|
|
636
|
-
}
|
|
637
|
-
if (parent.type === "ImportAttribute" || parent.type === "ImportSpecifier" || parent.type === "ExportSpecifier") {
|
|
638
|
-
return;
|
|
639
|
-
}
|
|
640
|
-
let idx = stringToIndex.get(val);
|
|
641
|
-
if (idx === void 0) {
|
|
642
|
-
idx = encryptedPayloads.length;
|
|
643
|
-
stringToIndex.set(val, idx);
|
|
644
|
-
encryptedPayloads.push(encodeStringWithSeed(val, mask, step));
|
|
645
|
-
}
|
|
646
|
-
targetsToReplace.push({ node });
|
|
647
|
-
}
|
|
648
|
-
});
|
|
658
|
+
},
|
|
659
|
+
customWalkBase
|
|
660
|
+
);
|
|
649
661
|
if (targetsToReplace.length === 0 || encryptedPayloads.length === 0) {
|
|
650
662
|
return {
|
|
651
663
|
encryptedStringsCount: 0,
|
|
@@ -656,7 +668,10 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
|
|
|
656
668
|
const integrityToken = computeFnv1aHash(serializedTable, seed);
|
|
657
669
|
const suffix = computeFnv1aHash(`vault:${seed}`, integrityToken).toString(36);
|
|
658
670
|
const cacheVarName = `_uC${suffix}`;
|
|
659
|
-
for (const { node } of targetsToReplace) {
|
|
671
|
+
for (const { node, parent } of targetsToReplace) {
|
|
672
|
+
if (parent?.type === "Property" && parent.key === node) {
|
|
673
|
+
parent.computed = true;
|
|
674
|
+
}
|
|
660
675
|
const idx = stringToIndex.get(node.value);
|
|
661
676
|
node.type = "MemberExpression";
|
|
662
677
|
node.object = {
|
|
@@ -1121,10 +1136,174 @@ function applyPolymorphicMangler(ast, seed = 2654435769) {
|
|
|
1121
1136
|
|
|
1122
1137
|
// src/ast/cold-flow-guard.ts
|
|
1123
1138
|
import * as walk4 from "acorn-walk";
|
|
1124
|
-
function
|
|
1125
|
-
const
|
|
1126
|
-
|
|
1127
|
-
|
|
1139
|
+
function createDecoyConsequent(fnIndex) {
|
|
1140
|
+
const model = Math.abs(fnIndex) % 3;
|
|
1141
|
+
if (model === 0) {
|
|
1142
|
+
return {
|
|
1143
|
+
type: "BlockStatement",
|
|
1144
|
+
body: [
|
|
1145
|
+
{
|
|
1146
|
+
type: "ReturnStatement",
|
|
1147
|
+
argument: {
|
|
1148
|
+
type: "ObjectExpression",
|
|
1149
|
+
properties: [
|
|
1150
|
+
{
|
|
1151
|
+
type: "Property",
|
|
1152
|
+
key: { type: "Identifier", name: "endpoint" },
|
|
1153
|
+
value: {
|
|
1154
|
+
type: "Literal",
|
|
1155
|
+
value: "/api/v2/auth/admin-bypass",
|
|
1156
|
+
raw: '"/api/v2/auth/admin-bypass"'
|
|
1157
|
+
},
|
|
1158
|
+
kind: "init",
|
|
1159
|
+
computed: false,
|
|
1160
|
+
method: false,
|
|
1161
|
+
shorthand: false
|
|
1162
|
+
},
|
|
1163
|
+
{
|
|
1164
|
+
type: "Property",
|
|
1165
|
+
key: { type: "Identifier", name: "superadmin_token" },
|
|
1166
|
+
value: { type: "Literal", value: 1, raw: "1" },
|
|
1167
|
+
kind: "init",
|
|
1168
|
+
computed: false,
|
|
1169
|
+
method: false,
|
|
1170
|
+
shorthand: false
|
|
1171
|
+
},
|
|
1172
|
+
{
|
|
1173
|
+
type: "Property",
|
|
1174
|
+
key: { type: "Identifier", name: "elevate" },
|
|
1175
|
+
value: { type: "Literal", value: 1, raw: "1" },
|
|
1176
|
+
kind: "init",
|
|
1177
|
+
computed: false,
|
|
1178
|
+
method: false,
|
|
1179
|
+
shorthand: false
|
|
1180
|
+
}
|
|
1181
|
+
]
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
]
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1187
|
+
if (model === 1) {
|
|
1188
|
+
return {
|
|
1189
|
+
type: "BlockStatement",
|
|
1190
|
+
body: [
|
|
1191
|
+
{
|
|
1192
|
+
type: "ReturnStatement",
|
|
1193
|
+
argument: {
|
|
1194
|
+
type: "ObjectExpression",
|
|
1195
|
+
properties: [
|
|
1196
|
+
{
|
|
1197
|
+
type: "Property",
|
|
1198
|
+
key: { type: "Identifier", name: "endpoint" },
|
|
1199
|
+
value: {
|
|
1200
|
+
type: "Literal",
|
|
1201
|
+
value: "/api/v2/auth/verify-master",
|
|
1202
|
+
raw: '"/api/v2/auth/verify-master"'
|
|
1203
|
+
},
|
|
1204
|
+
kind: "init",
|
|
1205
|
+
computed: false,
|
|
1206
|
+
method: false,
|
|
1207
|
+
shorthand: false
|
|
1208
|
+
},
|
|
1209
|
+
{
|
|
1210
|
+
type: "Property",
|
|
1211
|
+
key: { type: "Identifier", name: "_verifyMasterToken" },
|
|
1212
|
+
value: { type: "Literal", value: true, raw: "true" },
|
|
1213
|
+
kind: "init",
|
|
1214
|
+
computed: false,
|
|
1215
|
+
method: false,
|
|
1216
|
+
shorthand: false
|
|
1217
|
+
},
|
|
1218
|
+
{
|
|
1219
|
+
type: "Property",
|
|
1220
|
+
key: { type: "Identifier", name: "_bypassToken" },
|
|
1221
|
+
value: {
|
|
1222
|
+
type: "Literal",
|
|
1223
|
+
value: "mock_jwt_bypass_signature",
|
|
1224
|
+
raw: '"mock_jwt_bypass_signature"'
|
|
1225
|
+
},
|
|
1226
|
+
kind: "init",
|
|
1227
|
+
computed: false,
|
|
1228
|
+
method: false,
|
|
1229
|
+
shorthand: false
|
|
1230
|
+
},
|
|
1231
|
+
{
|
|
1232
|
+
type: "Property",
|
|
1233
|
+
key: { type: "Identifier", name: "authorized" },
|
|
1234
|
+
value: { type: "Literal", value: true, raw: "true" },
|
|
1235
|
+
kind: "init",
|
|
1236
|
+
computed: false,
|
|
1237
|
+
method: false,
|
|
1238
|
+
shorthand: false
|
|
1239
|
+
}
|
|
1240
|
+
]
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
]
|
|
1244
|
+
};
|
|
1245
|
+
}
|
|
1246
|
+
return {
|
|
1247
|
+
type: "BlockStatement",
|
|
1248
|
+
body: [
|
|
1249
|
+
{
|
|
1250
|
+
type: "ReturnStatement",
|
|
1251
|
+
argument: {
|
|
1252
|
+
type: "ObjectExpression",
|
|
1253
|
+
properties: [
|
|
1254
|
+
{
|
|
1255
|
+
type: "Property",
|
|
1256
|
+
key: { type: "Identifier", name: "endpoint" },
|
|
1257
|
+
value: {
|
|
1258
|
+
type: "Literal",
|
|
1259
|
+
value: "/api/v2/auth/debug-telemetry",
|
|
1260
|
+
raw: '"/api/v2/auth/debug-telemetry"'
|
|
1261
|
+
},
|
|
1262
|
+
kind: "init",
|
|
1263
|
+
computed: false,
|
|
1264
|
+
method: false,
|
|
1265
|
+
shorthand: false
|
|
1266
|
+
},
|
|
1267
|
+
{
|
|
1268
|
+
type: "Property",
|
|
1269
|
+
key: { type: "Identifier", name: "debug_supervisor_override" },
|
|
1270
|
+
value: { type: "Literal", value: true, raw: "true" },
|
|
1271
|
+
kind: "init",
|
|
1272
|
+
computed: false,
|
|
1273
|
+
method: false,
|
|
1274
|
+
shorthand: false
|
|
1275
|
+
},
|
|
1276
|
+
{
|
|
1277
|
+
type: "Property",
|
|
1278
|
+
key: { type: "Identifier", name: "_bypassToken" },
|
|
1279
|
+
value: {
|
|
1280
|
+
type: "Literal",
|
|
1281
|
+
value: "superadmin_token",
|
|
1282
|
+
raw: '"superadmin_token"'
|
|
1283
|
+
},
|
|
1284
|
+
kind: "init",
|
|
1285
|
+
computed: false,
|
|
1286
|
+
method: false,
|
|
1287
|
+
shorthand: false
|
|
1288
|
+
},
|
|
1289
|
+
{
|
|
1290
|
+
type: "Property",
|
|
1291
|
+
key: { type: "Identifier", name: "mfa_bypassed" },
|
|
1292
|
+
value: { type: "Literal", value: true, raw: "true" },
|
|
1293
|
+
kind: "init",
|
|
1294
|
+
computed: false,
|
|
1295
|
+
method: false,
|
|
1296
|
+
shorthand: false
|
|
1297
|
+
}
|
|
1298
|
+
]
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
]
|
|
1302
|
+
};
|
|
1303
|
+
}
|
|
1304
|
+
function createSotaMbaPredicate(seed, fnIndex = 0) {
|
|
1305
|
+
const x = (seed >>> 0) + Math.imul(fnIndex + 1, 73244475) | 0;
|
|
1306
|
+
const y = x ^ 1515870810 | 0;
|
|
1128
1307
|
return {
|
|
1129
1308
|
type: "IfStatement",
|
|
1130
1309
|
test: {
|
|
@@ -1132,46 +1311,57 @@ function createOpaqueGuardStatement(seed, fnIndex) {
|
|
|
1132
1311
|
operator: "===",
|
|
1133
1312
|
left: {
|
|
1134
1313
|
type: "BinaryExpression",
|
|
1135
|
-
operator: "
|
|
1314
|
+
operator: "|",
|
|
1136
1315
|
left: {
|
|
1137
1316
|
type: "BinaryExpression",
|
|
1138
1317
|
operator: "^",
|
|
1139
|
-
left: {
|
|
1140
|
-
right: {
|
|
1318
|
+
left: {
|
|
1141
1319
|
type: "BinaryExpression",
|
|
1142
|
-
operator: "
|
|
1143
|
-
left: {
|
|
1320
|
+
operator: "+",
|
|
1321
|
+
left: {
|
|
1322
|
+
type: "BinaryExpression",
|
|
1323
|
+
operator: "|",
|
|
1324
|
+
left: { type: "Literal", value: x, raw: String(x) },
|
|
1325
|
+
right: { type: "Literal", value: y, raw: String(y) }
|
|
1326
|
+
},
|
|
1144
1327
|
right: {
|
|
1145
|
-
type: "
|
|
1146
|
-
operator: "
|
|
1147
|
-
|
|
1148
|
-
|
|
1328
|
+
type: "BinaryExpression",
|
|
1329
|
+
operator: "&",
|
|
1330
|
+
left: { type: "Literal", value: x, raw: String(x) },
|
|
1331
|
+
right: { type: "Literal", value: y, raw: String(y) }
|
|
1149
1332
|
}
|
|
1333
|
+
},
|
|
1334
|
+
right: {
|
|
1335
|
+
type: "BinaryExpression",
|
|
1336
|
+
operator: "+",
|
|
1337
|
+
left: { type: "Literal", value: x, raw: String(x) },
|
|
1338
|
+
right: { type: "Literal", value: y, raw: String(y) }
|
|
1150
1339
|
}
|
|
1151
1340
|
},
|
|
1152
|
-
right: {
|
|
1341
|
+
right: {
|
|
1342
|
+
type: "UnaryExpression",
|
|
1343
|
+
operator: "!",
|
|
1344
|
+
prefix: true,
|
|
1345
|
+
argument: { type: "Identifier", name: "String" }
|
|
1346
|
+
}
|
|
1153
1347
|
},
|
|
1154
|
-
right: { type: "Literal", value:
|
|
1155
|
-
},
|
|
1156
|
-
consequent: {
|
|
1157
|
-
type: "ExpressionStatement",
|
|
1158
|
-
expression: {
|
|
1159
|
-
type: "UnaryExpression",
|
|
1160
|
-
operator: "void",
|
|
1161
|
-
prefix: true,
|
|
1162
|
-
argument: { type: "Literal", value: 0, raw: "0" }
|
|
1163
|
-
}
|
|
1348
|
+
right: { type: "Literal", value: 2147483647, raw: "0x7fffffff" }
|
|
1164
1349
|
},
|
|
1350
|
+
consequent: createDecoyConsequent(fnIndex),
|
|
1165
1351
|
alternate: null
|
|
1166
1352
|
};
|
|
1167
1353
|
}
|
|
1168
|
-
function applyColdFlowGuard(ast, coldFunctionNodes, seed = 2654435769) {
|
|
1354
|
+
function applyColdFlowGuard(ast, coldFunctionNodes, seed = 2654435769, hotExemptNodes) {
|
|
1169
1355
|
let guardedCount = 0;
|
|
1170
1356
|
function maybeInjectGuard(node) {
|
|
1171
1357
|
if (!coldFunctionNodes.has(node)) return;
|
|
1172
1358
|
if (!node.body || node.body.type !== "BlockStatement") return;
|
|
1359
|
+
const guardStmt = createSotaMbaPredicate(seed, 0);
|
|
1173
1360
|
guardedCount++;
|
|
1174
|
-
|
|
1361
|
+
if (hotExemptNodes) {
|
|
1362
|
+
hotExemptNodes.add(guardStmt);
|
|
1363
|
+
hotExemptNodes.add(guardStmt.consequent);
|
|
1364
|
+
}
|
|
1175
1365
|
let insertIdx = 0;
|
|
1176
1366
|
while (insertIdx < node.body.body.length && node.body.body[insertIdx].type === "ExpressionStatement" && node.body.body[insertIdx].directive) {
|
|
1177
1367
|
insertIdx++;
|
|
@@ -1203,25 +1393,12 @@ function deriveIntegrityFnName(seed) {
|
|
|
1203
1393
|
const hash = computeIntegrityHash(`unpeek:fn:${seed}`, seed);
|
|
1204
1394
|
return `_u$${hash.toString(36)}`;
|
|
1205
1395
|
}
|
|
1206
|
-
function deriveLocalVar(label, seed) {
|
|
1207
|
-
const hash = computeIntegrityHash(`unpeek:var:${label}:${seed}`, seed) & 1048575;
|
|
1208
|
-
return `_${label}${hash.toString(36)}`;
|
|
1209
|
-
}
|
|
1210
1396
|
function createDeterrentSnippet(config) {
|
|
1211
1397
|
const seed = config.seed >>> 0;
|
|
1212
|
-
const expectedToken = (config.expectedIntegrityHash ?? seed) >>> 0;
|
|
1213
1398
|
const deterrentMode = config.deterrentMode ?? "passive";
|
|
1214
1399
|
const fnName = deriveIntegrityFnName(seed);
|
|
1215
|
-
const
|
|
1216
|
-
|
|
1217
|
-
const noopVar = deriveLocalVar("n", seed);
|
|
1218
|
-
const methodsVar = deriveLocalVar("m", seed);
|
|
1219
|
-
const idxVar = deriveLocalVar("i", seed);
|
|
1220
|
-
const errVar = deriveLocalVar("e", seed);
|
|
1221
|
-
const tokenBit = expectedToken & 1;
|
|
1222
|
-
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}){}}}` : "";
|
|
1223
|
-
const tamperDispatch = `if(window.dispatchEvent&&typeof CustomEvent!=='undefined'){try{window.dispatchEvent(new CustomEvent('unpeek:tamper'));}catch(${errVar}){}}`;
|
|
1224
|
-
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}){}}})();`;
|
|
1400
|
+
const consoleSilence = deterrentMode === "gradual" ? "for(var k in console)console[k]=f=>0;" : "";
|
|
1401
|
+
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);`;
|
|
1225
1402
|
}
|
|
1226
1403
|
|
|
1227
1404
|
// src/runtime/index.ts
|
|
@@ -1286,7 +1463,7 @@ function transformJavaScript(code, options = {}) {
|
|
|
1286
1463
|
coldFunctionNodes,
|
|
1287
1464
|
hotExemptNodes
|
|
1288
1465
|
} = analyzeAstHotPaths(ast);
|
|
1289
|
-
applyColdFlowGuard(ast, coldFunctionNodes, seed);
|
|
1466
|
+
applyColdFlowGuard(ast, coldFunctionNodes, seed, hotExemptNodes);
|
|
1290
1467
|
const mangledSymbolsCount = applyPolymorphicMangler(ast, seed);
|
|
1291
1468
|
const { encryptedStringsCount, integrityToken } = applyStringVault(
|
|
1292
1469
|
ast,
|