@mappa-ai/mappa-node 1.2.3 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +11 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -8
- package/dist/index.d.mts +53 -8
- package/dist/index.mjs +11 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1614,7 +1614,7 @@ function isObject(v) {
|
|
|
1614
1614
|
}
|
|
1615
1615
|
/**
|
|
1616
1616
|
* Async signature verification using WebCrypto (works in modern Node and browsers).
|
|
1617
|
-
* Signature scheme
|
|
1617
|
+
* Signature scheme:
|
|
1618
1618
|
* headers["mappa-signature"] = "t=1700000000,v1=<hex_hmac_sha256>"
|
|
1619
1619
|
* Signed payload: `${t}.${rawBody}`
|
|
1620
1620
|
*/
|
|
@@ -1632,20 +1632,24 @@ var WebhooksResource = class {
|
|
|
1632
1632
|
if (!timingSafeEqualHex(await hmacHex(params.secret, signed), parts.v1)) throw new Error("Invalid signature");
|
|
1633
1633
|
return { ok: true };
|
|
1634
1634
|
}
|
|
1635
|
+
/**
|
|
1636
|
+
* Parse and validate a webhook event payload.
|
|
1637
|
+
*
|
|
1638
|
+
* @param payload - Raw JSON string from the webhook request body
|
|
1639
|
+
* @returns Parsed and validated webhook event
|
|
1640
|
+
* @throws Error if payload is invalid or missing required fields
|
|
1641
|
+
*/
|
|
1635
1642
|
parseEvent(payload) {
|
|
1636
1643
|
const raw = JSON.parse(payload);
|
|
1637
1644
|
if (!isObject(raw)) throw new Error("Invalid webhook payload: not an object");
|
|
1638
1645
|
const obj = raw;
|
|
1639
|
-
const id = obj.id;
|
|
1640
1646
|
const type = obj.type;
|
|
1641
|
-
const
|
|
1642
|
-
if (typeof id !== "string") throw new Error("Invalid webhook payload: id must be a string");
|
|
1647
|
+
const timestamp = obj.timestamp;
|
|
1643
1648
|
if (typeof type !== "string") throw new Error("Invalid webhook payload: type must be a string");
|
|
1644
|
-
if (typeof
|
|
1649
|
+
if (typeof timestamp !== "string") throw new Error("Invalid webhook payload: timestamp must be a string");
|
|
1645
1650
|
return {
|
|
1646
|
-
id,
|
|
1647
1651
|
type,
|
|
1648
|
-
|
|
1652
|
+
timestamp,
|
|
1649
1653
|
data: "data" in obj ? obj.data : void 0
|
|
1650
1654
|
};
|
|
1651
1655
|
}
|