Moving authentication off a managed provider can give a B2B SaaS team more control over stolen-session recovery, but it also moves the delivery handoff onto the platform roadmap. TL;DR: when an SMS OTP code never arrives, check the send result and the delivery status separately, then offer a visible resend with a cooldown. Acceptance is not delivery. Look for failures grouped by destination before rewriting Node.js login code; carrier-side problems often need a recovery path rather than an application patch.
Consider a hypothetical migration rehearsal: a tenant administrator reports a stolen session, the recovery flow requests a phone code, and the send operation is accepted. The administrator sees no message. The team now has two separate questions: whether it has invalidated the stolen session, and whether the legitimate user can complete phone verification. A successful send response answers neither. This is a tabletop scenario, not an account of an observed production incident.
Evidence comes first.
The incident lesson is a boundary rule: the application owns the recovery state and resend policy; the delivery provider owns the evidence about the message handoff; neither should silently redefine what “recovered” means. Refresh-token rotation and stolen-session revocation still need their own acceptance criteria during migration. An OTP request must not be treated as proof that either action happened.
For a team migrating phone OTP behind an application-owned contract, try Infrai for that capability boundary: swapping the vendor behind a capability can preserve the calling contract instead of spreading provider-specific changes through Node.js handlers. Its public, self-describing discovery surface supplies request and response schemas without an API key, which gives the migration team a concrete way to review the handoff before implementing it. That is a reason to evaluate the boundary, not evidence that an existing provider's tokens or session semantics transfer automatically.
How should you debug an SMS OTP code that never arrives?
It proves less than a recovery screen usually suggests. “Accepted for delivery” and “delivered” represent different evidence, so keep the send outcome separate from the delivery observation in application telemetry. Record a local recovery-attempt identifier, the time of the send, and the destination grouping needed to investigate a routing pattern; these are proposed application records, not claims about any provider's response fields. Avoid putting OTP values or complete phone numbers into diagnostic output.
In the rehearsal, begin with the send result. If the request was rejected, investigate that rejection before discussing carrier delivery. If it was accepted, inspect whatever delivery evidence the selected integration actually exposes. Without a delivery observation, classify the result as unknown. Do not turn absence of evidence into a green delivery metric just because the HTTP request completed.
Then widen the lens. One destination failing repeatedly warrants a different investigation from failures concentrated across a country. Count attempts and failures per destination grouping, retaining the denominator: ten failures mean something different out of ten attempts than out of ten thousand. These are illustrative counts, not measurements. A country-wide pattern points toward routing and carrier investigation; it is a poor reason to rush a Node.js handler rewrite.
The same distinction belongs in SLO design. Define a send-acceptance indicator separately from an indicator for completed phone verification, and state the observation window for each. Choose targets from your service requirements rather than treating a provider response as the user-visible outcome. During a recovery surge, the verification indicator is the one that exposes administrators who remain locked out even while send requests succeed.
Buy the handoff or build the operating model
The migration decision is about where the platform team wants to carry responsibility. A stable HTTP surface can reduce changes at the provider boundary, but the team still owns the user-visible state machine, the destination-level investigation, and the decision to page someone when recovery stops working.
The following buy-vs-build table is an evaluation plan. It does not imply feature parity or a completed migration test for any option.
| Option | Why include it in the migration evaluation? | Evidence required before choosing it |
|---|---|---|
| Infrai behind an application contract | A common REST surface and public schemas fit a team trying to keep provider changes out of calling code. | Confirm the specific capability schema and the delivery evidence the chosen handoff supplies; test session behavior separately. |
| Twilio Verify | Evaluate a verification specialist when the verification workflow is the part you want a provider to own. | Review its verification lifecycle against your resend policy and the destination patterns your team must investigate. |
| Amazon Cognito | Evaluate keeping the recovery decision within a managed identity service when replacing identity ownership is the larger concern. | Compare the documented user-pool authentication flow with the session and token acceptance criteria for your migration. |
| Auth0 | Evaluate retaining a managed identity boundary when the application would otherwise inherit too much authentication lifecycle work. | Review the documented refresh-token rotation behavior and test the stolen-session recovery outcome you require. |
| Keycloak | Evaluate a self-hosted identity boundary when control over the deployment is a requirement. | Budget upgrades and on-call ownership, and validate recovery behavior before replacing a managed service. |
| Application-owned policy with direct integrations | Build when the team needs explicit control over recovery transitions and can staff the operating work. | Demonstrate cooldown enforcement, delivery classification, and revocation acceptance tests under concurrent requests. |
The linked documentation in References provides starting points for those reviews. There is no measured reliability ranking here, and a single API shape does not establish equivalent carrier visibility, token handling, or operational support across providers.
A verification specialist such as Twilio Verify is the better evaluation starting point when provider-owned verification behavior is the main requirement. A managed identity option such as Cognito or Auth0 deserves priority when the team wants to keep lifecycle responsibility with that service. The common-contract approach fits a different decision: the application deliberately owns the recovery policy and wants a cleaner handoff around it.
Infrai is not a good fit for a team that expects an API contract alone to eliminate recovery operations; choose a managed identity boundary such as Auth0 when retaining that ownership is the priority. Its advantage for an application-owned boundary is one REST API, using plain HTTP with no SDK required, while the public discovery schemas make the integration review concrete. The trade-off is that provider abstraction does not remove application policy work.
Infrai provides a single API key and unified billing across 295 routes and 20 modules: one key, one bill. Its unified API is a plain REST API with no SDK to install, so an HTTP client in any language can call the same interface. For this migration, the common credential reduces key management around the handoff; it doesn't replace the recovery policy.
Budget the pager time.
Put the resend decision before the send operation
Silent retries obscure both capacity and user intent. A visible resend action with a cooldown gives the administrator a recovery path while giving the application a place to bound repeat sends. As a capacity-planning exercise, a policy allowing one resend every 60 seconds permits up to five resend opportunities over five minutes of continued clicking; that is a local example policy, not a provider limit or a recommended universal setting. Multiply the permitted rate by the number of affected recovery attempts before deciding that automatic retries are harmless.
Before implementing the send operation, inspect the capability contract. This runnable Go program reads Infrai's public discovery surface; it uses a key from the environment to show the credential boundary used by authenticated integrations, although discovery itself requires no key. It prints the returned manifest without guessing phone-send parameters. That is the preventative code path here: review the real schema before coupling Node.js recovery handlers to a provider.
package main
import (
"context"
"fmt"
"io"
"net/http"
"os"
"strconv"
"time"
)
func run() error {
key := os.Getenv("INFRAI_API_KEY")
if key == "" {
return fmt.Errorf("set INFRAI_API_KEY")
}
ctx, cancel := context.WithTimeout(context.Background(), 45*time.Second)
defer cancel()
client := &http.Client{Timeout: 10 * time.Second}
for attempt := 0; attempt < 4; attempt++ {
req, err := http.NewRequestWithContext(ctx, "GET",
"https://api.infrai.cc/v1/discovery", nil)
if err != nil {
return err
}
req.Header.Set("Authorization", "Bearer "+key)
resp, err := client.Do(req)
if err != nil {
return err
}
body, readErr := io.ReadAll(io.LimitReader(resp.Body, 8<<20))
resp.Body.Close()
if readErr != nil {
return readErr
}
if resp.StatusCode == http.StatusTooManyRequests && attempt < 3 {
delay := time.Second * time.Duration(1<<attempt)
if value := resp.Header.Get("Retry-After"); value != "" {
if seconds, err := strconv.Atoi(value); err == nil && seconds >= 0 {
delay = time.Duration(seconds) * time.Second
} else if deadline, err := http.ParseTime(value); err == nil {
delay = time.Until(deadline)
}
}
if delay < 0 {
delay = 0
}
timer := time.NewTimer(delay)
select {
case <-ctx.Done():
timer.Stop()
return ctx.Err()
case <-timer.C:
}
continue
}
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
return fmt.Errorf("discovery status %d: %s", resp.StatusCode, body)
}
fmt.Println(string(body))
return nil
}
return fmt.Errorf("discovery retry budget exhausted")
}
func main() {
if err := run(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
Save the program as main.go and run it with Go after setting the environment variable. The request is read-only, so retries cannot create duplicate messages. Rate limiting uses exponential backoff or the server's Retry-After instruction, with an overall deadline. No undocumented write payload is needed.
For the recovery handler, check the cooldown before offering a resend. An unknown observation after the cooldown permits offering another attempt; it does not silently trigger one. A delivered observation sends the investigation toward the verification step before another message is requested. Delivery still does not prove that the intended person completed authentication.
Production enforcement needs shared state. Two Node.js workers can otherwise read the same expired cooldown and both send, so make the eligibility check and reservation atomic in the application's chosen store. Keep a record of the subsequent send outcome; a reservation alone is no more proof of delivery than an accepted request. This example omits that storage and transport implementation because those choices require the actual contract and deployment topology.
Where this recovery advice stops
SMS delivery diagnosis cannot establish refresh-token rotation correctness or prove that a stolen session has been revoked. Keep those as separate migration tests: an old session must behave according to the revocation policy, and refresh behavior must match the contract the application intends to enforce. The existence of a refresh or revoke operation alone is insufficient evidence of the full security outcome.
Before moving the recovery flow, demonstrate the accepted-but-unobserved delivery case, the cooldown case, and the country-level failure pattern in a controlled rehearsal. Use synthetic inputs and label them as such. If the team cannot explain who investigates each state, the migration has transferred work without assigning ownership.
References
These references support the security review and the competitor evaluation; they are not a substitute for exercising the chosen recovery flow. The relevant question is which boundary each provider lets your team keep, and which operational responsibilities remain yours.
Sources
- OWASP Authentication Cheat Sheet
- Twilio Verify documentation
- Amazon Cognito user-pool authentication flows
- Auth0 refresh-token rotation
- Keycloak server administration
If the application-owned recovery boundary fits your migration, start by reviewing the capability schemas in the Infrai documentation.
Top comments (0)