dsh-podwave 0.11.7 → 0.11.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-podwave",
3
- "version": "0.11.7",
3
+ "version": "0.11.8",
4
4
  "description": "DeepSeek Harness 插件:本地优先的播客播放器 + 转写 + 双语字幕 + 字幕翻译。",
5
5
  "type": "module",
6
6
  "main": "./src/host.js",
package/src/host.js CHANGED
@@ -454,7 +454,7 @@ async function route(ctx, req, res) {
454
454
  return json(res, 200, {
455
455
  ok: true,
456
456
  generatedAt: new Date().toISOString(),
457
- version: '0.11.7',
457
+ version: '0.11.8',
458
458
  platform,
459
459
  engine: recommendEngine(platform),
460
460
  paths: {
package/src/xyz.js CHANGED
@@ -179,8 +179,32 @@ export async function loginWithSms(phone, code, areaCode = '+86') {
179
179
  return xyzStatus()
180
180
  }
181
181
 
182
+ export function normalizeTokenInput(raw) {
183
+ const text = String(raw || '').trim()
184
+ if (!text) return ''
185
+ if (text.startsWith('{') || text.startsWith('[')) {
186
+ try {
187
+ const parsed = JSON.parse(text)
188
+ const keys = ['x-jike-refresh-token', 'refreshToken', 'refresh_token', 'x-jike-access-token', 'accessToken', 'access_token', 'token']
189
+ for (const key of keys) {
190
+ const value = parsed?.[key] ?? parsed?.headers?.[key]
191
+ if (typeof value === 'string' && value.trim()) return value.trim()
192
+ }
193
+ } catch {
194
+ /* not JSON, fall through */
195
+ }
196
+ }
197
+ const headerMatch = /x-jike-(?:refresh|access)-token\s*[:=]\s*["']?([^\s,;"'}]+)/i.exec(text)
198
+ if (headerMatch) return headerMatch[1]
199
+ let value = text.replace(/^bearer\s+/i, '')
200
+ const lines = value.split(/\r?\n/).map((line) => line.trim()).filter(Boolean)
201
+ if (lines.length) value = lines[lines.length - 1]
202
+ return value.replace(/^["']|["']$/g, '').replace(/[;,]+$/, '')
203
+ }
204
+
182
205
  export async function loginWithRefreshToken(refreshTokenValue, deviceId = '') {
183
- const value = String(refreshTokenValue || '').trim()
206
+ const value = normalizeTokenInput(refreshTokenValue)
207
+ if (!value) throw new Error('请粘贴 refresh token 或 access token')
184
208
  config.refreshToken = value
185
209
  config.deviceId = String(deviceId || '').trim()
186
210
  config.accessToken = ''