| 88 | } |
| 89 | |
| 90 | function parseAccount(raw) { |
| 91 | const text = String(raw || "").trim(); |
| 92 | if (!text) return {}; |
| 93 | |
| 94 | if (text.startsWith("{")) { |
| 95 | try { |
| 96 | const data = JSON.parse(text); |
| 97 | return { |
| 98 | openid: data.openid || data.openId || data.account || "", |
| 99 | ticket: data.ticket || data.auth || "", |
| 100 | duid: data.duid || "", |
| 101 | udl: data.udl || "", |
| 102 | }; |
| 103 | } catch {} |
| 104 | } |
| 105 | |
| 106 | for (const sep of ["#", "|"]) { |
| 107 | if (text.includes(sep)) { |
| 108 | const [openid, ticket, duid, udl] = text.split(sep).map((v) => v.trim()); |
| 109 | return { openid, ticket, duid, udl }; |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | if (/^[A-Z0-9]{48,}$/i.test(text) && !/^o[A-Za-z0-9_-]{20,}$/.test(text)) { |
| 114 | return { ticket: text }; |
| 115 | } |
| 116 | return { openid: text }; |
| 117 | } |
| 118 | |
| 119 | function okResponseStatus(data) { |
| 120 | return data?.ResponseStatus?.Ack === "Success" || data?.responseStatus?.ack === "Success"; |