|
@@ -329,21 +329,28 @@ function delay(time) {
|
|
|
function calculateDigest(body, sk) {
|
|
function calculateDigest(body, sk) {
|
|
|
const CryptoJS = createCryptoJS();
|
|
const CryptoJS = createCryptoJS();
|
|
|
const signature = CryptoJS.HmacSHA256(body, sk);
|
|
const signature = CryptoJS.HmacSHA256(body, sk);
|
|
|
|
|
+ lk.log(signature);
|
|
|
return CryptoJS.enc.Base64.stringify(signature).toString();
|
|
return CryptoJS.enc.Base64.stringify(signature).toString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function calculateSignature(method, url, ak, sk, date) {
|
|
function calculateSignature(method, url, ak, sk, date) {
|
|
|
const CryptoJS = createCryptoJS();
|
|
const CryptoJS = createCryptoJS();
|
|
|
const strToSign = `${method.toUpperCase()}\n${url}\n\n${ak}\n${date}\n`;
|
|
const strToSign = `${method.toUpperCase()}\n${url}\n\n${ak}\n${date}\n`;
|
|
|
|
|
+ lk.log(strToSign);
|
|
|
const signature = CryptoJS.HmacSHA256(strToSign, sk);
|
|
const signature = CryptoJS.HmacSHA256(strToSign, sk);
|
|
|
|
|
+ lk.log(signature);
|
|
|
return CryptoJS.enc.Base64.stringify(signature).toString();
|
|
return CryptoJS.enc.Base64.stringify(signature).toString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function buildHeader(method, url, body) {
|
|
function buildHeader(method, url, body) {
|
|
|
const nowDate = new Date();
|
|
const nowDate = new Date();
|
|
|
const date = lk.formatDate(nowDate, 'ddd, DD MMM YYYY HH:mm:ss [GMT]');
|
|
const date = lk.formatDate(nowDate, 'ddd, DD MMM YYYY HH:mm:ss [GMT]');
|
|
|
|
|
+ lk.log(`==============================`);
|
|
|
const signature = calculateSignature(method, url, AK, SK, date);
|
|
const signature = calculateSignature(method, url, AK, SK, date);
|
|
|
|
|
+ lk.log(`signature=${signature}`);
|
|
|
|
|
+ lk.log(`==============================`);
|
|
|
const digest = calculateDigest(body, SK);
|
|
const digest = calculateDigest(body, SK);
|
|
|
|
|
+ lk.log(`digest=${digest}`);
|
|
|
const headers = {
|
|
const headers = {
|
|
|
'Content-Type': 'application/json',
|
|
'Content-Type': 'application/json',
|
|
|
'X-HMAC-SIGNATURE': signature,
|
|
'X-HMAC-SIGNATURE': signature,
|