Skip to content

Commit d61aa41

Browse files
committed
fix signing for get requests with query params
1 parent aab3e3c commit d61aa41

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/Client.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,15 @@ export class Client {
6060
return ''
6161
}
6262

63-
return isUrlencoded ? params.toString() : JSON.stringify(payload)
63+
if (isUrlencoded) {
64+
return params.toString()
65+
}
66+
67+
if (method === 'get') {
68+
return ''
69+
}
70+
71+
return JSON.stringify(payload)
6472
}
6573

6674
const timestamp = Number.parseInt((Date.now() / 1000).toString())
@@ -80,7 +88,6 @@ export class Client {
8088
hashMD5 = hashFunc.digest('hex');
8189
}
8290

83-
//const signUrl = url.split('?')[0]
8491
const toSign = [timestamp, nonce, httpVerb, url, hashMD5].join('\n')
8592

8693
const hash = new SHA('SHA-256', 'TEXT', {

0 commit comments

Comments
 (0)