Skip to content

Commit

Permalink
update: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
windingwind committed Aug 21, 2023
1 parent 374b089 commit f54b2f6
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/modules/services/aliyun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@ export default <TranslateTaskProcessor>async function (data) {
return str.split("-")[0];
}

const encodedBody = `AccessKeyId=${accessKeyId
}&Action=TranslateGeneral&Format=JSON&FormatType=text&SignatureMethod=HMAC-SHA1&SignatureNonce=${encodeURIComponent(randomString(12))
}&SignatureVersion=1.0&SourceLanguage=auto&SourceText=${encodeURIComponent(data.raw)
}&TargetLanguage=${languageCode(data.langto)}&Timestamp=${encodeURIComponent(new Date().toISOString())
}&Version=2018-10-12`;
const encodedBody = `AccessKeyId=${accessKeyId}&Action=TranslateGeneral&Format=JSON&FormatType=text&SignatureMethod=HMAC-SHA1&SignatureNonce=${encodeURIComponent(
randomString(12),
)}&SignatureVersion=1.0&SourceLanguage=auto&SourceText=${encodeURIComponent(
data.raw,
)}&TargetLanguage=${languageCode(data.langto)}&Timestamp=${encodeURIComponent(
new Date().toISOString(),
)}&Version=2018-10-12`;

const stringToSign = `POST&%2F&${encodeURIComponent(encodedBody)}`;

const signature = base64(await hmacSha1Digest(stringToSign, `${accessKeySecret}&`));
const signature = base64(
await hmacSha1Digest(stringToSign, `${accessKeySecret}&`),
);

const xhr = await Zotero.HTTP.request("POST", "https://mt.aliyuncs.com/", {
headers: {
Expand Down

0 comments on commit f54b2f6

Please sign in to comment.