MCPcopy Create free account
hub / github.com/smallfawn/QLScriptPublic / taskSignHeaders

Function taskSignHeaders

wxapp/skyworth.js:83–98  ·  view source on GitHub ↗
(data = {})

Source from the content-addressed store, hash-verified

81}
82
83function taskSignHeaders(data = {}) {
84 const payload = { ...data };
85 const nonce = uuid();
86 const timestamp = Date.now();
87 payload.nonce = nonce;
88 payload.timestamp = timestamp;
89
90 const preSign = Object.keys(payload)
91 .sort()
92 .filter((key) => key !== "taskCode" && key !== "snCode")
93 .map((key) => `${key}=${payload[key]}&`)
94 .join("");
95
96 const sign = crypto.createSign("RSA-SHA256").update(preSign).sign(TASK_PRIVATE_KEY, "base64");
97 return { sign, timestamp: String(timestamp), nonce };
98}
99
100async function request(options) {
101 const res = await axios.request({

Callers 1

completeTaskMethod · 0.85

Calls 2

uuidFunction · 0.70
signMethod · 0.45

Tested by

no test coverage detected