luckiness commited on
Commit
be7f12e
·
verified ·
1 Parent(s): b5d3b3e

Upload 10 files

Browse files
Files changed (10) hide show
  1. .dockerignore +33 -0
  2. Dockerfile +92 -0
  3. getSign.js +1 -0
  4. main.py +74 -0
  5. openapi.pyc +0 -0
  6. package.json +13 -0
  7. pyc_loader.py +59 -0
  8. requirements.txt +9 -0
  9. sign_bg.ebde2702.wasm +3 -0
  10. start.sh +18 -0
.dockerignore ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Git
2
+ .git
3
+ .gitignore
4
+ .github
5
+
6
+ # Python
7
+ __pycache__/
8
+ *.so
9
+ .Python
10
+ env/
11
+ venv/
12
+ ENV/
13
+
14
+ # 缓存文件
15
+ cache/
16
+ *.json
17
+
18
+ # 不需要的图片和测试文件
19
+ *.png
20
+ test_*.py
21
+
22
+ # 编辑器文件
23
+ .vscode/
24
+ .idea/
25
+ *.swp
26
+ *.swo
27
+
28
+ # 临时文件
29
+ tmp/
30
+ temp/
31
+
32
+ # 确保不忽略wasm文件
33
+ !
Dockerfile ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9-slim
2
+
3
+ WORKDIR /app
4
+
5
+ # 设置语言环境以支持UTF-8
6
+ ENV LANG=C.UTF-8
7
+ ENV LC_ALL=C.UTF-8
8
+ ENV PYTHONUNBUFFERED=1
9
+ ENV PYTHONDEBUG=1
10
+ # 确保Python不禁止写字节码文件
11
+ ENV PYTHONDONTWRITEBYTECODE=0
12
+ # 设置Playwright环境变量
13
+ ENV PLAYWRIGHT_BROWSERS_PATH=/app/.playwright
14
+ ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
15
+ # 允许Node.js加载本地WASM文件
16
+ ENV NODE_OPTIONS=--experimental-wasm-modules
17
+
18
+ # 安装最新版本的Node.js (20.x LTS)而不是使用默认版本
19
+ RUN apt-get update && apt-get install -y --no-install-recommends \
20
+ curl \
21
+ wget \
22
+ gnupg \
23
+ libglib2.0-0 \
24
+ libnss3 \
25
+ libnspr4 \
26
+ libatk1.0-0 \
27
+ libatk-bridge2.0-0 \
28
+ libcups2 \
29
+ libdrm2 \
30
+ libdbus-1-3 \
31
+ libxcb1 \
32
+ libxkbcommon0 \
33
+ libx11-6 \
34
+ libxcomposite1 \
35
+ libxdamage1 \
36
+ libxext6 \
37
+ libxfixes3 \
38
+ libxrandr2 \
39
+ libgbm1 \
40
+ libpango-1.0-0 \
41
+ libcairo2 \
42
+ libasound2 \
43
+ && apt-get clean \
44
+ && rm -rf /var/lib/apt/lists/*
45
+
46
+ # 安装Node.js 20.x LTS版本
47
+ RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
48
+ && apt-get install -y nodejs \
49
+ && npm install -g npm@latest \
50
+ && node --version \
51
+ && npm --version
52
+
53
+ # 先复制依赖文件
54
+ COPY requirements.txt /app/
55
+ RUN pip install --no-cache-dir -r requirements.txt
56
+
57
+ # 复制所有文件 - 特别是.pyc文件和.wasm文件
58
+ COPY . /app/
59
+
60
+ # 确保WASM文件有正确的权限
61
+ RUN find /app -name "*.wasm" -type f -exec chmod 644 {} \; || echo "没有找到WASM文件"
62
+
63
+ # 安装 Playwright 及其依赖(使用--with-deps确保安装浏览器依赖)
64
+ RUN pip install playwright && \
65
+ playwright install webkit --with-deps && \
66
+ playwright install-deps webkit
67
+
68
+ # 列出文件和目录,确认关键文件存在(用于调试)
69
+ RUN echo "==== 容器内的文件 ====" && \
70
+ ls -la /app/ && \
71
+ echo "=== .pyc文件检查 ===" && \
72
+ find /app -name "*.pyc" -type f | sort && \
73
+ echo "=== WASM文件检查 ===" && \
74
+ find /app -name "*.wasm" -type f | sort && \
75
+ echo "=== Playwright目录检查 ===" && \
76
+ ls -la $PLAYWRIGHT_BROWSERS_PATH || echo "Playwright目录未创建" && \
77
+ echo "=== Node.js版本 ===" && \
78
+ node --version && \
79
+ npm --version
80
+
81
+ # 创建缓存目录
82
+ RUN mkdir -p /app/cache && chmod 777 /app/cache
83
+
84
+ # 设置环境变量
85
+ ENV PORT=7860
86
+ ENV HOST=0.0.0.0
87
+
88
+ # 测试Node.js模块导入
89
+ RUN cd /app && node -e "console.log('测试ES模块导入'); import('crypto').then(m => console.log('成功导入crypto模块')).catch(e => console.error('导入失败:', e))" || echo "ES模块测试失败,但继续执行"
90
+
91
+ # 直接使用python运行main.py
92
+ CMD ["python", "main.py"]
getSign.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const a0_0x18f407=a0_0x186b;(function(_0x59c4cc,_0x6870d6){const _0x4f24a0=a0_0x186b,_0x8c831=_0x59c4cc();while(!![]){try{const _0x32456a=-parseInt(_0x4f24a0(0xc8))/0x1+parseInt(_0x4f24a0(0x86))/0x2+parseInt(_0x4f24a0(0x9e))/0x3+parseInt(_0x4f24a0(0xef))/0x4*(-parseInt(_0x4f24a0(0xb6))/0x5)+-parseInt(_0x4f24a0(0xc3))/0x6*(-parseInt(_0x4f24a0(0x6e))/0x7)+parseInt(_0x4f24a0(0x9d))/0x8+-parseInt(_0x4f24a0(0x9a))/0x9*(parseInt(_0x4f24a0(0x89))/0xa);if(_0x32456a===_0x6870d6)break;else _0x8c831['push'](_0x8c831['shift']());}catch(_0x4f0c92){_0x8c831['push'](_0x8c831['shift']());}}}(a0_0x4dad,0x607f4));function a0_0x4dad(){const _0x367cf5=['then','参数字符串:','instantiate','模拟存储异常:','memory','Nonce:','encode','Object(','call','now','fromEntries','245DjyOkv','decode','digest','处理参数:','调用WASM的get_sign函数...','签名信息:','asUintN','push','Memory','string','node','CompileError','__wbindgen_realloc','36YEdzCc','url','toUpperCase','function','filter','361698vMoUhT','slice','floor','https://ai.dangbei.com/','toString','concat','API请求错误:','WASM模块需要以下导入项:','stringify','argv','请检查importObject中是否提供了此函数','正在初始化WebAssembly模块...','Symbol(','__externref_table_alloc','__externrefTableNextIndex','WASM生成的签名:','签名:','...','请求URL:','sign','__wbindgen_export_2未定义,无法初始化externref表','hash','toLowerCase','\x0a===\x20发送API请求\x20===','body','text','setInt32','用法:\x20node\x20getSign.js\x20<payloadJson>\x20<url>','WASM文件路径:','1.0.2','getRandomValues','method','application/json','log','__wbindgen_export_2','charCodeAt','/v2/chat','includes','length','55868CkAWFl','使用WASM生成签名失败:','buffer','Exception\x20store\x20called\x20with\x20ptr:','module','stack','substring','utf8','WebAssembly模块初始化成功','POST','entries','GET','parse','resolve','223629rsEDcX','RuntimeError','indexOf','__wbindgen_malloc','Payload:','nonce','keys','catch','API响应内容:','crypto','isArray','match','WASM文件大小:','generateSignature','Object','LinkError','exports','__externrefTable','undefined','检查WASM导入项失败:','second','process','apply','\x20\x20\x20\x20-\x20','684542pvXvqv','message','name','450BXVXsm','初始化externref表失败:','warn','md5','1.0.12','\x20\x20模块\x20\x22','zh-CN,zh;q=0.9','WebAssembly初始化失败:','subarray','number','WASM模块未导出get_sign函数,尝试使用原始函数名','compile','准备调用WASM生成签名...','Module','__externref_table_alloc函数未导出,创建一个简单的替代函数','set','symbol','11133aYQgIz','utf-8','*/*','1449984OYwpyg','2345391PKjKgS','-\x20Payload:\x20','msCrypto','__wbindgen_exn_store','randomFillSync','error','startOf','WebAssembly运行时错误','description','缺少的函数:\x20','__wbindgen_start','WASM\x20get_sign函数返回空结果','prototype'];a0_0x4dad=function(){return _0x367cf5;};return a0_0x4dad();}import a0_0x21a3f7 from'crypto';import a0_0x4de2c7 from'fs';import a0_0x5cf552 from'path';let wasmModule=null,wasmInstance=null,wasmInitialized=![],wasmMemoryBuffer=null,dataView=null,uint8Array=null;const E={'Ak':function(_0x1662c6=0x15){let _0x43b087='';const _0x40f7e9=a0_0x21a3f7['randomBytes'](_0x1662c6|=0x0);for(;_0x1662c6--;){_0x43b087+='useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'[0x3f&_0x40f7e9[_0x1662c6]];}return _0x43b087;}};function C(){return()=>{return{'startOf':function(_0x4cde0e){const _0x5ac09c=a0_0x186b;if(_0x4cde0e===_0x5ac09c(0x82))return{'unix':function(){const _0x2f29e4=_0x5ac09c;return Math[_0x2f29e4(0xca)](Date[_0x2f29e4(0xb4)]()/0x3e8);}};return this;}};};}function O(_0x3d7e88,_0x163452){const _0x4ac4f2=a0_0x186b;if(_0x4ac4f2(0xfa)===_0x3d7e88[_0x4ac4f2(0xe7)]){var _0x1788fe,_0x3f466a=_0x3d7e88[_0x4ac4f2(0xc4)][_0x4ac4f2(0x70)]('?');if(-0x1!==_0x3f466a)return _0x3d7e88[_0x4ac4f2(0xc4)][_0x4ac4f2(0xf5)](_0x3f466a+0x1);}else{if(_0x4ac4f2(0xf8)===_0x3d7e88[_0x4ac4f2(0xe7)])return null!==(_0x1788fe=_0x163452[_0x4ac4f2(0xe0)])&&void 0x0!==_0x1788fe?_0x1788fe:'';}return'';}function S(){return function(_0x4ec645){const _0xdaee72=a0_0x186b;return a0_0x21a3f7['createHash'](_0xdaee72(0x8c))['update'](_0x4ec645,_0xdaee72(0xf6))[_0xdaee72(0xb8)]('hex');};}let writtenBytes=0x0;function getUint8ArrayFromWasmMemory(){const _0x560ada=a0_0x186b;return(uint8Array===null||uint8Array[_0x560ada(0xf1)]!==wasmInstance[_0x560ada(0x7e)][_0x560ada(0xaf)]['buffer'])&&(uint8Array=new Uint8Array(wasmInstance[_0x560ada(0x7e)]['memory'][_0x560ada(0xf1)])),uint8Array;}function getDataView(){const _0x3bfe68=a0_0x186b;return(dataView===null||dataView[_0x3bfe68(0xf1)]!==wasmInstance[_0x3bfe68(0x7e)][_0x3bfe68(0xaf)]['buffer'])&&(dataView=new DataView(wasmInstance[_0x3bfe68(0x7e)][_0x3bfe68(0xaf)][_0x3bfe68(0xf1)])),dataView;}function decodeString(_0xd52f0a,_0xd6ac4a){const _0x10a0e0=a0_0x186b;_0xd52f0a>>>=0x0;const _0x5ce30e=getUint8ArrayFromWasmMemory(),_0x31dd6d=_0x5ce30e[_0x10a0e0(0x91)](_0xd52f0a,_0xd52f0a+_0xd6ac4a),_0x2e0242=new TextDecoder(_0x10a0e0(0x9b),{'ignoreBOM':!![],'fatal':!![]});return _0x2e0242[_0x10a0e0(0xb7)](_0x31dd6d);}function encodeString(_0x525d50,_0x422161,_0x3e4f79){const _0x187911=a0_0x186b,_0x1e7221=new TextEncoder();if(_0x3e4f79===undefined){const _0x510454=_0x1e7221[_0x187911(0xb1)](_0x525d50),_0x55b141=wasmInstance[_0x187911(0x7e)][_0x187911(0x71)](_0x510454['length']),_0x549e6c=getUint8ArrayFromWasmMemory();return _0x549e6c[_0x187911(0x98)](_0x510454,_0x55b141),writtenBytes=_0x510454[_0x187911(0xee)],_0x55b141;}else{const _0xd074d4=_0x525d50[_0x187911(0xee)];let _0x1c0feb=_0x422161(_0xd074d4,0x1)>>>0x0;const _0x484dbb=getUint8ArrayFromWasmMemory();let _0x2471ce=0x0;for(;_0x2471ce<_0xd074d4;_0x2471ce++){const _0x344aa5=_0x525d50[_0x187911(0xeb)](_0x2471ce);if(_0x344aa5>0x7f)break;_0x484dbb[_0x1c0feb+_0x2471ce]=_0x344aa5;}if(_0x2471ce!==_0xd074d4){const _0x40bc83=_0x525d50[_0x187911(0xc9)](_0x2471ce),_0x330273=_0x1e7221[_0x187911(0xb1)](_0x40bc83),_0x4d1925=_0x2471ce+_0x330273[_0x187911(0xee)];_0x1c0feb=_0x3e4f79(_0x1c0feb,_0xd074d4,_0x4d1925,0x1)>>>0x0,_0x484dbb['set'](_0x330273,_0x1c0feb+_0x2471ce),_0x2471ce+=_0x330273[_0x187911(0xee)];}return writtenBytes=_0x2471ce,_0x1c0feb;}}function isNullOrUndefined(_0x15d9f0){return _0x15d9f0===null||_0x15d9f0===undefined;}function initExternrefTable(_0x2d5296){const _0x240c1b=a0_0x186b;if(!_0x2d5296[_0x240c1b(0xea)]){console[_0x240c1b(0x8b)](_0x240c1b(0xdc));return;}try{const _0x3898e5=_0x2d5296[_0x240c1b(0xea)],_0x4924b2=_0x3898e5['grow'](0x4);_0x3898e5[_0x240c1b(0x98)](0x0,undefined),_0x3898e5[_0x240c1b(0x98)](_0x4924b2+0x0,undefined),_0x3898e5['set'](_0x4924b2+0x1,null),_0x3898e5['set'](_0x4924b2+0x2,!![]),_0x3898e5[_0x240c1b(0x98)](_0x4924b2+0x3,![]);}catch(_0x2a8da7){console[_0x240c1b(0x8b)](_0x240c1b(0x8a),_0x2a8da7);}}function a0_0x186b(_0x3a1f46,_0x45ade1){const _0x4dad7e=a0_0x4dad();return a0_0x186b=function(_0x186b03,_0x9df002){_0x186b03=_0x186b03-0x6c;let _0x59fed2=_0x4dad7e[_0x186b03];return _0x59fed2;},a0_0x186b(_0x3a1f46,_0x45ade1);}function storeExternref(_0x39466d){const _0x1671a1=a0_0x186b;!wasmInstance['exports'][_0x1671a1(0xd5)]&&(console['warn'](_0x1671a1(0x97)),!wasmInstance['__externrefTable']&&(wasmInstance[_0x1671a1(0x7f)]=[],wasmInstance['__externrefTableNextIndex']=0x1,wasmInstance[_0x1671a1(0x7e)]['__externref_table_alloc']=function(){const _0x15cb28=_0x1671a1,_0x17f284=wasmInstance[_0x15cb28(0xd6)]++;return _0x17f284;},wasmInstance[_0x1671a1(0x7e)]['__wbindgen_export_2']={'get':function(_0x31e42b){const _0x65f9b6=_0x1671a1;return wasmInstance[_0x65f9b6(0x7f)][_0x31e42b];},'set':function(_0xd2d3b0,_0x1e1c79){const _0x3ef9d4=_0x1671a1;wasmInstance[_0x3ef9d4(0x7f)][_0xd2d3b0]=_0x1e1c79;},'grow':function(_0x2efaa3){const _0x3f735a=_0x1671a1,_0x1b9e45=wasmInstance[_0x3f735a(0x7f)][_0x3f735a(0xee)];return wasmInstance[_0x3f735a(0x7f)][_0x3f735a(0xee)]+=_0x2efaa3,_0x1b9e45;}}));const _0x1a8889=wasmInstance[_0x1671a1(0x7e)][_0x1671a1(0xd5)]();return wasmInstance[_0x1671a1(0x7e)][_0x1671a1(0xea)][_0x1671a1(0x98)](_0x1a8889,_0x39466d),_0x1a8889;}async function checkWasmImports(_0x4e2f8e){const _0x250cbe=a0_0x186b;try{const _0x462328=await WebAssembly[_0x250cbe(0x94)](_0x4e2f8e),_0x74be42=WebAssembly[_0x250cbe(0x96)]['imports'](_0x462328);console[_0x250cbe(0xa3)](_0x250cbe(0xcf));const _0x383dca={};for(const _0x3dfba7 of _0x74be42){!_0x383dca[_0x3dfba7['module']]&&(_0x383dca[_0x3dfba7[_0x250cbe(0xf3)]]=[]),_0x383dca[_0x3dfba7[_0x250cbe(0xf3)]][_0x250cbe(0xbd)](_0x3dfba7['name']);}for(const [_0x4c536c,_0x1e008b]of Object[_0x250cbe(0xf9)](_0x383dca)){console[_0x250cbe(0xa3)](_0x250cbe(0x8e)+_0x4c536c+'\x22:');for(const _0x2edd2f of _0x1e008b){console[_0x250cbe(0xa3)](_0x250cbe(0x85)+_0x2edd2f);}}return _0x74be42;}catch(_0x50dc31){return console[_0x250cbe(0xa3)](_0x250cbe(0x81),_0x50dc31),[];}}async function initWasm(){const _0x50314d=a0_0x186b;if(wasmInitialized)return wasmInstance[_0x50314d(0x7e)];try{console['error'](_0x50314d(0xd3));const _0x563157=a0_0x5cf552[_0x50314d(0x6d)]('./sign_bg.ebde2702.wasm');console['error'](_0x50314d(0xe4),_0x563157);if(!a0_0x4de2c7['existsSync'](_0x563157))throw new Error('WASM文件不存在:\x20'+_0x563157);const _0x358ad3=a0_0x4de2c7['readFileSync'](_0x563157);console['error'](_0x50314d(0x7a),_0x358ad3['length'],'字节'),await checkWasmImports(_0x358ad3);const _0x1698dc=new WebAssembly[(_0x50314d(0xbe))]({'initial':0x10,'maximum':0x64});wasmMemoryBuffer=_0x1698dc[_0x50314d(0xf1)];const _0x562fa2={'wbg':{'__wbindgen_string_new':function(_0xcef192,_0x3bb460){return decodeString(_0xcef192,_0x3bb460);},'__wbindgen_error_new':function(_0x241342,_0x34083f){return new Error(decodeString(_0x241342,_0x34083f));},'__wbindgen_throw':function(_0x4eacd7,_0x35ea1b){throw new Error(decodeString(_0x4eacd7,_0x35ea1b));},'__wbindgen_memory':function(){return _0x1698dc;},'__wbg_buffer_609cc3eee51ed158':function(_0x5b2a5b){const _0x563605=_0x50314d;return _0x5b2a5b[_0x563605(0xf1)];},'__wbg_call_672a4d21634d4a24':function(){const _0x4919ff=_0x50314d;try{return function(_0x1348cb,_0x5fe18c){const _0x2b1e44=a0_0x186b;return _0x1348cb[_0x2b1e44(0xb3)](_0x5fe18c);}[_0x4919ff(0x84)](this,arguments);}catch(_0x44d70b){const _0x4a088e=storeExternref(_0x44d70b);wasmInstance['exports'][_0x4919ff(0xa1)](_0x4a088e);}},'__wbg_call_7cccdd69e0791ae2':function(){try{return function(_0x3ea025,_0x1c2542,_0x451032){const _0x508e47=a0_0x186b;return _0x3ea025[_0x508e47(0xb3)](_0x1c2542,_0x451032);}['apply'](this,arguments);}catch(_0x675624){const _0x242012=storeExternref(_0x675624);wasmInstance['exports']['__wbindgen_exn_store'](_0x242012);}},'__wbg_instanceof_Window_def73ea0955fc569':function(_0x51323e){var _0x51a5dd;try{_0x51a5dd=![];}catch(_0x344af3){_0x51a5dd=![];}return _0x51a5dd;},'__wbg_document_d249400bd7bd996d':function(_0x506865){return 0x0;},'__wbg_getElementById_f827f0d6648718a8':function(_0x44d8cc,_0xad2777,_0x29f8af){return 0x0;},'__wbg_static_accessor_WINDOW_5de37043a91a9c40':function(){return 0x0;},'__wbg_static_accessor_SELF_37c5d418e4bf5819':function(){return 0x0;},'__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0':function(){const _0x57c11a=globalThis;return isNullOrUndefined(_0x57c11a)?0x0:storeExternref(_0x57c11a);},'__wbg_static_accessor_GLOBAL_88a902d13a557d07':function(){const _0x5f4f1d=global;return isNullOrUndefined(_0x5f4f1d)?0x0:storeExternref(_0x5f4f1d);},'__wbg_crypto_ed58b8e10a292839':function(_0x3c102d){const _0x9b29c0=_0x50314d;return _0x3c102d[_0x9b29c0(0x77)];},'__wbg_msCrypto_0a36e2ec3a343d26':function(_0xfdd67d){const _0x183524=_0x50314d;return _0xfdd67d[_0x183524(0xa0)];},'__wbg_getRandomValues_bcb4912f16000dc4':function(_0x3fc864,_0x14aa34){const _0x15f939=_0x50314d;try{_0x3fc864[_0x15f939(0xe6)](_0x14aa34);}catch(_0x24a86c){const _0x24076d=storeExternref(_0x24a86c);wasmInstance[_0x15f939(0x7e)][_0x15f939(0xa1)](_0x24076d);}},'__wbg_randomFillSync_ab2cfe79ebbf2740':function(_0xfa2fd4,_0x582c52){const _0x4a7d46=_0x50314d;try{_0xfa2fd4[_0x4a7d46(0xa2)](_0x582c52);}catch(_0xcf17e3){const _0x47b5d5=storeExternref(_0xcf17e3);wasmInstance[_0x4a7d46(0x7e)][_0x4a7d46(0xa1)](_0x47b5d5);}},'__wbg_new_a12002a7f91c75be':function(_0x32868c){return new Uint8Array(_0x32868c);},'__wbg_newwithlength_a381634e90c276d4':function(_0x4815ed){return new Uint8Array(_0x4815ed>>>0x0);},'__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a':function(_0x181d53,_0x307f46,_0x58bd23){return new Uint8Array(_0x181d53,_0x307f46>>>0x0,_0x58bd23>>>0x0);},'__wbg_subarray_aa9065fa9dc5df96':function(_0x48d93b,_0x3ce9f9,_0x3f12e9){const _0x15da0e=_0x50314d;return _0x48d93b[_0x15da0e(0x91)](_0x3ce9f9>>>0x0,_0x3f12e9>>>0x0);},'__wbg_set_37837023f3d740e8':function(_0x16c209,_0x4a52da,_0x1e5651){_0x16c209[_0x4a52da>>>0x0]=_0x1e5651;},'__wbg_new0_f788a2397c7ca929':function(){return new Date();},'__wbg_getTime_46267b1c24877e30':function(_0x354b89){return _0x354b89['getTime']();},'__wbg_new_405e22f390576ce2':function(){return{};},'__wbg_new_78feb108b6472713':function(){return[];},'__wbg_set_3f1d0b984ed272ed':function(_0x28d2c9,_0x17070b,_0x59d377){_0x28d2c9[_0x17070b]=_0x59d377;},'__wbg_new_5e0be73521bc8c17':function(){return new Map();},'__wbg_set_8fc6bf8a5b1071d1':function(_0x4bc920,_0x1da8fe,_0x462547){const _0x1ed899=_0x50314d;return _0x4bc920[_0x1ed899(0x98)](_0x1da8fe,_0x462547);},'__wbg_set_65595bdd868b3009':function(_0x1e369d,_0x33c6fd,_0x4a7d05){const _0x15e5d1=_0x50314d;_0x1e369d[_0x15e5d1(0x98)](_0x33c6fd,_0x4a7d05>>>0x0);},'__wbg_require_79b1e9274cde3c87':function(){const _0x5e247d=_0x50314d;try{return function(){return require;}['apply'](this,arguments);}catch(_0xe4ab49){const _0x48012e=storeExternref(_0xe4ab49);wasmInstance[_0x5e247d(0x7e)][_0x5e247d(0xa1)](_0x48012e);}},'__wbg_process_5c1d670bc53614b8':function(_0x5d7f96){const _0x5987df=_0x50314d;return _0x5d7f96[_0x5987df(0x83)];},'__wbg_versions_c71aa1626a93e0a1':function(_0x469e75){return _0x469e75['versions'];},'__wbg_node_02999533c4ea02e3':function(_0x193b87){const _0x539e3f=_0x50314d;return _0x193b87[_0x539e3f(0xc0)];},'__wbindgen_is_object':function(_0x13bac8){return typeof _0x13bac8==='object'&&_0x13bac8!==null?0x1:0x0;},'__wbindgen_is_string':function(_0x33d1ec){const _0xcc0c19=_0x50314d;return typeof _0x33d1ec===_0xcc0c19(0xbf)?0x1:0x0;},'__wbindgen_is_undefined':function(_0x59b692){const _0x4b18e0=_0x50314d;return typeof _0x59b692===_0x4b18e0(0x80)?0x1:0x0;},'__wbindgen_is_function':function(_0x44d14a){const _0x426f49=_0x50314d;return typeof _0x44d14a===_0x426f49(0xc6)?0x1:0x0;},'__wbindgen_number_new':function(_0x550a96){return _0x550a96;},'__wbindgen_bigint_from_i64':function(_0x3662d9){return BigInt(_0x3662d9);},'__wbindgen_bigint_from_u64':function(_0x596cf8){const _0x4bd68d=_0x50314d;return BigInt[_0x4bd68d(0xbc)](0x40,_0x596cf8);},'__wbindgen_init_externref_table':function(){const _0x40d7ac=_0x50314d;initExternrefTable(wasmInstance[_0x40d7ac(0x7e)]);},'__wbindgen_debug_string':function(_0x4bd67b,_0x2574f3){const _0x3627fc=_0x50314d;function _0x4454b6(_0x4e8213){const _0x1b4c51=a0_0x186b,_0x47db8a=typeof _0x4e8213;if(_0x47db8a===_0x1b4c51(0x92)||_0x47db8a==='boolean'||_0x4e8213==null)return''+_0x4e8213;if(_0x47db8a===_0x1b4c51(0xbf))return'\x22'+_0x4e8213+'\x22';if(_0x47db8a===_0x1b4c51(0x99)){const _0x54b147=_0x4e8213[_0x1b4c51(0xa6)];return _0x54b147==null?'Symbol':_0x1b4c51(0xd4)+_0x54b147+')';}if(_0x47db8a===_0x1b4c51(0xc6)){const _0x1eaed1=_0x4e8213[_0x1b4c51(0x88)];return typeof _0x1eaed1==='string'&&_0x1eaed1[_0x1b4c51(0xee)]>0x0?'Function('+_0x1eaed1+')':'Function';}if(Array[_0x1b4c51(0x78)](_0x4e8213)){const _0x2186e6=_0x4e8213['length'];let _0x14187a='[';_0x2186e6>0x0&&(_0x14187a+=_0x4454b6(_0x4e8213[0x0]));for(let _0x103a04=0x1;_0x103a04<_0x2186e6;_0x103a04++){_0x14187a+=',\x20'+_0x4454b6(_0x4e8213[_0x103a04]);}return _0x14187a+']';}const _0x3d4b63=Object[_0x1b4c51(0xaa)][_0x1b4c51(0xcc)][_0x1b4c51(0xb3)](_0x4e8213),_0x4aaed8=/\[object ([^\]]+)\]/['exec'](_0x3d4b63);if(!_0x4aaed8||_0x4aaed8[_0x1b4c51(0xee)]<=0x1)return _0x3d4b63;const _0x343210=_0x4aaed8[0x1];if(_0x343210===_0x1b4c51(0x7c))try{return _0x1b4c51(0xb2)+JSON['stringify'](_0x4e8213)+')';}catch(_0x3c2ac5){return _0x1b4c51(0x7c);}if(_0x4e8213 instanceof Error)return _0x4e8213[_0x1b4c51(0x88)]+':\x20'+_0x4e8213[_0x1b4c51(0x87)]+'\x0a'+_0x4e8213[_0x1b4c51(0xf4)];return _0x343210;}const _0x4ced79=_0x4454b6(_0x2574f3),_0xae44e7=encodeString(_0x4ced79,wasmInstance[_0x3627fc(0x7e)][_0x3627fc(0x71)],wasmInstance[_0x3627fc(0x7e)][_0x3627fc(0xc2)]),_0x42be77=writtenBytes;getDataView()['setInt32'](_0x4bd67b+0x4,_0x42be77,!![]),getDataView()[_0x3627fc(0xe2)](_0x4bd67b+0x0,_0xae44e7,!![]);},'__wbg_newnoargs_105ed471475aaf50':function(_0x4b7215,_0x5e016b){return Function(decodeString(_0x4b7215,_0x5e016b));},'__wbindgen_exn_store':function(_0xd7ddcb){const _0x53a747=_0x50314d;console[_0x53a747(0xe9)](_0x53a747(0xf2),_0xd7ddcb),!wasmInstance[_0x53a747(0x7e)]['__wbindgen_exn_store']&&(wasmInstance[_0x53a747(0x7e)][_0x53a747(0xa1)]=function(_0x3d8b64){const _0x895831=_0x53a747;console[_0x895831(0xe9)](_0x895831(0xae),_0x3d8b64);});}}};wasmModule=await WebAssembly[_0x50314d(0x94)](_0x358ad3),wasmInstance=await WebAssembly[_0x50314d(0xad)](wasmModule,_0x562fa2);typeof wasmInstance['exports'][_0x50314d(0xa8)]==='function'&&wasmInstance[_0x50314d(0x7e)][_0x50314d(0xa8)]();wasmInitialized=!![],console['error'](_0x50314d(0xf7));const _0x5427e9=Object[_0x50314d(0x74)](wasmInstance[_0x50314d(0x7e)]);return console[_0x50314d(0xa3)]('WASM导出的函数:',_0x5427e9),wasmInstance[_0x50314d(0x7e)];}catch(_0x10270f){console[_0x50314d(0xa3)](_0x50314d(0x90),_0x10270f);if(_0x10270f instanceof WebAssembly[_0x50314d(0xc1)])console[_0x50314d(0xa3)]('WebAssembly编译错误,可能是WASM文件格式不兼容');else{if(_0x10270f instanceof WebAssembly[_0x50314d(0x7d)]){console[_0x50314d(0xa3)]('WebAssembly链接错误,可能是缺少必要的导入函数');const _0x56354d=_0x10270f[_0x50314d(0x87)][_0x50314d(0x79)](/Import #\d+ module="([^"]+)" function="([^"]+)"/);if(_0x56354d){const [_0x4f7aba,_0x1d4160,_0x272baa]=_0x56354d;console[_0x50314d(0xa3)](_0x50314d(0xa7)+_0x1d4160+'.'+_0x272baa),console['error'](_0x50314d(0xd2));}}else _0x10270f instanceof WebAssembly[_0x50314d(0x6f)]&&console[_0x50314d(0xa3)](_0x50314d(0xa5));}throw _0x10270f;}}async function getWasmSign(_0x19762e,_0x595b4d){const _0x2cd0be=a0_0x186b;try{const _0x3beeac=await initWasm();console['error'](_0x2cd0be(0x95)),console['error'](_0x2cd0be(0x72),_0x19762e),console['error']('URL:',_0x595b4d);if(typeof _0x3beeac['get_sign']!==_0x2cd0be(0xc6)){console[_0x2cd0be(0xa3)](_0x2cd0be(0x93));const _0x179780=Object['keys'](_0x3beeac)[_0x2cd0be(0xc7)](_0x18a96c=>_0x18a96c[_0x2cd0be(0xde)]()[_0x2cd0be(0xed)](_0x2cd0be(0xdb))||_0x18a96c['toLowerCase']()[_0x2cd0be(0xed)](_0x2cd0be(0xdd)));_0x179780['length']>0x0&&console[_0x2cd0be(0xa3)]('可能的签名函数:',_0x179780);throw new Error('WASM模块缺少所需函数');}const _0x1537c4=encodeString(_0x19762e,_0x3beeac[_0x2cd0be(0x71)],_0x3beeac[_0x2cd0be(0xc2)]),_0x128398=writtenBytes,_0x4059b4=encodeString(_0x595b4d,_0x3beeac[_0x2cd0be(0x71)],_0x3beeac[_0x2cd0be(0xc2)]),_0x4a1019=writtenBytes;console[_0x2cd0be(0xa3)](_0x2cd0be(0xba));const _0x583119=_0x3beeac['get_sign'](_0x1537c4,_0x128398,_0x4059b4,_0x4a1019);if(!_0x583119)throw new Error(_0x2cd0be(0xa9));return console[_0x2cd0be(0xa3)](_0x2cd0be(0xd7),_0x583119),_0x583119;}catch(_0x298be4){console[_0x2cd0be(0xa3)](_0x2cd0be(0xf0),_0x298be4);throw _0x298be4;}}class ApiSignatureGenerator{static async[a0_0x18f407(0x7b)](_0xc3de70,_0x24f009,_0x51b4d8=null,_0x5bdd6b=null){const _0x625f83=a0_0x18f407,_0x2a5847={'method':_0x625f83(0xf8),'url':_0x24f009},_0x744387=JSON['stringify'](_0xc3de70),_0x427dda={'body':_0x744387,'url':_0x24f009},_0x3a0fe9=_0x51b4d8!==null?_0x51b4d8:C()()[_0x625f83(0xa4)](_0x625f83(0x82))['unix'](),_0x21b718=_0x5bdd6b!==null?_0x5bdd6b:(0x0,E['Ak'])(),_0x4f0de9=Object['keys'](_0xc3de70)[_0x625f83(0xee)]>0x0?O(_0x2a5847,_0x427dda):'';if(_0x24f009&&_0x24f009[_0x625f83(0xed)](_0x625f83(0xec))){console[_0x625f83(0xa3)]('\x0a===\x20检测到/v2/chat请求,使用WASM生成签名\x20===');try{const _0x249018=await getWasmSign(_0x4f0de9,_0x24f009);return Object[_0x625f83(0xb5)](_0x249018);}catch(_0x102add){console['error']('WASM签名生成失败,回退到标准签名:',_0x102add);}}const _0x58267e=S()(''[_0x625f83(0xcd)](_0x3a0fe9)[_0x625f83(0xcd)](_0x4f0de9)[_0x625f83(0xcd)](_0x21b718))[_0x625f83(0xc5)]();return console[_0x625f83(0xa3)]('时间戳:',_0x3a0fe9),console[_0x625f83(0xa3)](_0x625f83(0xb0),_0x21b718),console[_0x625f83(0xa3)](_0x625f83(0xac),_0x4f0de9),console['error'](_0x625f83(0xd8),_0x58267e),{'timestamp':_0x3a0fe9,'nonce':_0x21b718,'sign':_0x58267e};}}async function sendRequest(_0xba114d,_0x5e743d,_0x513387){const _0x212a26=a0_0x18f407,_0x448bd8=await ApiSignatureGenerator['generateSignature'](_0x513387,_0x5e743d);return console[_0x212a26(0xe9)](_0x212a26(0xdf)),console[_0x212a26(0xe9)](_0x212a26(0xda),_0x5e743d),console[_0x212a26(0xe9)]('请求参数:',JSON[_0x212a26(0xd0)](_0x513387)),console[_0x212a26(0xe9)]('签名信息:',_0x448bd8),console[_0x212a26(0xe9)](_0x212a26(0xbb),_0x448bd8[_0x212a26(0xdb)]),fetch(_0x5e743d,{'headers':{'accept':_0x212a26(0x9c),'accept-language':_0x212a26(0x8f),'apptype':'6','appversion':_0x212a26(0x8d),'client-ver':_0x212a26(0xe5),'content-type':_0x212a26(0xe8),'deviceid':_0xba114d,'lang':'zh','nonce':_0x448bd8[_0x212a26(0x73)],'sign':_0x448bd8[_0x212a26(0xdb)],'timestamp':String(_0x448bd8['timestamp']),'User-Agent':'Mozilla/5.0\x20(Windows\x20NT\x2010.0;\x20Win64;\x20x64)\x20AppleWebKit/537.36\x20(KHTML,\x20like\x20Gecko)\x20Chrome/125.0.0.0\x20Safari/537.36','Referer':_0x212a26(0xcb)},'body':JSON[_0x212a26(0xd0)](_0x513387),'method':_0x212a26(0xf8)})[_0x212a26(0xab)](_0x38f0be=>{const _0x5a636c=_0x212a26;return console['error']('API响应状态:',_0x38f0be['status']),_0x38f0be[_0x5a636c(0xe1)]();})[_0x212a26(0xab)](_0x1300ec=>{const _0x55d9cf=_0x212a26;return console['error'](_0x55d9cf(0x76),_0x1300ec),_0x1300ec;})[_0x212a26(0x75)](_0x31f0a7=>{const _0x1d8044=_0x212a26;console[_0x1d8044(0xa3)](_0x1d8044(0xce),_0x31f0a7);throw _0x31f0a7;});}async function main(){const _0x47961b=a0_0x18f407;try{const _0x12a5c1=process[_0x47961b(0xd1)]['slice'](0x2);_0x12a5c1[_0x47961b(0xee)]<0x2&&(console[_0x47961b(0xa3)](_0x47961b(0xe3)),process['exit'](0x1));const _0x2618b6=JSON[_0x47961b(0x6c)](_0x12a5c1[0x0]),_0x23453=_0x12a5c1[0x1];console[_0x47961b(0xa3)](_0x47961b(0xb9)),console['error'](_0x47961b(0x9f)+JSON[_0x47961b(0xd0)](_0x2618b6)[_0x47961b(0xf5)](0x0,0x64)+_0x47961b(0xd9)),console['error']('-\x20URL:\x20'+_0x23453);const _0x2a3dfc=await ApiSignatureGenerator[_0x47961b(0x7b)](_0x2618b6,_0x23453);console['log'](JSON['stringify'](_0x2a3dfc));}catch(_0x28317b){console['error']('错误:',_0x28317b),process['exit'](0x1);}}main();export{ApiSignatureGenerator};
main.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ # 简化版入口文件 - 直接加载openapi.pyc中的app对象
4
+ import importlib.util
5
+ import os
6
+ import sys
7
+ import traceback
8
+
9
+ # 将当前目录添加到Python路径
10
+ sys.path.insert(0, os.path.abspath('.'))
11
+
12
+ def load_pyc(name, path):
13
+ '''加载一个.pyc文件'''
14
+ print(f"加载模块: {name} 从 {path}")
15
+ try:
16
+ spec = importlib.util.spec_from_file_location(name, path)
17
+ if not spec:
18
+ print(f"错误: 无法为 {path} 创建规范")
19
+ return None
20
+
21
+ module = importlib.util.module_from_spec(spec)
22
+ sys.modules[name] = module # 将模块添加到sys.modules中
23
+ spec.loader.exec_module(module)
24
+ print(f"成功加载模块: {name}")
25
+ return module
26
+ except Exception as e:
27
+ print(f"加载模块 {name} 失败: {str(e)}")
28
+ traceback.print_exc()
29
+ return None
30
+
31
+ def main():
32
+ '''主函数 - 加载openapi.pyc并运行FastAPI应用'''
33
+ print("===== 当贝AI OpenAI代理启动 =====")
34
+ print(f"当前目录: {os.getcwd()}")
35
+
36
+ # 列出目录内容
37
+ files = os.listdir(".")
38
+ print(f"目录内容: {', '.join([f for f in files if f.endswith('.pyc') or f == 'main.py'])}")
39
+
40
+ # 加载openapi.pyc
41
+ openapi_path = "openapi.pyc"
42
+ if not os.path.exists(openapi_path):
43
+ print(f"错误: 找不到{openapi_path}文件")
44
+ return 1
45
+
46
+ print(f"加载{openapi_path}...")
47
+ openapi = load_pyc("openapi", openapi_path)
48
+
49
+ if not openapi:
50
+ print("错误: 无法加载openapi模块")
51
+ return 1
52
+
53
+ if not hasattr(openapi, "app"):
54
+ print("错误: openapi模块中未找到app对象")
55
+ print(f"可用属性: {', '.join(dir(openapi))}")
56
+ return 1
57
+
58
+ print("找到openapi.app,准备启动服务器")
59
+
60
+ try:
61
+ import uvicorn
62
+ # 从环境变量获取端口,默认为7860
63
+ port = int(os.environ.get("PORT", 7860))
64
+ host = os.environ.get("HOST", "0.0.0.0")
65
+ print(f"在{host}:{port}上启动服务...")
66
+ uvicorn.run(openapi.app, host=host, port=port)
67
+ return 0
68
+ except Exception as e:
69
+ print(f"启动服务器失败: {str(e)}")
70
+ traceback.print_exc()
71
+ return 1
72
+
73
+ if __name__ == "__main__":
74
+ sys.exit(main())
openapi.pyc ADDED
Binary file (54.9 kB). View file
 
package.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "dangbei-proxy",
3
+ "version": "1.0.0",
4
+ "description": "当贝AI OpenAI兼容API",
5
+ "main": "getSign.js",
6
+ "type": "module",
7
+ "dependencies": {
8
+ "crypto": "^1.0.1"
9
+ },
10
+ "scripts": {
11
+ "start": "node getSign.js"
12
+ }
13
+ }
pyc_loader.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ # pyc文件加载器
4
+ import sys
5
+ import os
6
+ import importlib.util
7
+
8
+ # 确保当前目录在Python路径中
9
+ current_dir = os.path.dirname(os.path.abspath(__file__))
10
+ if current_dir not in sys.path:
11
+ sys.path.insert(0, current_dir)
12
+
13
+ def load_pyc(pyc_file):
14
+ # 加载一个.pyc文件
15
+ if not os.path.exists(pyc_file):
16
+ print(f"错误: 文件 {pyc_file} 不存在")
17
+ return None
18
+
19
+ try:
20
+ module_name = os.path.splitext(os.path.basename(pyc_file))[0]
21
+ spec = importlib.util.spec_from_file_location(module_name, pyc_file)
22
+ if spec is None:
23
+ print(f"错误: 无法为 {pyc_file} 创建规范")
24
+ return None
25
+
26
+ module = importlib.util.module_from_spec(spec)
27
+ sys.modules[module_name] = module
28
+ spec.loader.exec_module(module)
29
+ return module
30
+ except Exception as e:
31
+ print(f"加载 {pyc_file} 失败: {e}")
32
+ return None
33
+
34
+ def main():
35
+ # 命令行入口点
36
+ if len(sys.argv) < 2:
37
+ print("用法: python pyc_loader.py <pyc文件> [函数名]")
38
+ return 1
39
+
40
+ pyc_file = sys.argv[1]
41
+ function_name = sys.argv[2] if len(sys.argv) > 2 else "main"
42
+
43
+ module = load_pyc(pyc_file)
44
+ if not module:
45
+ return 1
46
+
47
+ if hasattr(module, function_name):
48
+ func = getattr(module, function_name)
49
+ if callable(func):
50
+ return func()
51
+ else:
52
+ print(f"错误: {function_name} 不是一个可调用函数")
53
+ return 1
54
+ else:
55
+ print(f"错误: 模块中没有 {function_name} 函数")
56
+ return 1
57
+
58
+ if __name__ == "__main__":
59
+ sys.exit(main())
requirements.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ fastapi>=0.105.0
2
+ uvicorn>=0.27.0
3
+ pydantic>=2.5.3
4
+ requests>=2.31.0
5
+ httpx>=0.26.0
6
+ h2>=4.1.0
7
+ playwright>=1.40.0
8
+ python-multipart>=0.0.9
9
+ asyncio>=3.4.3
sign_bg.ebde2702.wasm ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2115c4b8fb76254afdf9e91da64428ecb0b54a1aad0f3936c50073eca8e4a832
3
+ size 86614
start.sh ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # 启动虚拟显示服务
4
+ Xvfb :99 -screen 0 1280x720x16 &
5
+ export DISPLAY=:99
6
+
7
+ # 确保缓存目录存在
8
+ mkdir -p /app/cache
9
+ chmod 777 /app/cache
10
+
11
+ # 检查Node.js版本
12
+ node_version=$(node -v)
13
+ echo "Node.js版本: $node_version"
14
+
15
+ # 启动应用
16
+ echo "启动应用..."
17
+ cd /app
18
+ exec uvicorn openapic:app --host 0.0.0.0 --port $PORT