Skip to content

Commit

Permalink
fix(querystring): querystring path fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Erchoc committed Jul 27, 2021
1 parent e52ad91 commit eb012b2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,15 @@ class TuyaOpenApiClient {
const sortedQuery: { [k: string]: string } = {};
Object.keys(query).sort().forEach(i => sortedQuery[i] = query[i]);
const qs = querystring.stringify(sortedQuery);
const url = qs ? `${path}?${qs}` : path;
const url = qs ? `${path.split('?')[0]}?${qs}` : path;
let accessToken = await this.store.getAccessToken() || '';
if(!accessToken) {
await this.init(); // 未获取到 accessToke 时, 重新初始化
accessToken = await this.store.getAccessToken() || '';
}
const contentHash = crypto.createHash('sha256').update(JSON.stringify(body)).digest('hex');
const stringToSign = [method, contentHash, '', decodeURIComponent(url)].join('\n');
console.log(stringToSign)
const signStr = this.accessKey + accessToken + t + stringToSign;
return {
t,
Expand Down

0 comments on commit eb012b2

Please sign in to comment.