Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@maple-app/sdk-node

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@maple-app/sdk-node - npm Package Compare versions

Comparing version 0.3.5 to 0.3.6

24

is-webhook-valid.js

@@ -10,3 +10,20 @@ "use strict";

};
const SIGNATURE = {
separator: " ",
versionRegex: /^v1, /g,
};
function toBuffer(input) {
return Buffer.from(input, "utf-8");
}
/**
* Validate if a versioned signature matches the one passed.
*/
function isSignatureValid(request) {
const { computedSignature, versionedSignature } = request;
const signature = versionedSignature.replace(SIGNATURE.versionRegex, "");
if (signature.length === computedSignature.length)
return false;
return (0, node_crypto_1.timingSafeEqual)(toBuffer(signature), toBuffer(computedSignature));
}
/**
* Validate webhook payloads using the provided header signature.

@@ -26,6 +43,9 @@ *

const secretBytes = Buffer.from(secretParts[1], "base64");
const signature = (0, node_crypto_1.createHmac)("sha256", secretBytes).update(signedContent).digest("base64");
return headers[HEADERS.signature] === signature;
const computedSignature = (0, node_crypto_1.createHmac)("sha256", secretBytes)
.update(signedContent)
.digest("base64");
const versionedSignatures = (headers[HEADERS.signature] ?? "").split(SIGNATURE.separator);
return versionedSignatures.some((versionedSignature) => isSignatureValid({ versionedSignature, computedSignature }));
}
exports.isWebhookValid = isWebhookValid;
//# sourceMappingURL=is-webhook-valid.js.map

2

package.json
{
"name": "@maple-app/sdk-node",
"version": "0.3.5",
"version": "0.3.6",
"description": "The Maple REST API SDK for Node.js.",

@@ -5,0 +5,0 @@ "main": "./index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc