Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sip: added headers to SIP inbound and output create requests #332

Merged
merged 3 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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