🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

cc-channel-patch

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cc-channel-patch - npm Package Compare versions

Comparing version
0.4.0
to
0.5.0
+65
-30
index.mjs

@@ -18,7 +18,26 @@ #!/usr/bin/env node

// ─── 二进制模式补丁定义(exe 专用)────────────────────────
const BINARY_PATCHES = [
['function PaH(){return lA("tengu_harbor",!1)}', 'function PaH(){return !0 }', 'Channels feature flag (tengu_harbor)'],
['if(!yf()?.accessToken)', 'if( false )', 'Channel gate auth check'],
['noAuth:!yf()?.accessToken', 'noAuth: false ', 'UI noAuth display check'],
// ─── 二进制模式补丁定义 ────────────────────────────────────
// 每组:多个 [原始, 替换] 变体,匹配到任一即生效(适配不同平台 minify 结果)
const BINARY_PATCH_GROUPS = [
{
desc: 'Channels feature flag (tengu_harbor)',
variants: [
['function PaH(){return lA("tengu_harbor",!1)}', 'function PaH(){return !0 }'],
['function waH(){return l$("tengu_harbor",!1)}', 'function waH(){return !0 }'],
],
},
{
desc: 'Channel gate auth check',
variants: [
['if(!yf()?.accessToken)', 'if( false )'],
['if(!SL()?.accessToken)', 'if( false )'],
],
},
{
desc: 'UI noAuth display check',
variants: [
['noAuth:!yf()?.accessToken', 'noAuth: false '],
['noAuth:!SL()?.accessToken', 'noAuth: false '],
],
},
];

@@ -136,31 +155,47 @@

for (const [original, replacement, desc] of BINARY_PATCHES) {
if (original.length !== replacement.length) {
console.error(` 致命错误: "${desc}" 补丁长度不匹配`);
process.exit(1);
}
const origBuf = Buffer.from(original);
const patchBuf = Buffer.from(replacement);
for (const { desc, variants } of BINARY_PATCH_GROUPS) {
let groupPatched = false, groupSkipped = false;
let pos = 0, count = 0;
while (true) {
const idx = buf.indexOf(origBuf, pos);
if (idx === -1) break;
patchBuf.copy(buf, idx);
count++;
pos = idx + 1;
}
for (const [original, replacement] of variants) {
if (original.length !== replacement.length) {
console.error(` 致命错误: "${desc}" 补丁长度不匹配 (${original.length} vs ${replacement.length})`);
process.exit(1);
}
const origBuf = Buffer.from(original);
const patchBuf = Buffer.from(replacement);
let alreadyCount = 0;
pos = 0;
while (true) {
const idx = buf.indexOf(patchBuf, pos);
if (idx === -1) break;
alreadyCount++;
pos = idx + 1;
// 搜索并替换
let pos = 0, count = 0;
while (true) {
const idx = buf.indexOf(origBuf, pos);
if (idx === -1) break;
patchBuf.copy(buf, idx);
count++;
pos = idx + 1;
}
if (count > 0) {
console.log(` ✅ ${desc} — ${count} 处已修补`);
patched += count;
groupPatched = true;
break; // 一组只需匹配一个变体
}
// 检查是否已 patch
let alreadyCount = 0;
pos = 0;
while (true) {
const idx = buf.indexOf(patchBuf, pos);
if (idx === -1) break;
alreadyCount++;
pos = idx + 1;
}
if (alreadyCount > 0) {
groupSkipped = true;
break;
}
}
if (count > 0) { console.log(` ✅ ${desc} — ${count} 处已修补`); patched += count; }
else if (alreadyCount > 0) { console.log(` ⏭️ ${desc} — 已修补 (${alreadyCount} 处)`); skipped += alreadyCount; }
else { console.log(` ⚠️ ${desc} — 未找到`); }
if (!groupPatched && groupSkipped) { console.log(` ⏭️ ${desc} — 已修补`); skipped++; }
else if (!groupPatched && !groupSkipped) { console.log(` ⚠️ ${desc} — 未找到`); }
}

@@ -167,0 +202,0 @@

{
"name": "cc-channel-patch",
"version": "0.4.0",
"version": "0.5.0",
"description": "One-command patch to enable Claude Code Channels (bypasses tengu_harbor feature flag)",

@@ -5,0 +5,0 @@ "type": "module",