Skip to content

Commit f10e983

Browse files
Sanitize account-specific values for template distribution
- Replace hardcoded TWIML_APP_SID with process.env.TWIML_APP_SID in tests - Replace hardcoded serverless domain (vibe-clauding-8464-dev.twil.io) with env var references in scripts, tests, and postman config - Add validation for missing SERVERLESS_DOMAIN in scripts - Update docs to use placeholder domain (your-domain.twil.io) - Delete stale backup file (conference-orchestrator.test.js.bak) This prevents external users from accidentally running tests/scripts against internal Twilio resources. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 462ec4d commit f10e983

11 files changed

Lines changed: 47 additions & 501 deletions

docs/api-documentation.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ const client = twilio(accountSid, authToken);
307307

308308
const result = await createConference(
309309
client,
310-
'APf6ae15d8f3df8d16e98d9d1afeb9e6b6', // TwiML App SID
310+
'APxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', // TwiML App SID
311311
'+15559998888', // Agent phone
312312
'+15551234567', // Customer phone
313313
{ strategy: 'random' }
@@ -361,7 +361,7 @@ const participant = await addCustomerToConference(
361361
client,
362362
'CFxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
363363
{ CustomerName: 'Lucy Macintosh' },
364-
'APf6ae15d8f3df8d16e98d9d1afeb9e6b6',
364+
'APxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
365365
'+15551234567'
366366
);
367367

@@ -370,7 +370,7 @@ console.log(`Customer added: ${participant.callSid}`);
370370

371371
**TwiML Application URL Format:**
372372
```
373-
app:APf6ae15d8f3df8d16e98d9d1afeb9e6b6?role=customer&persona=Lucy%20Macintosh&conferenceId=CFxxx
373+
app:APxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx?role=customer&persona=Lucy%20Macintosh&conferenceId=CFxxx
374374
```
375375

376376
#### `addAgentToConference(twilioClient, conferenceSid, agent, twimlAppSid, agentPhoneNumber)`
@@ -410,7 +410,7 @@ const participant = await addAgentToConference(
410410
client,
411411
'CFxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
412412
{ AgentName: 'Sarah' },
413-
'APf6ae15d8f3df8d16e98d9d1afeb9e6b6',
413+
'APxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
414414
'+15559998888'
415415
);
416416

@@ -419,7 +419,7 @@ console.log(`Agent added with OpenAI: ${participant.callSid}`);
419419

420420
**TwiML Application URL Format:**
421421
```
422-
app:APf6ae15d8f3df8d16e98d9d1afeb9e6b6?role=agent&persona=Sarah&conferenceId=CFxxx
422+
app:APxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx?role=agent&persona=Sarah&conferenceId=CFxxx
423423
```
424424

425425
---

docs/error-handling-guide.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ This system implements a **multi-layered error handling strategy** to capture, m
2626
- All Twilio service errors/warnings
2727

2828
**Function:** `/error-handler`
29-
**URL:** `https://vibe-clauding-8464-dev.twil.io/error-handler`
29+
**URL:** `https://your-domain.twil.io/error-handler`
3030

3131
**How it works:**
3232
1. Twilio Debugger detects error/warning
@@ -82,7 +82,7 @@ The error-handler function is already deployed:
8282
twilio serverless:deploy --override-existing-project
8383
```
8484

85-
**Deployed URL:** `https://vibe-clauding-8464-dev.twil.io/error-handler`
85+
**Deployed URL:** `https://your-domain.twil.io/error-handler`
8686

8787
### Step 3: Configure Debugger Webhook (MANUAL)
8888

@@ -98,7 +98,7 @@ This displays configuration instructions.
9898
1. Go to: https://console.twilio.com/us1/monitor/debugger
9999
2. Click **Settings** (gear icon in top right)
100100
3. Under "Webhook", enter:
101-
`https://vibe-clauding-8464-dev.twil.io/error-handler`
101+
`https://your-domain.twil.io/error-handler`
102102
4. Click **Save**
103103

104104
**Verification:**

postman/environment.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
{
2323
"key": "BASE_URL",
24-
"value": "https://vibe-clauding-8464-dev.twil.io",
24+
"value": "{{$processEnvironment SERVERLESS_DOMAIN}}",
2525
"type": "default",
2626
"enabled": true
2727
},

scripts/configure-debugger-webhook.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ async function configureDebuggerWebhook() {
2626

2727
const accountSid = process.env.TWILIO_ACCOUNT_SID;
2828
const authToken = process.env.TWILIO_AUTH_TOKEN;
29-
const serverlessDomain =
30-
process.env.SERVERLESS_DOMAIN || 'vibe-clauding-8464-dev.twil.io';
29+
const serverlessDomain = process.env.SERVERLESS_DOMAIN;
3130

32-
if (!accountSid || !authToken) {
31+
if (!accountSid || !authToken || !serverlessDomain) {
3332
console.error(
34-
`${colors.red}✗ Missing TWILIO_ACCOUNT_SID or TWILIO_AUTH_TOKEN${colors.reset}`
33+
`${colors.red}✗ Missing required environment variables${colors.reset}`
3534
);
35+
if (!accountSid) console.error(`${colors.red} - TWILIO_ACCOUNT_SID${colors.reset}`);
36+
if (!authToken) console.error(`${colors.red} - TWILIO_AUTH_TOKEN${colors.reset}`);
37+
if (!serverlessDomain) console.error(`${colors.red} - SERVERLESS_DOMAIN${colors.reset}`);
3638
process.exit(1);
3739
}
3840

scripts/test-error-handling.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33

44
const https = require('https');
55

6-
const DOMAIN =
7-
process.env.SERVERLESS_DOMAIN || 'vibe-clauding-8464-dev.twil.io';
6+
const DOMAIN = process.env.SERVERLESS_DOMAIN;
7+
8+
if (!DOMAIN) {
9+
console.error('❌ Missing required environment variable: SERVERLESS_DOMAIN');
10+
console.error(' Set it in your .env file or export it before running this script.');
11+
process.exit(1);
12+
}
813

914
function makeRequest(path, data) {
1015
return new Promise((resolve, reject) => {

tests/e2e/full-pipeline.test.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ jest.mock('@segment/analytics-node', () => {
4747

4848
describe('Full Pipeline Integration Tests', () => {
4949
let twilioClient;
50+
const TWIML_APP_SID = process.env.TWIML_APP_SID || 'APxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
5051

5152
beforeEach(() => {
5253
// Reset all mocks to clear implementations and call history
@@ -121,7 +122,7 @@ describe('Full Pipeline Integration Tests', () => {
121122
// Step 2: Create conference with paired customer and agent
122123
const conferenceResult = await conferenceOrchestrator.createConference(
123124
twilioClient,
124-
'APf6ae15d8f3df8d16e98d9d1afeb9e6b6',
125+
TWIML_APP_SID,
125126
agentPhoneNumber,
126127
'+15551234567'
127128
);
@@ -217,7 +218,7 @@ describe('Full Pipeline Integration Tests', () => {
217218
mockConferenceCreate.mockRejectedValueOnce(new Error('Twilio API error'));
218219

219220
await expect(
220-
conferenceOrchestrator.createConference(twilioClient, "APf6ae15d8f3df8d16e98d9d1afeb9e6b6", agentPhoneNumber, "+15551234567")
221+
conferenceOrchestrator.createConference(twilioClient, TWIML_APP_SID, agentPhoneNumber, "+15551234567")
221222
).rejects.toThrow('Twilio API error');
222223

223224
// Should not leave orphaned resources
@@ -248,7 +249,7 @@ describe('Full Pipeline Integration Tests', () => {
248249
});
249250

250251
await expect(
251-
conferenceOrchestrator.createConference(twilioClient, "APf6ae15d8f3df8d16e98d9d1afeb9e6b6", agentPhoneNumber, "+15551234567")
252+
conferenceOrchestrator.createConference(twilioClient, TWIML_APP_SID, agentPhoneNumber, "+15551234567")
252253
).rejects.toThrow();
253254

254255
// Should attempt rollback
@@ -322,7 +323,7 @@ describe('Full Pipeline Integration Tests', () => {
322323
.map(() =>
323324
conferenceOrchestrator.createConference(
324325
twilioClient,
325-
'APf6ae15d8f3df8d16e98d9d1afeb9e6b6',
326+
TWIML_APP_SID,
326327
agentPhoneNumber,
327328
'+15551234567'
328329
)
@@ -357,7 +358,7 @@ describe('Full Pipeline Integration Tests', () => {
357358

358359
const result = await conferenceOrchestrator.createConference(
359360
twilioClient,
360-
'APf6ae15d8f3df8d16e98d9d1afeb9e6b6',
361+
TWIML_APP_SID,
361362
agentPhoneNumber,
362363
'+15551234567',
363364
{ strategy: 'frustrated' }

tests/e2e/newman-collection.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ describe('Postman Collection Structure', () => {
168168
it('should have BASE_URL variable', () => {
169169
const baseUrl = environment.values.find(v => v.key === 'BASE_URL');
170170
expect(baseUrl).toBeDefined();
171-
expect(baseUrl.value).toContain('twil.io');
171+
expect(baseUrl.value).toContain('SERVERLESS_DOMAIN');
172172
});
173173
});
174174

tests/e2e/transcript-content-validation.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const { execSync } = require('child_process');
99
jest.setTimeout(600000); // 10 minutes
1010

1111
describe('Transcript Content Validation - E2E', () => {
12-
const DOMAIN = process.env.DOMAIN_NAME || 'vibe-clauding-8464-dev.twil.io';
12+
const DOMAIN = process.env.SERVERLESS_DOMAIN;
1313
const VOICE_INTELLIGENCE_SID = process.env.VOICE_INTELLIGENCE_SID;
1414
const TWILIO_ACCOUNT_SID = process.env.TWILIO_ACCOUNT_SID;
1515
const TWILIO_AUTH_TOKEN = process.env.TWILIO_AUTH_TOKEN;

tests/integration/orchestration/conference-orchestrator.test.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const createMockTwilioClient = () => {
3535

3636
describe.skip('Conference Orchestrator Integration (DEPRECATED - LEGACY CODE)', () => {
3737
let client;
38+
const TWIML_APP_SID = process.env.TWIML_APP_SID || 'APxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
3839

3940
beforeEach(() => {
4041
client = createMockTwilioClient();
@@ -73,7 +74,7 @@ describe.skip('Conference Orchestrator Integration (DEPRECATED - LEGACY CODE)',
7374

7475
const result = await conferenceOrchestrator.createConference(
7576
client,
76-
'APf6ae15d8f3df8d16e98d9d1afeb9e6b6',
77+
TWIML_APP_SID,
7778
agentPhoneNumber,
7879
'+15551234567'
7980
);
@@ -134,7 +135,7 @@ describe.skip('Conference Orchestrator Integration (DEPRECATED - LEGACY CODE)',
134135

135136
const result = await conferenceOrchestrator.createConference(
136137
client,
137-
'APf6ae15d8f3df8d16e98d9d1afeb9e6b6',
138+
TWIML_APP_SID,
138139
agentPhoneNumber,
139140
'+15551234567'
140141
);
@@ -166,7 +167,7 @@ describe.skip('Conference Orchestrator Integration (DEPRECATED - LEGACY CODE)',
166167

167168
const result = await conferenceOrchestrator.createConference(
168169
client,
169-
'APf6ae15d8f3df8d16e98d9d1afeb9e6b6',
170+
TWIML_APP_SID,
170171
agentPhoneNumber,
171172
'+15551234567',
172173
{ strategy: 'frustrated' }
@@ -191,7 +192,7 @@ describe.skip('Conference Orchestrator Integration (DEPRECATED - LEGACY CODE)',
191192
conferenceSid: conferenceSid,
192193
});
193194

194-
await conferenceOrchestrator.createConference(client, "APf6ae15d8f3df8d16e98d9d1afeb9e6b6", agentPhoneNumber, "+15551234567");
195+
await conferenceOrchestrator.createConference(client, TWIML_APP_SID, agentPhoneNumber, "+15551234567");
195196

196197
expect(mockConferenceCreate).toHaveBeenCalledWith(
197198
expect.objectContaining({
@@ -219,7 +220,7 @@ describe.skip('Conference Orchestrator Integration (DEPRECATED - LEGACY CODE)',
219220

220221
const result = await conferenceOrchestrator.createConference(
221222
client,
222-
'APf6ae15d8f3df8d16e98d9d1afeb9e6b6',
223+
TWIML_APP_SID,
223224
agentPhoneNumber,
224225
'+15551234567'
225226
);
@@ -237,7 +238,7 @@ describe.skip('Conference Orchestrator Integration (DEPRECATED - LEGACY CODE)',
237238
mockConferenceCreate.mockRejectedValue(conferenceError);
238239

239240
await expect(
240-
conferenceOrchestrator.createConference(client, "APf6ae15d8f3df8d16e98d9d1afeb9e6b6", agentPhoneNumber, "+15551234567")
241+
conferenceOrchestrator.createConference(client, TWIML_APP_SID, agentPhoneNumber, "+15551234567")
241242
).rejects.toThrow('Failed to create conference');
242243
});
243244

@@ -266,7 +267,7 @@ describe.skip('Conference Orchestrator Integration (DEPRECATED - LEGACY CODE)',
266267
});
267268

268269
await expect(
269-
conferenceOrchestrator.createConference(client, "APf6ae15d8f3df8d16e98d9d1afeb9e6b6", agentPhoneNumber, "+15551234567")
270+
conferenceOrchestrator.createConference(client, TWIML_APP_SID, agentPhoneNumber, "+15551234567")
270271
).rejects.toThrow('Failed to add customer');
271272

272273
// Verify rollback was attempted
@@ -307,7 +308,7 @@ describe.skip('Conference Orchestrator Integration (DEPRECATED - LEGACY CODE)',
307308
});
308309

309310
await expect(
310-
conferenceOrchestrator.createConference(client, "APf6ae15d8f3df8d16e98d9d1afeb9e6b6", agentPhoneNumber, "+15551234567")
311+
conferenceOrchestrator.createConference(client, TWIML_APP_SID, agentPhoneNumber, "+15551234567")
311312
).rejects.toThrow('Failed to add agent');
312313

313314
// Verify rollback was attempted
@@ -338,7 +339,7 @@ describe.skip('Conference Orchestrator Integration (DEPRECATED - LEGACY CODE)',
338339
mockConferenceUpdate.mockRejectedValue(new Error('Rollback failed'));
339340

340341
await expect(
341-
conferenceOrchestrator.createConference(client, "APf6ae15d8f3df8d16e98d9d1afeb9e6b6", agentPhoneNumber, "+15551234567")
342+
conferenceOrchestrator.createConference(client, TWIML_APP_SID, agentPhoneNumber, "+15551234567")
342343
).rejects.toThrow('Failed to add customer');
343344

344345
// Should still attempt rollback even if it fails
@@ -362,7 +363,7 @@ describe.skip('Conference Orchestrator Integration (DEPRECATED - LEGACY CODE)',
362363
conferenceSid: conferenceSid,
363364
});
364365

365-
await conferenceOrchestrator.createConference(client, "APf6ae15d8f3df8d16e98d9d1afeb9e6b6", agentPhoneNumber, "+15551234567");
366+
await conferenceOrchestrator.createConference(client, TWIML_APP_SID, agentPhoneNumber, "+15551234567");
366367

367368
expect(mockConferenceCreate).toHaveBeenCalledWith(
368369
expect.objectContaining({
@@ -391,7 +392,7 @@ describe.skip('Conference Orchestrator Integration (DEPRECATED - LEGACY CODE)',
391392

392393
const result = await conferenceOrchestrator.createConference(
393394
client,
394-
'APf6ae15d8f3df8d16e98d9d1afeb9e6b6',
395+
TWIML_APP_SID,
395396
agentPhoneNumber,
396397
'+15551234567'
397398
);
@@ -409,13 +410,13 @@ describe.skip('Conference Orchestrator Integration (DEPRECATED - LEGACY CODE)',
409410
const invalidPhone = '5129998888'; // Missing +
410411

411412
await expect(
412-
conferenceOrchestrator.createConference(client, "APf6ae15d8f3df8d16e98d9d1afeb9e6b6", invalidPhone, "+15551234567")
413+
conferenceOrchestrator.createConference(client, TWIML_APP_SID, invalidPhone, "+15551234567")
413414
).rejects.toThrow('E.164 format');
414415
});
415416

416417
it('should require agent phone number', async () => {
417418
await expect(
418-
conferenceOrchestrator.createConference(client, "APf6ae15d8f3df8d16e98d9d1afeb9e6b6", null, "+15551234567")
419+
conferenceOrchestrator.createConference(client, TWIML_APP_SID, null, "+15551234567")
419420
).rejects.toThrow('Agent phone number is required');
420421
});
421422
});
@@ -449,7 +450,7 @@ describe.skip('Conference Orchestrator Integration (DEPRECATED - LEGACY CODE)',
449450
conferenceSid: conferenceSid,
450451
});
451452

452-
await conferenceOrchestrator.createConference(client, "APf6ae15d8f3df8d16e98d9d1afeb9e6b6", agentPhoneNumber, "+15551234567");
453+
await conferenceOrchestrator.createConference(client, TWIML_APP_SID, agentPhoneNumber, "+15551234567");
453454

454455
expect(consoleLogSpy).toHaveBeenCalledWith(
455456
expect.stringContaining('Creating conference')
@@ -468,7 +469,7 @@ describe.skip('Conference Orchestrator Integration (DEPRECATED - LEGACY CODE)',
468469
mockConferenceCreate.mockRejectedValue(new Error('API error'));
469470

470471
await expect(
471-
conferenceOrchestrator.createConference(client, "APf6ae15d8f3df8d16e98d9d1afeb9e6b6", agentPhoneNumber, "+15551234567")
472+
conferenceOrchestrator.createConference(client, TWIML_APP_SID, agentPhoneNumber, "+15551234567")
472473
).rejects.toThrow();
473474

474475
expect(consoleErrorSpy).toHaveBeenCalled();

0 commit comments

Comments
 (0)