mirror of
https://github.com/GMGNAI/gmgn-skills.git
synced 2026-07-27 16:57:44 +00:00
fix(signer): percent-encode query params in buildMessage to match server
Server's CanonicalQueryString uses url.QueryEscape on all keys and values, but buildMessage was using raw string interpolation. Cursor values (base64) contain +, =, / which diverge under encoding — causing 401 on all paginated signed requests (e.g. portfolio holdings page 2+). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -44,11 +44,12 @@ export function buildMessage(
|
||||
const sortedQs = Object.keys(queryParams)
|
||||
.sort()
|
||||
.flatMap((k) => {
|
||||
const ek = encodeURIComponent(k);
|
||||
const v = queryParams[k];
|
||||
if (Array.isArray(v)) {
|
||||
return [...v].sort().map((item) => `${k}=${item}`);
|
||||
return [...v].sort().map((item) => `${ek}=${encodeURIComponent(item)}`);
|
||||
}
|
||||
return [`${k}=${v}`];
|
||||
return [`${ek}=${encodeURIComponent(String(v))}`];
|
||||
})
|
||||
.join("&");
|
||||
return `${subPath}:${sortedQs}:${body}:${timestamp}`;
|
||||
|
||||
Reference in New Issue
Block a user