@enfinitos/sdk-messaging
EnfinitOS reference SDK for the MESSAGING substrate. Built around the OptOutRegistryConstraint shipped earlier — every send goes through a pre-send TCPA / PECR / DNC / CASL check + a per- jurisdiction quiet-hours gate before reaching the carrier.
Architecture
┌─────────────────────────────────────────┐
│ @enfinitos/sdk-renderer-core (TS) │
│ resolve / event-ingest / health │
│ OptOutRegistryConstraint │
└─────────────────────────────────────────┘
▲
│
┌──────────────────┴──────────────────┐
│ messaging ts-core (OptOutChecker │
│ + QuietHoursEnforcer + │
│ sendWithGovernance) │
└──────────────────┬──────────────────┘
│
┌─────────────────┬─────────────┬─────────────┬─────────────┬─────────────┐
│ │ │ │ │ │
┌───────┐ ┌──────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐
│Twilio │ │ WhatsApp │ │ APNs │ │ FCM │ │SendGrid│ │Mailgun │
│v5 SDK │ │ Business │ │ JWT/p8 │ │HTTP v1 │ │CAN-SPAM│ │email │
│(SMS+ │ │ Cloud API│ │(certs │ │(legacy │ │compl. │ │ │
│RCS+ │ │(Cloud, │ │deprec.)│ │HTTP │ │ │ │ │
│Voice) │ │not │ │ │ │deprec.)│ │ │ │ │
│ │ │On-Prem) │ │ │ │ │ │ │ │ │
└───────┘ └──────────┘ └────────┘ └────────┘ └────────┘ └────────┘
Getting started
import { MessagingClient, MessageChannel } from "@enfinitos/sdk-messaging";
const messaging = new MessagingClient({
apiBaseUrl: "https://api.enfinitos.com",
authToken: jwt,
orgId: "acme",
});
await messaging.start();
const r = await messaging.sendWithGovernance({
channel: MessageChannel.SMS,
recipient: { phoneE164: "+15555550100", jurisdiction: "US-CA" },
body: "Your appointment is tomorrow at 9am.",
campaignId: "campaign-123",
});
if (r.status === "delivered") {
// ...
}
if (r.status === "blocked") {
console.log("Blocked:", r.reason);
}
2026 platform notes
Twilio (v5)
- Twilio Node SDK v5 (released 2024). Messaging v1 API + Programmable Voice v2.
ConnectionServicefor delivery verification. - RCS Business Messaging is mainstream now (Apple added RCS support to iOS 18 in Sept 2024). The Twilio SDK targets RCS as the primary path for cross-platform rich messaging.
- WhatsApp Business Cloud API (Meta-hosted) only. The on-premises API is end-of-life as of Oct 2025; we do NOT target it for new integrations.
- Template messages (Marketing, Utility, Authentication) use the Meta Business Manager-approved templates.
APNs
- Token-based (JWT / .p8) authentication ONLY. Certificate-based authentication is deprecated for new apps. The SDK refuses to start with certificate-based credentials.
FCM
- HTTP v1 API ONLY (
fcm.googleapis.com/v1). The legacy HTTP API (fcm.googleapis.com/fcm/send) is end-of-life June 2024; the SDK does not use it.
RCS Business Messaging
- Mainstream after Apple's iOS 18 RCS support (Sept 2024). The Twilio adapter exposes RCS as a first-class channel; the fallback ladder is RCS → SMS when the recipient's device doesn't support RCS.
- CAN-SPAM compliance is built into the SendGrid + Mailgun bridges — every send includes the operator's physical address + an unsubscribe link, and the SDK refuses to send if those are missing.
OptOutRegistry contract
Every sendWithGovernance call invokes:
- OptOutChecker — queries the platform's
/opt-out-registry/checkendpoint with(channel, recipient, campaignId, jurisdiction). Returnsallowed|opted-out|unknown. - QuietHoursEnforcer — per-jurisdiction quiet-hours rules (US: 8am-9pm local; PECR (UK/EU): per-marketer schedule; CASL (Canada): per-consent expiry).
- Send via the channel adapter (Twilio, WhatsApp, APNs, FCM, email).
- Report the delivery + the decision to the platform's audit log.
Endpoint surface
| SDK call | Platform endpoint | Status |
|---|---|---|
sendWithGovernance | POST /opt-out-registry/check then channel API | existing |
reportDelivery/Read/Click | POST /runtime/event-ingest | existing |
| OptOutRegistry sync | POST /opt-out-registry/sync | existing |
| Twilio status webhook | Operator's webhook URL; forwarded by SDK | existing |
| APNs token rotation | Apple's JWT signing | existing (SDK-side) |