@@ -5,6 +5,7 @@ import { dirname, join, resolve } from 'node:path'
55const dshRoot = resolve ( process . argv [ 2 ] ?? '/usr/local/lib/node_modules/@deepseek-ai/dsh' )
66const requireFromDsh = createRequire ( join ( dshRoot , 'package.json' ) )
77const flag = 'globalThis.__DSH_AUTHENTICATED_SETTINGS__ === true'
8+ const proxyAuthFlag = 'process.env.ONEPANEL_DSH_AUTH_PROXY === "1"'
89
910async function packageRoot ( name ) {
1011 const manifestPath = requireFromDsh . resolve ( `${ name } /package.json` )
@@ -28,18 +29,25 @@ const settingsPath = join(
2829let settings = await readFile ( settingsPath , 'utf8' )
2930settings = replaceOnce (
3031 settings ,
31- 'new SettingsScopeController(connection.api, spec, this.mirror, connection.isLoopback ? "host" : "memory", this.schema)' ,
32- `new SettingsScopeController(connection.api, spec, this.mirror, connection.isLoopback || ${ flag } ? "host" : "memory", this.schema)` ,
33- 'settings scope' ,
34- )
35- settings = replaceOnce (
36- settings ,
37- 'new SettingsDescribeMirror(connection.api, connection.isLoopback ? "host" : "memory")' ,
38- `new SettingsDescribeMirror(connection.api, connection.isLoopback || ${ flag } ? "host" : "memory")` ,
39- 'settings mirror' ,
32+ 'const persistence = ctx.remote.$host.isLoopback ? "host" : "memory";' ,
33+ `const persistence = ctx.remote.$host.isLoopback || ${ flag } ? "host" : "memory";` ,
34+ 'settings persistence' ,
4035)
4136await writeFile ( settingsPath , settings , 'utf8' )
4237
38+ const connectionPath = join (
39+ await packageRoot ( '@deepseek-ai/dsh-client-connection' ) ,
40+ 'lib/index.js' ,
41+ )
42+ let connection = await readFile ( connectionPath , 'utf8' )
43+ connection = replaceOnce (
44+ connection ,
45+ 'isAuthenticated(request) {\n\t\tconst authority = requestAuthority(request.headers);' ,
46+ `isAuthenticated(request) {\n\t\tif (${ proxyAuthFlag } ) return true;\n\t\tconst authority = requestAuthority(request.headers);` ,
47+ 'browser proxy authentication' ,
48+ )
49+ await writeFile ( connectionPath , connection , 'utf8' )
50+
4351const frontendPath = join (
4452 await packageRoot ( '@deepseek-ai/dsh-web-frontend' ) ,
4553 'dist/index.html' ,
@@ -53,6 +61,10 @@ if (moduleScripts.length !== 1 || frontend.includes(bootstrap)) {
5361frontend = frontend . replace ( moduleScripts [ 0 ] , ` ${ bootstrap } \n${ moduleScripts [ 0 ] } ` )
5462await writeFile ( frontendPath , frontend , 'utf8' )
5563
56- if ( ( settings . split ( flag ) . length - 1 ) !== 2 || ! frontend . includes ( `${ bootstrap } \n${ moduleScripts [ 0 ] } ` ) ) {
64+ if (
65+ ( settings . split ( flag ) . length - 1 ) !== 1 ||
66+ ( connection . split ( proxyAuthFlag ) . length - 1 ) !== 1 ||
67+ ! frontend . includes ( `${ bootstrap } \n${ moduleScripts [ 0 ] } ` )
68+ ) {
5769 throw new Error ( 'authenticated settings patch verification failed' )
5870}
0 commit comments