MCPcopy Create free account
hub / github.com/smallfawn/QLScriptPublic / parseAccount

Function parseAccount

wxapp/wps.js:114–138  ·  view source on GitHub ↗
(raw)

Source from the content-addressed store, hash-verified

112}
113
114function parseAccount(raw) {
115 const text = String(raw || "").trim();
116 if (!text) return { openid: "", cookie: "", secret: "" };
117
118 if (text.startsWith("{")) {
119 try {
120 const data = JSON.parse(text);
121 return {
122 openid: data.openid || data.openId || data.account || "",
123 cookie: data.cookie || data.Cookie || "",
124 secret: data.secret || data.jsrsasign_secret || "",
125 };
126 } catch {}
127 }
128
129 for (const sep of ["#", "|"]) {
130 if (text.includes(sep)) {
131 const [openid, cookie, secret] = text.split(sep);
132 return { openid: openid.trim(), cookie: (cookie || "").trim(), secret: (secret || "").trim() };
133 }
134 }
135
136 if (text.includes("wps_sid=") || text.includes("kso_sid=")) return { openid: "", cookie: text, secret: "" };
137 return { openid: text, cookie: "", secret: "" };
138}
139
140function canonicalJson(data = {}) {
141 const sorted = {};

Callers 1

constructorMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected