@openclaw/sms 2026.8.2 → 2026.9.1

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.
@@ -1,5 +1,5 @@
1
1
  import { t as getSmsRuntime } from "./runtime-BBlPgBIF.js";
2
- import { C as normalizeSmsPhoneNumber, S as normalizeSmsAllowFrom, _ as listSmsAccountIds, a as listTwilioMessages, b as resolveTwilioStatusCallbackUrl, c as resolveTwilioMessageSid, d as retrieveTwilioMessagingService, f as sendSmsViaTwilio, g as isSmsAccountConfigured, h as inspectSmsAccount, i as listTwilioIncomingPhoneNumbers, l as resolveTwilioWebhookSignatureUrl, m as assertSmsCredentialOwnerAvailable, o as readTwilioWebhookForm, p as verifyTwilioSignature, r as buildTwilioInboundMessage, s as resolveTwilioInboundSender, t as TWILIO_MESSAGE_BODY_MAX_LENGTH, u as respondTwiml, v as resolveDefaultSmsAccountId, x as looksLikeSmsPhoneNumber, y as resolveSmsAccount } from "./twilio-BpcGZSHK.js";
2
+ import { C as normalizeSmsAllowFrom, S as looksLikeSmsPhoneNumber, _ as isSmsAccountConfigured, a as listTwilioIncomingPhoneNumbers, b as resolveSmsAccount, c as resolveTwilioInboundSender, d as respondTwiml, f as retrieveTwilioMessagingService, g as inspectSmsAccount, h as assertSmsCredentialOwnerAvailable, i as buildTwilioInboundMessage, l as resolveTwilioMessageSid, m as verifyTwilioSignature, o as listTwilioMessages, p as sendSmsViaTwilio, r as TWIML_CONTENT_TYPE, s as readTwilioWebhookForm, t as TWILIO_MESSAGE_BODY_MAX_LENGTH, u as resolveTwilioWebhookSignatureUrl, v as listSmsAccountIds, w as normalizeSmsPhoneNumber, x as resolveTwilioStatusCallbackUrl, y as resolveDefaultSmsAccountId } from "./twilio-J4cwlx0M.js";
3
3
  import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-Cp0f-YPc.js";
4
4
  import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
5
5
  import { createHybridChannelConfigAdapter, createScopedDmSecurityResolver } from "openclaw/plugin-sdk/channel-config-helpers";
@@ -19,7 +19,7 @@ import { z } from "zod";
19
19
  import { createHash } from "node:crypto";
20
20
  import { channelBlockedPatch, channelReadyPatch, channelStoppedPatch } from "openclaw/plugin-sdk/gateway-runtime";
21
21
  import { createFixedWindowRateLimiter, isRequestBodyLimitError, registerPluginHttpRoute, resolveRequestClientIp } from "openclaw/plugin-sdk/webhook-ingress";
22
- import { runDetachedWebhookWork } from "openclaw/plugin-sdk/webhook-request-guards";
22
+ import { createWebhookInFlightLimiter, runDetachedWebhookWork, sendHttpRequestRejection } from "openclaw/plugin-sdk/webhook-request-guards";
23
23
  import { resolveStableChannelMessageIngress } from "openclaw/plugin-sdk/channel-ingress-runtime";
24
24
  import { createChannelPairingChallengeIssuer } from "openclaw/plugin-sdk/channel-pairing";
25
25
  import { createChannelPartialDeliveryError } from "openclaw/plugin-sdk/channel-inbound";
@@ -474,7 +474,7 @@ async function prepareSmsMediaAttempt(params) {
474
474
  });
475
475
  let hostedMedia;
476
476
  try {
477
- const { prepareHostedSmsMedia } = await import("./media-BDbaClzL.js");
477
+ const { prepareHostedSmsMedia } = await import("./media-Cle9pp18.js");
478
478
  assertSmsCredentialOwnerAvailable(params.account);
479
479
  const prepared = await prepareHostedSmsMedia({
480
480
  account: params.account,
@@ -606,7 +606,7 @@ async function dispatchSmsInboundEvent(params) {
606
606
  params.log?.warn?.(`SMS sender ${from} is not authorized`);
607
607
  return;
608
608
  }
609
- const materialized = params.msg.media.length > 0 || (params.msg.unavailableMediaCount ?? 0) > 0 ? await (await import("./media-BDbaClzL.js")).materializeSmsInboundMedia({
609
+ const materialized = params.msg.media.length > 0 || (params.msg.unavailableMediaCount ?? 0) > 0 ? await (await import("./media-Cle9pp18.js")).materializeSmsInboundMedia({
610
610
  account: params.account,
611
611
  msg: params.msg,
612
612
  mediaRuntime: params.channelRuntime,
@@ -869,6 +869,7 @@ function createSmsIngressSpool(params) {
869
869
  //#endregion
870
870
  //#region extensions/sms/src/webhook.ts
871
871
  const INVALID_REQUEST_MAX_REQUESTS = 300;
872
+ const PRE_AUTH_MAX_IN_FLIGHT = 64;
872
873
  const INBOUND_DISPATCH_MAX_REQUESTS = 30;
873
874
  const DELIVERY_CALLBACK_MAX_REQUESTS = 3e3;
874
875
  const DELIVERY_CALLBACK_WINDOW_MS = 6e4;
@@ -909,6 +910,11 @@ function rejectInvalidRequestRateLimit(params) {
909
910
  }
910
911
  function createSmsWebhookHandler(params) {
911
912
  let deliveryRecorder = params.delivery;
913
+ const preAuthInFlightLimiter = createWebhookInFlightLimiter({
914
+ maxInFlightPerKey: PRE_AUTH_MAX_IN_FLIGHT,
915
+ maxTrackedKeys: 1
916
+ });
917
+ const preAuthInFlightKey = accountRouteRateLimitKey(params.account);
912
918
  const deliveryCallbackRateLimiter = createFixedWindowRateLimiter({
913
919
  maxRequests: DELIVERY_CALLBACK_MAX_REQUESTS,
914
920
  windowMs: DELIVERY_CALLBACK_WINDOW_MS,
@@ -929,42 +935,56 @@ function createSmsWebhookHandler(params) {
929
935
  subject: clientAddress
930
936
  });
931
937
  const invalidRequestRateLimited = invalidRequestRateLimiter.isRateLimited(clientAddressKey);
938
+ if (!preAuthInFlightLimiter.tryAcquire(preAuthInFlightKey)) {
939
+ params.log?.warn?.("SMS webhook pre-authentication concurrency limit exceeded");
940
+ await sendHttpRequestRejection(req, res, 429, "Rate limit exceeded", TWIML_CONTENT_TYPE);
941
+ return true;
942
+ }
932
943
  let form;
933
944
  try {
934
- form = await readTwilioWebhookForm(req);
935
- } catch (error) {
936
- if (isRequestBodyLimitError(error, "PAYLOAD_TOO_LARGE")) {
937
- respondTwiml(res, 413, "Payload too large");
938
- return true;
945
+ try {
946
+ form = await readTwilioWebhookForm(req);
947
+ } catch (error) {
948
+ if (isRequestBodyLimitError(error, "PAYLOAD_TOO_LARGE")) {
949
+ await sendHttpRequestRejection(req, res, 413, "Payload too large", TWIML_CONTENT_TYPE);
950
+ return true;
951
+ }
952
+ if (isRequestBodyLimitError(error, "REQUEST_BODY_TIMEOUT")) {
953
+ res.setHeader("cache-control", "no-store");
954
+ await sendHttpRequestRejection(req, res, 500, "Internal Server Error", "text/plain; charset=utf-8");
955
+ return true;
956
+ }
957
+ throw error;
939
958
  }
940
- throw error;
941
- }
942
- assertSmsCredentialOwnerAvailable(params.account);
943
- if (!params.account.dangerouslyDisableSignatureValidation) {
944
- if (!verifyTwilioSignature({
945
- signature: headerValue(req.headers["x-twilio-signature"]),
946
- url: resolveTwilioWebhookSignatureUrl({
947
- req,
948
- publicWebhookUrl: params.account.publicWebhookUrl
949
- }),
950
- authToken: params.account.authToken,
951
- form
952
- })) {
953
- if (invalidRequestRateLimited) return rejectInvalidRequestRateLimit({
954
- key: clientAddressKey,
955
- log: params.log,
956
- res
957
- });
958
- params.log?.warn?.("SMS webhook rejected invalid Twilio signature");
959
- respondTwiml(res, 403, "Invalid signature");
960
- return true;
959
+ assertSmsCredentialOwnerAvailable(params.account);
960
+ if (!params.account.dangerouslyDisableSignatureValidation) {
961
+ if (!verifyTwilioSignature({
962
+ signature: headerValue(req.headers["x-twilio-signature"]),
963
+ url: resolveTwilioWebhookSignatureUrl({
964
+ req,
965
+ publicWebhookUrl: params.account.publicWebhookUrl
966
+ }),
967
+ authToken: params.account.authToken,
968
+ form
969
+ })) {
970
+ if (invalidRequestRateLimited) return rejectInvalidRequestRateLimit({
971
+ key: clientAddressKey,
972
+ log: params.log,
973
+ res
974
+ });
975
+ params.log?.warn?.("SMS webhook rejected invalid Twilio signature");
976
+ respondTwiml(res, 403, "Invalid signature");
977
+ return true;
978
+ }
961
979
  }
980
+ if (invalidRequestRateLimited && params.account.dangerouslyDisableSignatureValidation) return rejectInvalidRequestRateLimit({
981
+ key: clientAddressKey,
982
+ log: params.log,
983
+ res
984
+ });
985
+ } finally {
986
+ preAuthInFlightLimiter.release(preAuthInFlightKey);
962
987
  }
963
- if (invalidRequestRateLimited && params.account.dangerouslyDisableSignatureValidation) return rejectInvalidRequestRateLimit({
964
- key: clientAddressKey,
965
- log: params.log,
966
- res
967
- });
968
988
  if (isTwilioDeliveryStatusForm(form)) {
969
989
  if (params.account.dangerouslyDisableSignatureValidation && inboundDispatchRateLimiter.isRateLimited(clientAddressKey)) {
970
990
  params.log?.warn?.("SMS webhook callback rate limit exceeded");
@@ -1091,7 +1111,7 @@ async function registerSmsWebhookRoute(params) {
1091
1111
  throwOnFailure: true,
1092
1112
  log: (msg) => params.log?.info?.(msg),
1093
1113
  handler: async (req, res) => {
1094
- const { tryHandleHostedSmsMediaRequest } = await import("./media-BDbaClzL.js");
1114
+ const { tryHandleHostedSmsMediaRequest } = await import("./media-Cle9pp18.js");
1095
1115
  if (await tryHandleHostedSmsMediaRequest(req, res, params.account.accountId)) return true;
1096
1116
  return await webhookHandler(req, res);
1097
1117
  }
@@ -1,5 +1,5 @@
1
1
  import { t as getSmsRuntime } from "./runtime-BBlPgBIF.js";
2
- import { m as assertSmsCredentialOwnerAvailable, n as TWILIO_MMS_MAX_BYTES } from "./twilio-BpcGZSHK.js";
2
+ import { h as assertSmsCredentialOwnerAvailable, n as TWILIO_MMS_MAX_BYTES } from "./twilio-J4cwlx0M.js";
3
3
  import { collectErrorGraphCandidates } from "openclaw/plugin-sdk/error-runtime";
4
4
  import { resolveExpiresAtMsFromDurationMs } from "openclaw/plugin-sdk/number-runtime";
5
5
  import { createHash } from "node:crypto";
@@ -373,12 +373,14 @@ function resolveTwilioMessageSid(form) {
373
373
  async function readTwilioWebhookForm(req) {
374
374
  return parseTwilioFormBody(await readRequestBodyWithLimit(req, {
375
375
  maxBytes: WEBHOOK_BODY_LIMIT_BYTES,
376
- timeoutMs: WEBHOOK_BODY_TIMEOUT_MS
376
+ timeoutMs: WEBHOOK_BODY_TIMEOUT_MS,
377
+ destroyOnLimit: false
377
378
  }));
378
379
  }
380
+ const TWIML_CONTENT_TYPE = "text/xml; charset=utf-8";
379
381
  function respondTwiml(res, statusCode, body = "") {
380
382
  res.statusCode = statusCode;
381
- res.setHeader("content-type", "text/xml; charset=utf-8");
383
+ res.setHeader("content-type", TWIML_CONTENT_TYPE);
382
384
  res.end(body || "<Response></Response>");
383
385
  }
384
386
  function twilioApiUrl(accountSid, path, query) {
@@ -593,4 +595,4 @@ async function sendSmsViaTwilio(params) {
593
595
  };
594
596
  }
595
597
  //#endregion
596
- export { normalizeSmsPhoneNumber as C, normalizeSmsAllowFrom as S, listSmsAccountIds as _, listTwilioMessages as a, resolveTwilioStatusCallbackUrl as b, resolveTwilioMessageSid as c, retrieveTwilioMessagingService as d, sendSmsViaTwilio as f, isSmsAccountConfigured as g, inspectSmsAccount as h, listTwilioIncomingPhoneNumbers as i, resolveTwilioWebhookSignatureUrl as l, assertSmsCredentialOwnerAvailable as m, TWILIO_MMS_MAX_BYTES as n, readTwilioWebhookForm as o, verifyTwilioSignature as p, buildTwilioInboundMessage as r, resolveTwilioInboundSender as s, TWILIO_MESSAGE_BODY_MAX_LENGTH as t, respondTwiml as u, resolveDefaultSmsAccountId as v, looksLikeSmsPhoneNumber as x, resolveSmsAccount as y };
598
+ export { normalizeSmsAllowFrom as C, looksLikeSmsPhoneNumber as S, isSmsAccountConfigured as _, listTwilioIncomingPhoneNumbers as a, resolveSmsAccount as b, resolveTwilioInboundSender as c, respondTwiml as d, retrieveTwilioMessagingService as f, inspectSmsAccount as g, assertSmsCredentialOwnerAvailable as h, buildTwilioInboundMessage as i, resolveTwilioMessageSid as l, verifyTwilioSignature as m, TWILIO_MMS_MAX_BYTES as n, listTwilioMessages as o, sendSmsViaTwilio as p, TWIML_CONTENT_TYPE as r, readTwilioWebhookForm as s, TWILIO_MESSAGE_BODY_MAX_LENGTH as t, resolveTwilioWebhookSignatureUrl as u, listSmsAccountIds as v, normalizeSmsPhoneNumber as w, resolveTwilioStatusCallbackUrl as x, resolveDefaultSmsAccountId as y };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/sms",
3
- "version": "2026.8.2",
3
+ "version": "2026.9.1",
4
4
  "description": "OpenClaw SMS/MMS channel plugin for Twilio messages.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -123,10 +123,10 @@
123
123
  }
124
124
  },
125
125
  "compat": {
126
- "pluginApi": ">=2026.8.2"
126
+ "pluginApi": ">=2026.9.1"
127
127
  },
128
128
  "build": {
129
- "openclawVersion": "2026.8.2",
129
+ "openclawVersion": "2026.9.1",
130
130
  "bundledDist": false
131
131
  },
132
132
  "install": {
@@ -150,7 +150,7 @@
150
150
  "README.md"
151
151
  ],
152
152
  "peerDependencies": {
153
- "openclaw": ">=2026.8.2"
153
+ "openclaw": ">=2026.9.1"
154
154
  },
155
155
  "peerDependenciesMeta": {
156
156
  "openclaw": {