Skip to content

Commit

Permalink
fix message for sig add query params
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarnadas committed Feb 22, 2024
1 parent 614d3cd commit f8ae23e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions api/py/src/signer.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ def sign_request(self, req: Request) -> PreparedRequest:
if req.json is not None:
json_str = json.dumps(req.json)

path = urllib.parse.urlparse(req.url).path
message = str(timestamp) + req.method + path + json_str
url = urllib.parse.urlparse(req.url)
message = str(timestamp) + req.method + url.path + json_str
if len(url.query) > 0:
message += "?" + url.query

orderly_signature = urlsafe_b64encode(
self._key_pair.sign(message.encode())
).decode("utf-8")
Expand Down
2 changes: 1 addition & 1 deletion api/ts/src/signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export async function signAndSendRequest(
const encoder = new TextEncoder();

const url = new URL(input);
let message = `${String(timestamp)}${init?.method ?? 'GET'}${url.pathname}`;
let message = `${String(timestamp)}${init?.method ?? 'GET'}${url.pathname}${url.search}`;
if (init?.body) {
message += init.body;
}
Expand Down

0 comments on commit f8ae23e

Please sign in to comment.