- Route Twilio Lookup v2 through the on-prem remote agent so all
third-party calls (SIW, Google, Twilio) share the same network path
and future IP allow-lists / corp proxies don't break it silently
- Delete unused GOOGLE_APPLICATION_CREDENTIALS / serviceAccountKeyPath
wiring in config.js, .env.example, and README (never read by any code)
- Extract 150 lines of STORE_DEVICE_CUSTOMIZATIONS out of
src/webex/devices.js into src/webex/deviceCustomizations.js so device
config diffs are self-contained and devices.js stays focused on API
- runStep learns a {critical: true} option that re-throws on failure
instead of the legacy always-swallow behavior; mark
enableLocationForCalling critical in buildStore + stageStore so a
failure there aborts the flow cleanly rather than cascading into
dozens of downstream 404s
Co-authored-by: Cursor <cursoragent@cursor.com>
31 lines
1.3 KiB
JavaScript
31 lines
1.3 KiB
JavaScript
import { config } from '../config.js';
|
|
import { proxyRequest } from '../services/websocket.js';
|
|
|
|
// Twilio's Lookup v2 has no IP allow-list requirement today, but every other
|
|
// third-party call in this bot (SIW, Google) is already proxied through the
|
|
// on-prem agent. Doing the same for Twilio keeps the network surface
|
|
// consistent — if Twilio ever adds IP restrictions, or the bot moves behind
|
|
// a corporate egress proxy, this call keeps working without a code change.
|
|
// `insecure` is not set here: Twilio uses public CAs that Node trusts, and
|
|
// the agent's host reaches lookups.twilio.com without an SSL-inspecting hop.
|
|
|
|
function twilioAuthHeaders() {
|
|
const auth = Buffer.from(`${config.twilio.accountSid}:${config.twilio.authToken}`).toString(
|
|
'base64',
|
|
);
|
|
return { Authorization: `Basic ${auth}` };
|
|
}
|
|
|
|
/**
|
|
* Look up a phone number via Twilio's Lookup v2. Returns the raw response
|
|
* body; callers typically use `.phone_number` (E.164 normalized).
|
|
*/
|
|
export async function validatePhoneNumber(phoneNumber) {
|
|
const url = `https://lookups.twilio.com/v2/PhoneNumbers/${encodeURIComponent(phoneNumber)}`;
|
|
const response = await proxyRequest({
|
|
method: 'GET',
|
|
url,
|
|
headers: twilioAuthHeaders(),
|
|
});
|
|
return response?.data;
|
|
}
|