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

Function buildSignedHeaders

wxapp/feihe.js:66–93  ·  view source on GitHub ↗
({ data = null, token = "" } = {})

Source from the content-addressed store, hash-verified

64}
65
66function buildSignedHeaders({ data = null, token = "" } = {}) {
67 const headers = {
68 fhAppid: APP_ID,
69 fhNonceStr: randomString(16),
70 fhTimestamp: Math.floor(Date.now() / 1000),
71 token,
72 source: 1,
73 "Content-Type": "application/json",
74 OrderUpdate: 1,
75 visit: "",
76 };
77 const dataSignValue = data && typeof data === "object" ? JSON.stringify(data) : data ? String(data) : "";
78 const signKeys = ["fhAppid", "fhNonceStr", "fhTimestamp", dataSignValue].sort();
79 const signText = signKeys.reduce((text, key) => {
80 if (Object.prototype.hasOwnProperty.call(headers, key)) {
81 return text + key + headers[key];
82 }
83 return text + key;
84 }, "");
85
86 return {
87 ...headers,
88 fhSign: md5Upper(signText + APP_KEY),
89 Referer: `https://servicewechat.com/${MINI_APP_ID}/420/page-frame.html`,
90 "User-Agent": USER_AGENT,
91 Accept: "application/json, text/plain, */*",
92 };
93}
94
95function buildUrl(apiPath, query = {}) {
96 const params = new URLSearchParams();

Callers 1

requestMethod · 0.85

Calls 3

randomStringFunction · 0.85
md5UpperFunction · 0.85
callMethod · 0.80

Tested by

no test coverage detected