From 7b11a56a53ccc3a704e68efef4806b2b3653768a Mon Sep 17 00:00:00 2001 From: Hoan Luu Huu <110280845+xquanluu@users.noreply.github.com> Date: Thu, 20 Jul 2023 20:10:41 +0700 Subject: [PATCH] feat siprec custom header (#400) * feat siprec custom header * wip * update verb specification * add newline to info siprec body * add newline to info siprec body --- lib/session/call-session.js | 11 +++++++---- package-lock.json | 14 +++++++------- package.json | 2 +- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/session/call-session.js b/lib/session/call-session.js index d48c451f..aa0b6df7 100644 --- a/lib/session/call-session.js +++ b/lib/session/call-session.js @@ -423,7 +423,10 @@ class CallSession extends Emitter { 'X-Call-Sid': this.callSid, 'X-Account-Sid': this.accountSid, 'X-Application-Sid': this.applicationSid, - } + ...(this.recordOptions.headers && {'Content-Type': 'application/json'}) + }, + // Siprect Client is initiated from startCallRecording, so just need to pass custom headers in startRecording + ...(this.recordOptions.headers && {body: JSON.stringify(this.recordOptions.headers) + '\n'}) }); if (res.status === 200) { this._recordState = RecordState.RecordingOn; @@ -444,7 +447,7 @@ class CallSession extends Emitter { const res = await this.dlg.request({ method: 'INFO', headers: { - 'X-Reason': 'stopCallRecording', + 'X-Reason': 'stopCallRecording' } }); if (res.status === 200) { @@ -466,7 +469,7 @@ class CallSession extends Emitter { const res = await this.dlg.request({ method: 'INFO', headers: { - 'X-Reason': 'pauseCallRecording', + 'X-Reason': 'pauseCallRecording' } }); if (res.status === 200) { @@ -488,7 +491,7 @@ class CallSession extends Emitter { const res = await this.dlg.request({ method: 'INFO', headers: { - 'X-Reason': 'resumeCallRecording', + 'X-Reason': 'resumeCallRecording' } }); if (res.status === 200) { diff --git a/package-lock.json b/package-lock.json index 62fe038c..e9df3ad4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "@jambonz/speech-utils": "^0.0.17", "@jambonz/stats-collector": "^0.1.8", "@jambonz/time-series": "^0.2.8", - "@jambonz/verb-specifications": "^0.0.25", + "@jambonz/verb-specifications": "^0.0.26", "@opentelemetry/api": "^1.4.0", "@opentelemetry/exporter-jaeger": "^1.9.0", "@opentelemetry/exporter-trace-otlp-http": "^0.35.0", @@ -3019,9 +3019,9 @@ } }, "node_modules/@jambonz/verb-specifications": { - "version": "0.0.25", - "resolved": "https://registry.npmjs.org/@jambonz/verb-specifications/-/verb-specifications-0.0.25.tgz", - "integrity": "sha512-Dq8bS9hNCWGm7CbSaAwMv3YzG6PI1tk3lOj0bFIF74FiLq/cIHtm4KsUwUMQPgJhED8Lbi0v3q63L98737ndbg==", + "version": "0.0.26", + "resolved": "https://registry.npmjs.org/@jambonz/verb-specifications/-/verb-specifications-0.0.26.tgz", + "integrity": "sha512-C/2KpX7dLPrEOFbcpyjJ3FkR8EEp+QbNmJoWbCcfYoZEyLiOcawWVwPRvz8hNPVa/Hf2Scth9OvjKeGuny33gQ==", "dependencies": { "debug": "^4.3.4", "pino": "^8.8.0" @@ -12985,9 +12985,9 @@ } }, "@jambonz/verb-specifications": { - "version": "0.0.25", - "resolved": "https://registry.npmjs.org/@jambonz/verb-specifications/-/verb-specifications-0.0.25.tgz", - "integrity": "sha512-Dq8bS9hNCWGm7CbSaAwMv3YzG6PI1tk3lOj0bFIF74FiLq/cIHtm4KsUwUMQPgJhED8Lbi0v3q63L98737ndbg==", + "version": "0.0.26", + "resolved": "https://registry.npmjs.org/@jambonz/verb-specifications/-/verb-specifications-0.0.26.tgz", + "integrity": "sha512-C/2KpX7dLPrEOFbcpyjJ3FkR8EEp+QbNmJoWbCcfYoZEyLiOcawWVwPRvz8hNPVa/Hf2Scth9OvjKeGuny33gQ==", "requires": { "debug": "^4.3.4", "pino": "^8.8.0" diff --git a/package.json b/package.json index 02de5986..e8ced9c4 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "@jambonz/speech-utils": "^0.0.17", "@jambonz/stats-collector": "^0.1.8", "@jambonz/time-series": "^0.2.8", - "@jambonz/verb-specifications": "^0.0.25", + "@jambonz/verb-specifications": "^0.0.26", "@opentelemetry/api": "^1.4.0", "@opentelemetry/exporter-jaeger": "^1.9.0", "@opentelemetry/exporter-trace-otlp-http": "^0.35.0",