Skip to content
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
66 changes: 66 additions & 0 deletions lib/Constants.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
export const USER_AGENT: string
export const SIP = 'sip'
export const SIPS = 'sips'

export enum causes {
CONNECTION_ERROR = 'Connection Error',
REQUEST_TIMEOUT = 'Request Timeout',
SIP_FAILURE_CODE = 'SIP Failure Code',
INTERNAL_ERROR = 'Internal Error',
BUSY = 'Busy',
REJECTED = 'Rejected',
REDIRECTED = 'Redirected',
UNAVAILABLE = 'Unavailable',
NOT_FOUND = 'Not Found',
ADDRESS_INCOMPLETE = 'Address Incomplete',
INCOMPATIBLE_SDP = 'Incompatible SDP',
MISSING_SDP = 'Missing SDP',
AUTHENTICATION_ERROR = 'Authentication Error',
BYE = 'Terminated',
WEBRTC_ERROR = 'WebRTC Error',
CANCELED = 'Canceled',
NO_ANSWER = 'No Answer',
EXPIRES = 'Expires',
NO_ACK = 'No ACK',
DIALOG_ERROR = 'Dialog Error',
USER_DENIED_MEDIA_ACCESS = 'User Denied Media Access',
BAD_MEDIA_DESCRIPTION = 'Bad Media Description',
RTP_TIMEOUT = 'RTP Timeout',
}

export const SIP_ERROR_CAUSES: {
REDIRECTED: [300, 301, 302, 305, 380],
BUSY: [486, 600],
REJECTED: [403, 603],
NOT_FOUND: [404, 604],
UNAVAILABLE: [480, 410, 408, 430],
ADDRESS_INCOMPLETE: [484, 424],
INCOMPATIBLE_SDP: [488, 606],
AUTHENTICATION_ERROR: [401, 407]
}
export const ACK = 'ACK'
export const BYE = 'BYE'
export const CANCEL = 'CANCEL'
export const INFO = 'INFO'
export const INVITE = 'INVITE'
export const MESSAGE = 'MESSAGE'
export const NOTIFY = 'NOTIFY'
export const OPTIONS = 'OPTIONS'
export const REGISTER = 'REGISTER'
export const REFER = 'REFER'
export const UPDATE = 'UPDATE'
export const SUBSCRIBE = 'SUBSCRIBE'

export enum DTMF_TRANSPORT {
INFO = 'INFO',
RFC2833 = 'RFC2833',
}

export const REASON_PHRASE: Record<number, string>
export const ALLOWED_METHODS = 'INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY'
export const ACCEPTED_BODY_TYPES = 'application/sdp, application/dtmf-relay'
export const MAX_FORWARDS = 69
export const SESSION_EXPIRES = 90
export const MIN_SESSION_EXPIRES = 60
export const CONNECTION_RECOVERY_MAX_INTERVAL = 30
export const CONNECTION_RECOVERY_MIN_INTERVAL = 2
24 changes: 24 additions & 0 deletions lib/Exceptions.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
declare class BaseError extends Error {
code: number
}

export class ConfigurationError extends BaseError {
parameter: string
value: any

constructor(parameter: string, value?: any);
}

export class InvalidStateError extends BaseError {
status: number

constructor(status: number);
}

export class NotSupportedError extends BaseError {
constructor(message: string);
}

export class NotReadyError extends BaseError {
constructor(message: string);
}
5 changes: 5 additions & 0 deletions lib/Grammar.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export type Grammar = any;

export function parse(input: string, startRule?: string): Grammar;

export function toSource(): any;
14 changes: 14 additions & 0 deletions lib/JsSIP.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {Debug} from 'debug'

export * as C from './Constants'
export * as Exceptions from './Exceptions'
export * as Utils from './Utils'
export {UA} from './UA'
export {URI} from './URI'
export {NameAddrHeader} from './NameAddrHeader'
export {WebSocketInterface} from './WebSocketInterface'
export * as Grammar from './Grammar'

export const debug: Debug
export const name: string
export const version: string
45 changes: 45 additions & 0 deletions lib/Message.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/// <reference types="node" />
import {EventEmitter} from 'events'

import {ExtraHeaders, Originator, OutgoingListener, SessionDirection, TerminateOptions} from './RTCSession'
import {IncomingResponse} from './SIPMessage'
import {NameAddrHeader} from './NameAddrHeader'
import {causes} from './Constants';

export interface AcceptOptions extends ExtraHeaders {
body?: string;
}

export interface MessageFailedEvent {
originator: Originator;
response: IncomingResponse;
cause?: causes;
}

export type MessageFailedListener = (event: MessageFailedEvent) => void;

export interface MessageEventMap {
succeeded: OutgoingListener;
failed: MessageFailedListener;
}

export interface SendMessageOptions extends ExtraHeaders {
contentType?: string;
eventHandlers?: Partial<MessageEventMap>;
}

export class Message extends EventEmitter {
get direction(): SessionDirection;

get local_identity(): NameAddrHeader;

get remote_identity(): NameAddrHeader;

send(target: string, body: string, options?: SendMessageOptions): void;

accept(options: AcceptOptions): void;

reject(options: TerminateOptions): void;

on<T extends keyof MessageEventMap>(type: T, listener: MessageEventMap[T]): this;
}
27 changes: 27 additions & 0 deletions lib/NameAddrHeader.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {Parameters, URI} from './URI'
import {Grammar} from './Grammar'

export class NameAddrHeader {
get display_name(): string;
set display_name(value: string);

get uri(): URI;

constructor(uri: URI, display_name?: string, parameters?: Parameters);

setParam(key: string, value?: string): void;

getParam<T = any>(key: string): T;

hasParam(key: string): boolean;

deleteParam(key: string): void;

clearParams(): void;

clone(): this;

toString(): string;

static parse(uri: string): Grammar | undefined;
}
Loading