Skip to content

fix: correct provider edge cases found in the API audit - #13

Merged
Schero94 merged 3 commits into
mainfrom
fix/provider-audit
Nov 20, 2026
Merged

Schero94 merged 3 commits into
mainfrom
fix/provider-audit

Conversation

@Schero94

Copy link
Copy Markdown
Owner

Summary

Audit of all four provider adapters against the providers' current official specs and docs (retrieved 2026-11-20). Full table with sources: docs/audits/2026-11-20-provider-apis.md.

# Finding Severity
1 seven.io posts webhooks form-encoded by default; MessageGate only read JSON, so every signed DLR / inbound SMS got 200 and was dropped silently. Now: admin hint (5 locales) + README say "request method JSON", and a signed non-JSON body logs a warning naming the fix. high
2 /api hard-coded: with a custom api.rest.prefix every webhook failed the signature check (raw body not captured) and all shown URLs were wrong. medium
3 Telegram: raw HTML cut at 4096 units could split & → Bot API "can't parse entities" (permanent failure). Now counts visible characters, never cuts an entity. medium
4 seven.io: SMS cut at 1600, documented max is 1520 → code 401 for 1521–1600 chars. medium
6 seven.io codes: 101 (single recipient) was uncertain; 500/501 did not flag the account; 407004 (unsubscribed) did not revoke consent. medium
7 Twilio 21610 / Advanced Opt-Out OptOutType=STOP did not revoke consent (later sends kept failing at Twilio). medium
5, 8–10, 18a emoji split on text cuts; seven sms_mo Unix time; HLR roaming object; HTTP-date Retry-After; Twilio 21611 (queue full) now transient low

No API or schema change. Patch release.

Tests

Regression tests for every fix (all fail on main, verified by stashing server/src): tests/adapters.test.js, tests/webhooks.test.js, tests/plugin.test.js (custom REST prefix), tests/admin.test.js (webhook hints). A new test fails 90 days before the end of support of the pinned Graph API version (v23.0 until 2027-10-08).

Local: npm run lint, npm run format:check, npm test (170 pass), npm run test:admin, npm run build, npm run verify.

docs/site/llms-full.txt is regenerated from README/AGENTS (required by tests/docs.test.js); no other docs/site file is touched.

🤖 Generated with Claude Code

Schero94 and others added 2 commits November 20, 2026 00:30
Audit of the Meta, Twilio, seven.io and Telegram adapters against the
providers' official specs and docs (docs/audits/2026-11-20-provider-apis.md).

- seven.io: tell the owner to use the JSON webhook request method and log
  signed non-JSON webhooks instead of dropping them silently; cut SMS at
  the documented 1520 characters; map 101/500/501/407004 correctly; read
  sms_mo Unix timestamps and the HLR roaming object.
- Twilio: 21610 and OptOutType=STOP revoke consent; 21611 is transient.
- Telegram: never cut the HTML text inside an entity.
- Follow api.rest.prefix for webhook URLs, status callbacks, file links and
  the raw-body middleware.
- Keep surrogate pairs whole when cutting text; honour HTTP-date
  Retry-After.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Schero94
Schero94 merged commit 8cc8097 into main Nov 20, 2026
16 checks passed
@Schero94
Schero94 deleted the fix/provider-audit branch November 20, 2026 00:10
github-actions Bot pushed a commit that referenced this pull request Nov 20, 2026
## [1.1.3](messagegate-v1.1.2...messagegate-v1.1.3) (2026-11-20)

### Bug Fixes

* correct provider edge cases found in the API audit ([#13](#13)) ([8cc8097](8cc8097))

### Fixed

- seven.io: the admin and README now say to set the webhook's request method to **JSON**. seven.io's default sends form fields, which MessageGate cannot read; such a signed webhook now logs a warning instead of being dropped without a trace.
- seven.io: SMS texts are cut at 1520 characters (the documented limit) instead of 1600, so texts between 1521 and 1600 characters no longer fail with code 401.
- seven.io: return code 101 for the single recipient is a rejection with the recipient's own error code instead of `uncertain`; 500 (no credit) and 501 (spending limit) mark the account unhealthy; 407004 (recipient unsubscribed) revokes SMS consent.
- seven.io: inbound SMS keep their real receive time (`time` is a Unix timestamp); HLR checks return `roaming` from the documented object.
- Twilio: error 21610 (recipient replied STOP) and an inbound `OptOutType=STOP` (Advanced Opt-Out) revoke consent for the channel, so later sends stop at the consent check instead of failing at Twilio. Error 21611 (sender queue full) is retried.
- Telegram: long texts with `&`, `<` or `>` are no longer cut inside an HTML entity (the Bot API refused them); the 4096 limit counts visible characters.
- Webhook URLs, Twilio status callbacks, signed file links and the webhook raw-body capture follow `api.rest.prefix`. With a custom prefix every webhook used to fail the signature check.
- Outgoing texts are never cut inside an emoji.
- `Retry-After` given as an HTTP date is honoured (capped at 24 hours).

### Documentation

- `docs/audits/2026-11-20-provider-apis.md`: audit of all four provider APIs against their official specs and docs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant