dsh-podwave 0.11.6 → 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 +1 -1
- package/src/host.js +1 -1
- package/src/xyz.js +25 -1
package/package.json
CHANGED
package/src/host.js
CHANGED
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 =
|
|
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 = ''
|