First upload version 0.0.1
This commit is contained in:
65
node_modules/@octokit/webhooks-methods/dist-node/index.js
generated
vendored
Normal file
65
node_modules/@octokit/webhooks-methods/dist-node/index.js
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
// pkg/dist-src/node/sign.js
|
||||
import { createHmac } from "node:crypto";
|
||||
|
||||
// pkg/dist-src/version.js
|
||||
var VERSION = "6.0.0";
|
||||
|
||||
// pkg/dist-src/node/sign.js
|
||||
async function sign(secret, payload) {
|
||||
if (!secret || !payload) {
|
||||
throw new TypeError(
|
||||
"[@octokit/webhooks-methods] secret & payload required for sign()"
|
||||
);
|
||||
}
|
||||
if (typeof payload !== "string") {
|
||||
throw new TypeError("[@octokit/webhooks-methods] payload must be a string");
|
||||
}
|
||||
const algorithm = "sha256";
|
||||
return `${algorithm}=${createHmac(algorithm, secret).update(payload).digest("hex")}`;
|
||||
}
|
||||
sign.VERSION = VERSION;
|
||||
|
||||
// pkg/dist-src/node/verify.js
|
||||
import { timingSafeEqual } from "node:crypto";
|
||||
import { Buffer } from "node:buffer";
|
||||
async function verify(secret, eventPayload, signature) {
|
||||
if (!secret || !eventPayload || !signature) {
|
||||
throw new TypeError(
|
||||
"[@octokit/webhooks-methods] secret, eventPayload & signature required"
|
||||
);
|
||||
}
|
||||
if (typeof eventPayload !== "string") {
|
||||
throw new TypeError(
|
||||
"[@octokit/webhooks-methods] eventPayload must be a string"
|
||||
);
|
||||
}
|
||||
const signatureBuffer = Buffer.from(signature);
|
||||
const verificationBuffer = Buffer.from(await sign(secret, eventPayload));
|
||||
if (signatureBuffer.length !== verificationBuffer.length) {
|
||||
return false;
|
||||
}
|
||||
return timingSafeEqual(signatureBuffer, verificationBuffer);
|
||||
}
|
||||
verify.VERSION = VERSION;
|
||||
|
||||
// pkg/dist-src/index.js
|
||||
async function verifyWithFallback(secret, payload, signature, additionalSecrets) {
|
||||
const firstPass = await verify(secret, payload, signature);
|
||||
if (firstPass) {
|
||||
return true;
|
||||
}
|
||||
if (additionalSecrets !== void 0) {
|
||||
for (const s of additionalSecrets) {
|
||||
const v = await verify(s, payload, signature);
|
||||
if (v) {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
export {
|
||||
sign,
|
||||
verify,
|
||||
verifyWithFallback
|
||||
};
|
||||
7
node_modules/@octokit/webhooks-methods/dist-node/index.js.map
generated
vendored
Normal file
7
node_modules/@octokit/webhooks-methods/dist-node/index.js.map
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../dist-src/node/sign.js", "../dist-src/version.js", "../dist-src/node/verify.js", "../dist-src/index.js"],
|
||||
"sourcesContent": ["import { createHmac } from \"node:crypto\";\nimport { VERSION } from \"../version.js\";\nasync function sign(secret, payload) {\n if (!secret || !payload) {\n throw new TypeError(\n \"[@octokit/webhooks-methods] secret & payload required for sign()\"\n );\n }\n if (typeof payload !== \"string\") {\n throw new TypeError(\"[@octokit/webhooks-methods] payload must be a string\");\n }\n const algorithm = \"sha256\";\n return `${algorithm}=${createHmac(algorithm, secret).update(payload).digest(\"hex\")}`;\n}\nsign.VERSION = VERSION;\nexport {\n sign\n};\n", "const VERSION = \"6.0.0\";\nexport {\n VERSION\n};\n", "import { timingSafeEqual } from \"node:crypto\";\nimport { Buffer } from \"node:buffer\";\nimport { sign } from \"./sign.js\";\nimport { VERSION } from \"../version.js\";\nasync function verify(secret, eventPayload, signature) {\n if (!secret || !eventPayload || !signature) {\n throw new TypeError(\n \"[@octokit/webhooks-methods] secret, eventPayload & signature required\"\n );\n }\n if (typeof eventPayload !== \"string\") {\n throw new TypeError(\n \"[@octokit/webhooks-methods] eventPayload must be a string\"\n );\n }\n const signatureBuffer = Buffer.from(signature);\n const verificationBuffer = Buffer.from(await sign(secret, eventPayload));\n if (signatureBuffer.length !== verificationBuffer.length) {\n return false;\n }\n return timingSafeEqual(signatureBuffer, verificationBuffer);\n}\nverify.VERSION = VERSION;\nexport {\n verify\n};\n", "import { sign } from \"./node/sign.js\";\nimport { verify } from \"./node/verify.js\";\nasync function verifyWithFallback(secret, payload, signature, additionalSecrets) {\n const firstPass = await verify(secret, payload, signature);\n if (firstPass) {\n return true;\n }\n if (additionalSecrets !== void 0) {\n for (const s of additionalSecrets) {\n const v = await verify(s, payload, signature);\n if (v) {\n return v;\n }\n }\n }\n return false;\n}\nexport {\n sign,\n verify,\n verifyWithFallback\n};\n"],
|
||||
"mappings": ";AAAA,SAAS,kBAAkB;;;ACA3B,IAAM,UAAU;;;ADEhB,eAAe,KAAK,QAAQ,SAAS;AACnC,MAAI,CAAC,UAAU,CAAC,SAAS;AACvB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,MAAI,OAAO,YAAY,UAAU;AAC/B,UAAM,IAAI,UAAU,sDAAsD;AAAA,EAC5E;AACA,QAAM,YAAY;AAClB,SAAO,GAAG,SAAS,IAAI,WAAW,WAAW,MAAM,EAAE,OAAO,OAAO,EAAE,OAAO,KAAK,CAAC;AACpF;AACA,KAAK,UAAU;;;AEdf,SAAS,uBAAuB;AAChC,SAAS,cAAc;AAGvB,eAAe,OAAO,QAAQ,cAAc,WAAW;AACrD,MAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,WAAW;AAC1C,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,MAAI,OAAO,iBAAiB,UAAU;AACpC,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,QAAM,kBAAkB,OAAO,KAAK,SAAS;AAC7C,QAAM,qBAAqB,OAAO,KAAK,MAAM,KAAK,QAAQ,YAAY,CAAC;AACvE,MAAI,gBAAgB,WAAW,mBAAmB,QAAQ;AACxD,WAAO;AAAA,EACT;AACA,SAAO,gBAAgB,iBAAiB,kBAAkB;AAC5D;AACA,OAAO,UAAU;;;ACpBjB,eAAe,mBAAmB,QAAQ,SAAS,WAAW,mBAAmB;AAC/E,QAAM,YAAY,MAAM,OAAO,QAAQ,SAAS,SAAS;AACzD,MAAI,WAAW;AACb,WAAO;AAAA,EACT;AACA,MAAI,sBAAsB,QAAQ;AAChC,eAAW,KAAK,mBAAmB;AACjC,YAAM,IAAI,MAAM,OAAO,GAAG,SAAS,SAAS;AAC5C,UAAI,GAAG;AACL,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;",
|
||||
"names": []
|
||||
}
|
||||
Reference in New Issue
Block a user