@goodandready/dsh-clinebot 0.6.30 → 0.6.31

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.
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import { readFileSync, writeFileSync, renameSync, mkdirSync, existsSync, copyFileSync, readdirSync, unlinkSync } from 'node:fs'
9
- import { homedir } from 'node:os'
9
+ import { resolveDataPath, isSafeDataPath } from './path-safety.js'
10
10
  import path from 'node:path'
11
11
  import {
12
12
  latencyBucketIndex,
@@ -85,33 +85,8 @@ function localDateKey(date) {
85
85
  return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`
86
86
  }
87
87
 
88
- /** Get active .dsh directory, respecting DSH_HOME and HOME. */
89
- function getDshHome() {
90
- if (process.env.DSH_HOME) return process.env.DSH_HOME
91
- const home = process.env.HOME || homedir()
92
- return path.join(home, '.dsh')
93
- }
94
-
95
88
  export function resolvePath(targetPath) {
96
- let unwrapGuard = 0
97
- while (unwrapGuard < 5 && targetPath) {
98
- if (typeof targetPath === 'function') {
99
- try { targetPath = targetPath() } catch { targetPath = ''; break }
100
- unwrapGuard += 1
101
- } else if (typeof targetPath === 'object' && typeof targetPath.get === 'function') {
102
- try { targetPath = targetPath.get() } catch { targetPath = ''; break }
103
- unwrapGuard += 1
104
- } else {
105
- break
106
- }
107
- }
108
- if (typeof targetPath !== 'string') targetPath = ''
109
- if (!targetPath) return path.join(getDshHome(), 'clinebot-stats.json')
110
- if (targetPath.startsWith('~/') || targetPath === '~') {
111
- const home = process.env.HOME || homedir()
112
- return path.join(home, targetPath.slice(1))
113
- }
114
- return path.resolve(targetPath)
89
+ return resolveDataPath(targetPath, 'clinebot-stats.json')
115
90
  }
116
91
 
117
92
  /**
@@ -10,7 +10,7 @@ import { createRequire } from 'node:module'
10
10
  import { isSecureRemoteBaseUrl } from '../http.js'
11
11
 
12
12
  const require = createRequire(import.meta.url)
13
- let packageVersion = '0.6.30'
13
+ let packageVersion = '0.6.31'
14
14
  try {
15
15
  packageVersion = require('../../package.json').version || packageVersion
16
16
  } catch {
package/lib/updater.js CHANGED
@@ -1,4 +1,4 @@
1
- import { getConnection } from './http.js'
1
+ import { getConnection, isLoopbackAddress, isLoopbackHostname } from './http.js'
2
2
  /**
3
3
  * Host-side one-click updater for @goodandready/dsh-clinebot.
4
4
  * Conforms to the DSH authoring reference implementation.
@@ -58,12 +58,7 @@ function header(request, name) {
58
58
  return Array.isArray(value) ? value[0] : value
59
59
  }
60
60
 
61
- function isLoopback(value) {
62
- const address = value?.toLowerCase().replace(/^\[|\]$/g, '')
63
- return address === 'localhost' || address === 'localhost.' || address === '::1'
64
- || address?.startsWith('127.') === true
65
- || address?.startsWith('::ffff:127.') === true
66
- }
61
+
67
62
 
68
63
  export function isTrustedUpdateRequest(request, targetCtx = null) {
69
64
  if (header(request, UPDATE_HEADER) !== '1') return false
@@ -77,7 +72,7 @@ export function isTrustedUpdateRequest(request, targetCtx = null) {
77
72
  }
78
73
  if (rejection !== undefined) return false
79
74
  }
80
- if (!isLoopback(request?.socket?.remoteAddress)) return false
75
+ if (!isLoopbackAddress(request?.socket?.remoteAddress)) return false
81
76
  const site = header(request, 'sec-fetch-site')
82
77
  if (site !== undefined && site !== 'same-origin') return false
83
78
  const origin = header(request, 'origin')
@@ -86,7 +81,7 @@ export function isTrustedUpdateRequest(request, targetCtx = null) {
86
81
  try {
87
82
  const url = new URL(origin)
88
83
  return (url.protocol === 'http:' || url.protocol === 'https:')
89
- && isLoopback(url.hostname) && url.host === host
84
+ && isLoopbackHostname(url.hostname) && url.host === host
90
85
  } catch {
91
86
  return false
92
87
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodandready/dsh-clinebot",
3
- "version": "0.6.30",
3
+ "version": "0.6.31",
4
4
  "description": "DeepSeek Harness companion for ClineBot / ClinePass: dynamic subscription models sync, quota exhaustion warnings, session metrics, dedicated settings page, live usage limits, and /cline slash-command.",
5
5
  "license": "MIT",
6
6
  "type": "module",