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

Function makePopToken

wxapp/wps.js:166–178  ·  view source on GitHub ↗
(method, url, secret, cv = "")

Source from the content-addressed store, hash-verified

164}
165
166function makePopToken(method, url, secret, cv = "") {
167 if (!secret) return "";
168 const header = base64url(JSON.stringify({ alg: "HS256", typ: "JWT" }));
169 const body = {
170 htm: String(method || "GET").toUpperCase(),
171 htu: new URL(url).pathname,
172 iat: Math.floor(Date.now() / 1000),
173 };
174 if (cv) body.cv = cv;
175 const payload = base64url(JSON.stringify(body));
176 const sig = crypto.createHmac("sha256", Buffer.from(secret)).update(`${header}.${payload}`).digest("base64url");
177 return `${header}.${payload}.${sig}`;
178}
179
180function genEcKeyPair() {
181 return crypto.generateKeyPairSync("ec", { namedCurve: "prime256v1" });

Callers 2

accountRequestFunction · 0.85
wpsRequestFunction · 0.85

Calls 1

base64urlFunction · 0.85

Tested by

no test coverage detected