Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions es/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FlowApi {
apiKey: this.apiKey,
...params
};
let data = this.getPack(params, method);
let data = this.getPack(params);
let sign = this.sign(params);
let response;
if (method == "GET") {
Expand All @@ -42,7 +42,7 @@ class FlowApi {
}
});
}
getPack(params, method) {
getPack(params) {
const keys = Object.keys(params)
.map(key => key)
.sort((a, b) => {
Expand All @@ -52,13 +52,9 @@ class FlowApi {
});
let data = [];
keys.map(key => {
if (method == "GET") {
data.push(
encodeURIComponent(key) + "=" + encodeURIComponent(params[key])
);
} else {
data.push(key + "=" + params[key]);
}
data.push(
encodeURIComponent(key) + "=" + encodeURIComponent(params[key])
);
});
return data.join("&");
}
Expand All @@ -72,9 +68,9 @@ class FlowApi {
});
let toSign = [];
keys.map(key => {
toSign.push(key + "=" + params[key]);
toSign.push(key + params[key]);
});
toSign = toSign.join("&");
toSign = toSign.join("");

return CryptoJS.HmacSHA256(toSign, this.secretKey);
}
Expand Down