@voicenter-team/opensips-js 1.0.20 → 1.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,12 @@
1
+ export default class MSRPMessage {
2
+ constructor(msg: any);
3
+ headers: {};
4
+ protocol: any;
5
+ ident: any;
6
+ code: number | undefined;
7
+ method: any;
8
+ body: string | undefined;
9
+ addHeader(name: any, content: any): void;
10
+ getHeader(name: any): any;
11
+ toString(): string;
12
+ }
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const Utils = __importStar(require("jssip/lib/Utils"));
27
+ class MSRPMessage {
28
+ constructor(msg) {
29
+ this.headers = {};
30
+ if (msg.length > 0) {
31
+ let _hasBody = false;
32
+ const msgLines = msg.split('\r\n');
33
+ const msgHeadLineArray = msgLines.shift().split(/\s/);
34
+ this.protocol = msgHeadLineArray[0];
35
+ this.ident = msgHeadLineArray[1];
36
+ this.code = (msgHeadLineArray.length > 3) ?
37
+ parseInt(msgHeadLineArray[2]) : 0;
38
+ this.method = (msgHeadLineArray.length > 3) ?
39
+ msgHeadLineArray[3] : msgHeadLineArray[2];
40
+ this.body = '';
41
+ for (const msgLine of msgLines) {
42
+ if (msgLine == `-------${this.ident}$`) {
43
+ break;
44
+ }
45
+ if (msgLine === '') {
46
+ _hasBody = true;
47
+ continue;
48
+ }
49
+ if (msgLine && _hasBody) {
50
+ this.body += `${msgLine}\r\n`;
51
+ }
52
+ else {
53
+ const msgLineArray = msgLine.split(': ');
54
+ this.addHeader(msgLineArray[0], msgLineArray[1].trim());
55
+ }
56
+ }
57
+ }
58
+ else {
59
+ this.ident = Utils.createRandomToken(12);
60
+ this.protocol = 'MSRP';
61
+ }
62
+ }
63
+ addHeader(name, content) {
64
+ this.headers[name] = content;
65
+ }
66
+ getHeader(name) {
67
+ return this.headers[name];
68
+ }
69
+ toString() {
70
+ let _msg = `${this.protocol} ${this.ident} ${this.code} ${this.method}`
71
+ .replaceAll(/null\s|undefined\s/ig, '') + '\r\n';
72
+ for (const _header in this.headers) {
73
+ _msg += `${_header}: ${this.headers[_header]}\r\n`;
74
+ }
75
+ if (this.body) {
76
+ _msg += `\r\n${this.body}\r\n`;
77
+ }
78
+ _msg += `-------${this.ident}$\r\n`;
79
+ return _msg;
80
+ }
81
+ }
82
+ exports.default = MSRPMessage;
@@ -0,0 +1,94 @@
1
+ export class MSRPSession extends EventEmitter {
2
+ /**
3
+ * Expose C object.
4
+ */
5
+ static get C(): {
6
+ STATUS_NULL: number;
7
+ STATUS_INVITE_SENT: number;
8
+ STATUS_1XX_RECEIVED: number;
9
+ STATUS_INVITE_RECEIVED: number;
10
+ STATUS_WAITING_FOR_ANSWER: number;
11
+ STATUS_ANSWERED: number;
12
+ STATUS_WAITING_FOR_ACK: number;
13
+ STATUS_CANCELED: number;
14
+ STATUS_TERMINATED: number;
15
+ STATUS_CONFIRMED: number;
16
+ };
17
+ constructor(ua: any);
18
+ _id: any;
19
+ my_ip: string;
20
+ _ua: any;
21
+ auth_id: any;
22
+ _status: number;
23
+ _dialog: any;
24
+ _earlyDialogs: {};
25
+ _contact: any;
26
+ _from_tag: any;
27
+ _to_tag: any;
28
+ _msgHistory: any[];
29
+ target_addr: any[];
30
+ my_addr: any[];
31
+ credentials: {
32
+ username: any;
33
+ ha1: any;
34
+ realm: any;
35
+ };
36
+ _request: any;
37
+ status: string;
38
+ target: string;
39
+ message: string;
40
+ _timers: {
41
+ ackTimer: null;
42
+ expiresTimer: null;
43
+ invite2xxTimer: null;
44
+ userNoAnswerTimer: null;
45
+ };
46
+ _direction: string | null;
47
+ _local_identity: any;
48
+ _remote_identity: any;
49
+ _start_time: any;
50
+ _end_time: any;
51
+ _tones: any;
52
+ _sessionTimers: {
53
+ enabled: any;
54
+ refreshMethod: any;
55
+ defaultExpires: number;
56
+ currentExpires: null;
57
+ running: boolean;
58
+ refresher: boolean;
59
+ timer: null;
60
+ };
61
+ get direction(): string | null;
62
+ get connection(): WebSocket | undefined;
63
+ get id(): any;
64
+ connect(target?: string): void;
65
+ _connection: WebSocket | undefined;
66
+ answer(): void;
67
+ acceptParty(msgObj: any): void;
68
+ terminate(options?: {}): void;
69
+ _is_canceled: boolean | undefined;
70
+ _cancel_reason: string | undefined;
71
+ receiveRequest: (({ method }: {
72
+ method: any;
73
+ }) => void) | undefined;
74
+ sendRequest(method: any, options: any): any;
75
+ authenticate(auth: any): void;
76
+ onmessage(msg: any): void;
77
+ onclose(): void;
78
+ onopen(): void;
79
+ onerror(e: any): void;
80
+ inviteParty(msgObj: any): void;
81
+ sendMSRP(message: any): void;
82
+ _sendOk(msgObj: any): void;
83
+ _sendReport(msgObj: any): void;
84
+ parseAuth(content: any): {};
85
+ init_incoming(request: any, initCallback: any): void;
86
+ _late_sdp: boolean | undefined;
87
+ _failed(originator: any, message: any, cause: any): void;
88
+ _close(): void;
89
+ _createDialog(message: any, type: any, early: any): boolean;
90
+ _newMSRPSession(originator: any, request: any): void;
91
+ _progress(originator: any, response: any): void;
92
+ isEnded(): boolean;
93
+ }
94
+ import { EventEmitter } from "events";