@mulmobridge/twilio-sms 1.0.1 → 1.0.2
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.js +9 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -27,7 +27,7 @@ import "dotenv/config";
|
|
|
27
27
|
import crypto from "crypto";
|
|
28
28
|
import express from "express";
|
|
29
29
|
import { createBridgeClient, chunkText } from "@mulmobridge/client";
|
|
30
|
-
import { parseCsvSet } from "@mulmoclaude/common";
|
|
30
|
+
import { isRecord, parseCsvSet } from "@mulmoclaude/common";
|
|
31
31
|
const TRANSPORT_ID = "twilio-sms";
|
|
32
32
|
const MAX_SMS_LEN = 1_600; // Twilio concatenates segments up to 1600 chars
|
|
33
33
|
const FETCH_TIMEOUT_MS = 15_000;
|
|
@@ -116,7 +116,7 @@ app.get("/health", (__req, res) => {
|
|
|
116
116
|
res.json({ status: "ok", transport: TRANSPORT_ID });
|
|
117
117
|
});
|
|
118
118
|
function parseTwilioBody(body) {
|
|
119
|
-
if (!body
|
|
119
|
+
if (!isRecord(body))
|
|
120
120
|
return null;
|
|
121
121
|
const record = body;
|
|
122
122
|
const from = typeof record.From === "string" ? record.From : "";
|
|
@@ -127,7 +127,14 @@ function parseTwilioBody(body) {
|
|
|
127
127
|
return null;
|
|
128
128
|
return { From: from, To: toField, Body: text, MessageSid: messageSid };
|
|
129
129
|
}
|
|
130
|
+
/** The string-valued subset of a form body, for signature computation.
|
|
131
|
+
*
|
|
132
|
+
* Takes `unknown` because the caller has an Express `req.body`. A non-record
|
|
133
|
+
* yields `{}`, which produces a signature that cannot match — fail closed,
|
|
134
|
+
* the same outcome as an absent body. */
|
|
130
135
|
function stringifyParams(body) {
|
|
136
|
+
if (!isRecord(body))
|
|
137
|
+
return {};
|
|
131
138
|
const out = {};
|
|
132
139
|
for (const [key, value] of Object.entries(body)) {
|
|
133
140
|
if (typeof value === "string")
|
package/package.json
CHANGED