@openclaw/sms 2026.7.2-beta.5 → 2026.7.2-beta.7

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.
@@ -754,10 +754,6 @@ async function dispatchSmsInboundEvent(params) {
754
754
  //#region extensions/sms/src/ingress-spool.ts
755
755
  const SMS_INGRESS_PAYLOAD_VERSION = 1;
756
756
  const SMS_INGRESS_DRAIN_INTERVAL_MS = 500;
757
- const SMS_COMPLETED_TTL_MS = 1440 * 60 * 1e3;
758
- const SMS_COMPLETED_MAX_ENTRIES = 2e4;
759
- const SMS_FAILED_TTL_MS = 720 * 60 * 60 * 1e3;
760
- const SMS_FAILED_MAX_ENTRIES = 1e3;
761
757
  var SmsIngressPermanentError = class extends Error {};
762
758
  function parseSmsIngressForm(form, account) {
763
759
  const message = buildTwilioInboundMessage(form);
@@ -810,10 +806,8 @@ function createSmsIngressSpool(params) {
810
806
  pollIntervalMs: SMS_INGRESS_DRAIN_INTERVAL_MS,
811
807
  retention: {
812
808
  pruneIntervalMs: 0,
813
- completedTtlMs: SMS_COMPLETED_TTL_MS,
814
- completedMaxEntries: SMS_COMPLETED_MAX_ENTRIES,
815
- failedTtlMs: SMS_FAILED_TTL_MS,
816
- failedMaxEntries: SMS_FAILED_MAX_ENTRIES
809
+ completedTtlMs: 1440 * 60 * 1e3,
810
+ failedMaxEntries: 1e3
817
811
  },
818
812
  appendRetryDelaysMs: [0],
819
813
  waitForDeliveryIdleBeforeRepump: false,
@@ -850,6 +844,8 @@ function createSmsIngressSpool(params) {
850
844
  //#region extensions/sms/src/webhook.ts
851
845
  const INVALID_REQUEST_MAX_REQUESTS = 300;
852
846
  const CALLBACK_DISPATCH_MAX_REQUESTS = 30;
847
+ const SMS_WEBHOOK_ACCEPTED_HEADER = "x-openclaw-delivery-accepted";
848
+ const SMS_WEBHOOK_ACCEPTED_VALUE = "durable";
853
849
  const invalidRequestRateLimiter = createFixedWindowRateLimiter({
854
850
  maxRequests: INVALID_REQUEST_MAX_REQUESTS,
855
851
  windowMs: 6e4,
@@ -860,6 +856,11 @@ const callbackDispatchRateLimiter = createFixedWindowRateLimiter({
860
856
  windowMs: 6e4,
861
857
  maxTrackedKeys: 5e3
862
858
  });
859
+ const validatedAggregateRateLimiter = createFixedWindowRateLimiter({
860
+ maxRequests: 300,
861
+ windowMs: 6e4,
862
+ maxTrackedKeys: 1e3
863
+ });
863
864
  function headerValue(value) {
864
865
  if (Array.isArray(value)) return value[0];
865
866
  return value;
@@ -868,7 +869,10 @@ function resolvedClientAddress(params) {
868
869
  return resolveRequestClientIp(params.req, params.cfg.gateway?.trustedProxies, params.cfg.gateway?.allowRealIpFallback === true) ?? params.req.socket?.remoteAddress ?? "unknown";
869
870
  }
870
871
  function rateLimitKey(params) {
871
- return `${params.account.accountId}:${params.account.webhookPath}:${params.clientAddress}`;
872
+ return `${params.account.accountId}:${params.account.webhookPath}:${params.subject}`;
873
+ }
874
+ function accountRouteRateLimitKey(account) {
875
+ return `${account.accountId}:${account.webhookPath}`;
872
876
  }
873
877
  function rejectInvalidRequestRateLimit(params) {
874
878
  params.log?.warn?.(`SMS webhook invalid-request rate limit exceeded for ${params.key}`);
@@ -885,17 +889,17 @@ function createSmsWebhookHandler(params) {
885
889
  cfg: params.cfg,
886
890
  req
887
891
  });
888
- const key = rateLimitKey({
892
+ const clientAddressKey = rateLimitKey({
889
893
  account: params.account,
890
- clientAddress
894
+ subject: clientAddress
891
895
  });
892
- const invalidRequestRateLimited = invalidRequestRateLimiter.isRateLimited(key);
896
+ const invalidRequestRateLimited = invalidRequestRateLimiter.isRateLimited(clientAddressKey);
893
897
  let form;
894
898
  try {
895
899
  form = await readTwilioWebhookForm(req);
896
900
  } catch {
897
901
  if (invalidRequestRateLimited) return rejectInvalidRequestRateLimit({
898
- key,
902
+ key: clientAddressKey,
899
903
  log: params.log,
900
904
  res
901
905
  });
@@ -913,7 +917,7 @@ function createSmsWebhookHandler(params) {
913
917
  form
914
918
  })) {
915
919
  if (invalidRequestRateLimited) return rejectInvalidRequestRateLimit({
916
- key,
920
+ key: clientAddressKey,
917
921
  log: params.log,
918
922
  res
919
923
  });
@@ -923,21 +927,34 @@ function createSmsWebhookHandler(params) {
923
927
  }
924
928
  }
925
929
  if (invalidRequestRateLimited && params.account.dangerouslyDisableSignatureValidation) return rejectInvalidRequestRateLimit({
926
- key,
930
+ key: clientAddressKey,
927
931
  log: params.log,
928
932
  res
929
933
  });
930
- if (callbackDispatchRateLimiter.isRateLimited(key)) {
931
- params.log?.warn?.(`SMS webhook rate limit exceeded for ${key}`);
934
+ const dispatchKey = params.account.dangerouslyDisableSignatureValidation ? clientAddressKey : rateLimitKey({
935
+ account: params.account,
936
+ subject: resolveTwilioInboundSender(form)
937
+ });
938
+ if (callbackDispatchRateLimiter.isRateLimited(dispatchKey)) {
939
+ params.log?.warn?.("SMS webhook callback rate limit exceeded");
932
940
  respondTwiml(res, 429, "Rate limit exceeded");
933
941
  return true;
934
942
  }
943
+ if (!params.account.dangerouslyDisableSignatureValidation) {
944
+ const aggregateKey = accountRouteRateLimitKey(params.account);
945
+ if (validatedAggregateRateLimiter.isRateLimited(aggregateKey)) {
946
+ params.log?.warn?.(`SMS webhook aggregate rate limit exceeded for ${aggregateKey}`);
947
+ respondTwiml(res, 429, "Rate limit exceeded");
948
+ return true;
949
+ }
950
+ }
935
951
  const messageSid = resolveTwilioMessageSid(form);
936
952
  if (!messageSid) {
937
953
  respondTwiml(res, 400, "Missing MessageSid");
938
954
  return true;
939
955
  }
940
956
  if ((await params.ingress.enqueue(form)).duplicate) params.log?.warn?.(`SMS webhook ignored replayed message ${messageSid}`);
957
+ res.setHeader(SMS_WEBHOOK_ACCEPTED_HEADER, SMS_WEBHOOK_ACCEPTED_VALUE);
941
958
  respondTwiml(res, 200);
942
959
  return true;
943
960
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/sms",
3
- "version": "2026.7.2-beta.5",
3
+ "version": "2026.7.2-beta.7",
4
4
  "description": "OpenClaw SMS channel plugin for Twilio text messages.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -124,10 +124,10 @@
124
124
  }
125
125
  },
126
126
  "compat": {
127
- "pluginApi": ">=2026.7.2-beta.5"
127
+ "pluginApi": ">=2026.7.2-beta.7"
128
128
  },
129
129
  "build": {
130
- "openclawVersion": "2026.7.2-beta.5",
130
+ "openclawVersion": "2026.7.2-beta.7",
131
131
  "bundledDist": false
132
132
  },
133
133
  "install": {
@@ -151,7 +151,7 @@
151
151
  "README.md"
152
152
  ],
153
153
  "peerDependencies": {
154
- "openclaw": ">=2026.7.2-beta.5"
154
+ "openclaw": ">=2026.7.2-beta.7"
155
155
  },
156
156
  "peerDependenciesMeta": {
157
157
  "openclaw": {