@waterplus-ai/waterbuddy 0.1.10 → 0.1.12

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/lib/host/index.js CHANGED
@@ -38,13 +38,17 @@ function clearPersistedAuth() {
38
38
  try { fs.rmSync(authFile, { force: true }) } catch {}
39
39
  }
40
40
 
41
+ function isSupportedAvatarUrl(url) {
42
+ return (url.protocol === 'http:' || url.protocol === 'https:') && !url.username && !url.password
43
+ }
44
+
41
45
  function normalizeAvatar(value) {
42
46
  if (typeof value !== 'string' || !value) return undefined
43
47
  if (value.startsWith('data:')) return value
44
48
  try {
45
49
  const url = new URL(value, AI_URL)
46
- if (url.protocol !== 'https:' || url.host !== new URL(AI_URL).host) return undefined
47
- return `/api/waterbuddy/avatar?url=${encodeURIComponent(url.href)}`
50
+ if (!isSupportedAvatarUrl(url)) return undefined
51
+ return url.href
48
52
  } catch { return undefined }
49
53
  }
50
54
 
@@ -143,15 +147,13 @@ async function proxyAvatar(req, res) {
143
147
  const value = new URL(req.url, 'http://127.0.0.1').searchParams.get('url')
144
148
  let target
145
149
  try { target = new URL(value) } catch { return json(res, 400, { error: 'invalid-avatar-url' }) }
146
- if (target.protocol !== 'https:' || target.host !== new URL(AI_URL).host) return json(res, 403, { error: 'avatar-host-not-allowed' })
147
- const response = await fetch(target)
148
- if (!response.ok || !response.body) return json(res, response.status || 502, { error: 'avatar-fetch-failed' })
149
- res.writeHead(response.status, { 'content-type': response.headers.get('content-type') || 'image/jpeg', 'cache-control': 'private, max-age=3600' })
150
- for await (const chunk of response.body) res.write(chunk)
150
+ if (!isSupportedAvatarUrl(target)) return json(res, 400, { error: 'avatar-url-not-supported' })
151
+ res.writeHead(302, { location: target.href, 'cache-control': 'private, max-age=3600' })
151
152
  res.end()
152
153
  }
153
154
 
154
155
  export const inject = ['webServer', 'systemPrompt']
156
+ export { normalizeAvatar }
155
157
 
156
158
  export function apply(ctx) {
157
159
  readPersistedAuth()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@waterplus-ai/waterbuddy",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "WaterBuddy branding and Web profile bundle for DeepSeek Harness",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",