Skip to content

Commit

Permalink
sip: added headers to SIP inbound and output create requests (#332)
Browse files Browse the repository at this point in the history
* add headers to SIP inbound and output create requests

* added headers to trunk opts

* changeset
  • Loading branch information
s-hamdananwar authored Nov 9, 2024
1 parent ca7a43e commit 2aa5d09
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-comics-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-server-sdk": patch
---

SIP: added headers options to SIP inbound and output create requests
16 changes: 16 additions & 0 deletions packages/livekit-server-sdk/src/SipClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,16 @@ export interface CreateSipInboundTrunkOptions {
allowed_numbers?: string[];
auth_username?: string;
auth_password?: string;
headers?: { [key: string]: string };
headersToAttributes?: { [key: string]: string };
}
export interface CreateSipOutboundTrunkOptions {
metadata?: string;
transport: SIPTransport;
auth_username?: string;
auth_password?: string;
headers?: { [key: string]: string };
headersToAttributes?: { [key: string]: string };
}

export interface SipDispatchRuleDirect {
Expand Down Expand Up @@ -177,13 +181,17 @@ export class SipClient extends ServiceBase {
let authUsername: string = '';
let authPassword: string = '';
let metadata: string = '';
let headers: { [key: string]: string } = {};
let headersToAttributes: { [key: string]: string } = {};

if (opts !== undefined) {
allowedAddresses = opts.allowed_addresses;
allowedNumbers = opts.allowed_numbers;
authUsername = opts.auth_username || '';
authPassword = opts.auth_password || '';
metadata = opts.metadata || '';
headers = opts.headers || {};
headersToAttributes = opts.headersToAttributes || {};
}

const req = new CreateSIPInboundTrunkRequest({
Expand All @@ -195,6 +203,8 @@ export class SipClient extends ServiceBase {
allowedNumbers: allowedNumbers,
authUsername: authUsername,
authPassword: authPassword,
headers: headers,
headersToAttributes: headersToAttributes,
}),
}).toJson();

Expand Down Expand Up @@ -223,12 +233,16 @@ export class SipClient extends ServiceBase {
let authPassword: string = '';
let transport: SIPTransport = SIPTransport.SIP_TRANSPORT_AUTO;
let metadata: string = '';
let headers: { [key: string]: string } = {};
let headersToAttributes: { [key: string]: string } = {};

if (opts !== undefined) {
authUsername = opts.auth_username || '';
authPassword = opts.auth_password || '';
transport = opts.transport || SIPTransport.SIP_TRANSPORT_AUTO;
metadata = opts.metadata || '';
headers = opts.headers || {};
headersToAttributes = opts.headersToAttributes || {};
}

const req = new CreateSIPOutboundTrunkRequest({
Expand All @@ -240,6 +254,8 @@ export class SipClient extends ServiceBase {
transport: transport,
authUsername: authUsername,
authPassword: authPassword,
headers: headers,
headersToAttributes: headersToAttributes,
}),
}).toJson();

Expand Down

0 comments on commit 2aa5d09

Please sign in to comment.