Skip to content

Commit 2a672b5

Browse files
committed
dist/ lib/ files for 0.13.8
1 parent af0540a commit 2a672b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+83891
-0
lines changed

dist/sip-0.13.8.js

Lines changed: 27445 additions & 0 deletions
Large diffs are not rendered by default.

dist/sip-0.13.8.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/sip.js

Lines changed: 27445 additions & 0 deletions
Large diffs are not rendered by default.

dist/sip.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/ClientContext.d.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/// <reference types="node" />
2+
import { EventEmitter } from "events";
3+
import { TypeStrings } from "./Enums";
4+
import { Logger } from "./LoggerFactory";
5+
import { NameAddrHeader } from "./NameAddrHeader";
6+
import { IncomingResponse, OutgoingRequest } from "./SIPMessage";
7+
import { UA } from "./UA";
8+
import { URI } from "./URI";
9+
export declare class ClientContext extends EventEmitter {
10+
static initializer(objToConstruct: ClientContext, ua: UA, method: string, originalTarget: string | URI, options?: any): void;
11+
type: TypeStrings;
12+
data: any;
13+
ua: UA;
14+
logger: Logger;
15+
request: OutgoingRequest;
16+
method: string;
17+
body: any;
18+
localIdentity: NameAddrHeader;
19+
remoteIdentity: NameAddrHeader;
20+
constructor(ua: UA, method: string, target: string | URI, options?: any);
21+
send(): this;
22+
receiveResponse(response: IncomingResponse): void;
23+
onRequestTimeout(): void;
24+
onTransportError(): void;
25+
}

lib/ClientContext.js

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
"use strict";
2+
var __extends = (this && this.__extends) || (function () {
3+
var extendStatics = function (d, b) {
4+
extendStatics = Object.setPrototypeOf ||
5+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7+
return extendStatics(d, b);
8+
};
9+
return function (d, b) {
10+
extendStatics(d, b);
11+
function __() { this.constructor = d; }
12+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13+
};
14+
})();
15+
Object.defineProperty(exports, "__esModule", { value: true });
16+
var events_1 = require("events");
17+
var Constants_1 = require("./Constants");
18+
var Enums_1 = require("./Enums");
19+
var RequestSender_1 = require("./RequestSender");
20+
var SIPMessage_1 = require("./SIPMessage");
21+
var Utils_1 = require("./Utils");
22+
var ClientContext = /** @class */ (function (_super) {
23+
__extends(ClientContext, _super);
24+
function ClientContext(ua, method, target, options) {
25+
var _this = _super.call(this) || this;
26+
_this.data = {};
27+
ClientContext.initializer(_this, ua, method, target, options);
28+
return _this;
29+
}
30+
ClientContext.initializer = function (objToConstruct, ua, method, originalTarget, options) {
31+
objToConstruct.type = Enums_1.TypeStrings.ClientContext;
32+
// Validate arguments
33+
if (originalTarget === undefined) {
34+
throw new TypeError("Not enough arguments");
35+
}
36+
objToConstruct.ua = ua;
37+
objToConstruct.logger = ua.getLogger("sip.clientcontext");
38+
objToConstruct.method = method;
39+
var target = ua.normalizeTarget(originalTarget);
40+
if (!target) {
41+
throw new TypeError("Invalid target: " + originalTarget);
42+
}
43+
/* Options
44+
* - extraHeaders
45+
* - params
46+
* - contentType
47+
* - body
48+
*/
49+
options = Object.create(options || Object.prototype);
50+
options.extraHeaders = (options.extraHeaders || []).slice();
51+
// Build the request
52+
objToConstruct.request = new SIPMessage_1.OutgoingRequest(objToConstruct.method, target, objToConstruct.ua, options.params, options.extraHeaders);
53+
if (options.body) {
54+
objToConstruct.body = {};
55+
objToConstruct.body.body = options.body;
56+
if (options.contentType) {
57+
objToConstruct.body.contentType = options.contentType;
58+
}
59+
objToConstruct.request.body = objToConstruct.body;
60+
}
61+
/* Set other properties from the request */
62+
if (objToConstruct.request.from) {
63+
objToConstruct.localIdentity = objToConstruct.request.from;
64+
}
65+
if (objToConstruct.request.to) {
66+
objToConstruct.remoteIdentity = objToConstruct.request.to;
67+
}
68+
};
69+
ClientContext.prototype.send = function () {
70+
var sender = new RequestSender_1.RequestSender(this, this.ua);
71+
sender.send();
72+
return this;
73+
};
74+
ClientContext.prototype.receiveResponse = function (response) {
75+
var statusCode = response.statusCode || 0;
76+
var cause = Utils_1.Utils.getReasonPhrase(statusCode);
77+
switch (true) {
78+
case /^1[0-9]{2}$/.test(statusCode.toString()):
79+
this.emit("progress", response, cause);
80+
break;
81+
case /^2[0-9]{2}$/.test(statusCode.toString()):
82+
if (this.ua.applicants[this.toString()]) {
83+
delete this.ua.applicants[this.toString()];
84+
}
85+
this.emit("accepted", response, cause);
86+
break;
87+
default:
88+
if (this.ua.applicants[this.toString()]) {
89+
delete this.ua.applicants[this.toString()];
90+
}
91+
this.emit("rejected", response, cause);
92+
this.emit("failed", response, cause);
93+
break;
94+
}
95+
};
96+
ClientContext.prototype.onRequestTimeout = function () {
97+
this.emit("failed", undefined, Constants_1.C.causes.REQUEST_TIMEOUT);
98+
};
99+
ClientContext.prototype.onTransportError = function () {
100+
this.emit("failed", undefined, Constants_1.C.causes.CONNECTION_ERROR);
101+
};
102+
return ClientContext;
103+
}(events_1.EventEmitter));
104+
exports.ClientContext = ClientContext;

lib/Constants.d.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
export declare namespace C {
2+
const USER_AGENT: string;
3+
const SIP = "sip";
4+
const SIPS = "sips";
5+
enum causes {
6+
CONNECTION_ERROR = "Connection Error",
7+
INTERNAL_ERROR = "Internal Error",
8+
REQUEST_TIMEOUT = "Request Timeout",
9+
SIP_FAILURE_CODE = "SIP Failure Code",
10+
ADDRESS_INCOMPLETE = "Address Incomplete",
11+
AUTHENTICATION_ERROR = "Authentication Error",
12+
BUSY = "Busy",
13+
DIALOG_ERROR = "Dialog Error",
14+
INCOMPATIBLE_SDP = "Incompatible SDP",
15+
NOT_FOUND = "Not Found",
16+
REDIRECTED = "Redirected",
17+
REJECTED = "Rejected",
18+
UNAVAILABLE = "Unavailable",
19+
BAD_MEDIA_DESCRIPTION = "Bad Media Description",
20+
CANCELED = "Canceled",
21+
EXPIRES = "Expires",
22+
NO_ACK = "No ACK",
23+
NO_ANSWER = "No Answer",
24+
NO_PRACK = "No PRACK",
25+
RTP_TIMEOUT = "RTP Timeout",
26+
USER_DENIED_MEDIA_ACCESS = "User Denied Media Access",
27+
WEBRTC_ERROR = "WebRTC Error",
28+
WEBRTC_NOT_SUPPORTED = "WebRTC Not Supported"
29+
}
30+
enum supported {
31+
REQUIRED = "required",
32+
SUPPORTED = "supported",
33+
UNSUPPORTED = "none"
34+
}
35+
const SIP_ERROR_CAUSES: {
36+
[name: string]: Array<number>;
37+
};
38+
const ACK = "ACK";
39+
const BYE = "BYE";
40+
const CANCEL = "CANCEL";
41+
const INFO = "INFO";
42+
const INVITE = "INVITE";
43+
const MESSAGE = "MESSAGE";
44+
const NOTIFY = "NOTIFY";
45+
const OPTIONS = "OPTIONS";
46+
const REGISTER = "REGISTER";
47+
const UPDATE = "UPDATE";
48+
const SUBSCRIBE = "SUBSCRIBE";
49+
const PUBLISH = "PUBLISH";
50+
const REFER = "REFER";
51+
const PRACK = "PRACK";
52+
const REASON_PHRASE: {
53+
[code: number]: string;
54+
};
55+
const OPTION_TAGS: {
56+
[option: string]: boolean;
57+
};
58+
enum dtmfType {
59+
INFO = "info",
60+
RTP = "rtp"
61+
}
62+
}

lib/Constants.js

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
// tslint:disable-next-line:no-var-requires
4+
var pkg = require("../package.json");
5+
var C;
6+
(function (C) {
7+
C.USER_AGENT = pkg.title + "/" + pkg.version;
8+
// SIP scheme
9+
C.SIP = "sip";
10+
C.SIPS = "sips";
11+
// End and Failure causes
12+
var causes;
13+
(function (causes) {
14+
// Generic error causes
15+
causes["CONNECTION_ERROR"] = "Connection Error";
16+
causes["INTERNAL_ERROR"] = "Internal Error";
17+
causes["REQUEST_TIMEOUT"] = "Request Timeout";
18+
causes["SIP_FAILURE_CODE"] = "SIP Failure Code";
19+
// SIP error causes
20+
causes["ADDRESS_INCOMPLETE"] = "Address Incomplete";
21+
causes["AUTHENTICATION_ERROR"] = "Authentication Error";
22+
causes["BUSY"] = "Busy";
23+
causes["DIALOG_ERROR"] = "Dialog Error";
24+
causes["INCOMPATIBLE_SDP"] = "Incompatible SDP";
25+
causes["NOT_FOUND"] = "Not Found";
26+
causes["REDIRECTED"] = "Redirected";
27+
causes["REJECTED"] = "Rejected";
28+
causes["UNAVAILABLE"] = "Unavailable";
29+
// Session error causes
30+
causes["BAD_MEDIA_DESCRIPTION"] = "Bad Media Description";
31+
causes["CANCELED"] = "Canceled";
32+
causes["EXPIRES"] = "Expires";
33+
causes["NO_ACK"] = "No ACK";
34+
causes["NO_ANSWER"] = "No Answer";
35+
causes["NO_PRACK"] = "No PRACK";
36+
causes["RTP_TIMEOUT"] = "RTP Timeout";
37+
causes["USER_DENIED_MEDIA_ACCESS"] = "User Denied Media Access";
38+
causes["WEBRTC_ERROR"] = "WebRTC Error";
39+
causes["WEBRTC_NOT_SUPPORTED"] = "WebRTC Not Supported";
40+
})(causes = C.causes || (C.causes = {}));
41+
var supported;
42+
(function (supported) {
43+
supported["REQUIRED"] = "required";
44+
supported["SUPPORTED"] = "supported";
45+
supported["UNSUPPORTED"] = "none";
46+
})(supported = C.supported || (C.supported = {}));
47+
C.SIP_ERROR_CAUSES = {
48+
ADDRESS_INCOMPLETE: [484],
49+
AUTHENTICATION_ERROR: [401, 407],
50+
BUSY: [486, 600],
51+
INCOMPATIBLE_SDP: [488, 606],
52+
NOT_FOUND: [404, 604],
53+
REDIRECTED: [300, 301, 302, 305, 380],
54+
REJECTED: [403, 603],
55+
UNAVAILABLE: [480, 410, 408, 430]
56+
};
57+
// SIP Methods
58+
C.ACK = "ACK";
59+
C.BYE = "BYE";
60+
C.CANCEL = "CANCEL";
61+
C.INFO = "INFO";
62+
C.INVITE = "INVITE";
63+
C.MESSAGE = "MESSAGE";
64+
C.NOTIFY = "NOTIFY";
65+
C.OPTIONS = "OPTIONS";
66+
C.REGISTER = "REGISTER";
67+
C.UPDATE = "UPDATE";
68+
C.SUBSCRIBE = "SUBSCRIBE";
69+
C.PUBLISH = "PUBLISH";
70+
C.REFER = "REFER";
71+
C.PRACK = "PRACK";
72+
/* SIP Response Reasons
73+
* DOC: http://www.iana.org/assignments/sip-parameters
74+
* Copied from https://github.com/versatica/OverSIP/blob/master/lib/oversip/sip/constants.rb#L7
75+
*/
76+
C.REASON_PHRASE = {
77+
100: "Trying",
78+
180: "Ringing",
79+
181: "Call Is Being Forwarded",
80+
182: "Queued",
81+
183: "Session Progress",
82+
199: "Early Dialog Terminated",
83+
200: "OK",
84+
202: "Accepted",
85+
204: "No Notification",
86+
300: "Multiple Choices",
87+
301: "Moved Permanently",
88+
302: "Moved Temporarily",
89+
305: "Use Proxy",
90+
380: "Alternative Service",
91+
400: "Bad Request",
92+
401: "Unauthorized",
93+
402: "Payment Required",
94+
403: "Forbidden",
95+
404: "Not Found",
96+
405: "Method Not Allowed",
97+
406: "Not Acceptable",
98+
407: "Proxy Authentication Required",
99+
408: "Request Timeout",
100+
410: "Gone",
101+
412: "Conditional Request Failed",
102+
413: "Request Entity Too Large",
103+
414: "Request-URI Too Long",
104+
415: "Unsupported Media Type",
105+
416: "Unsupported URI Scheme",
106+
417: "Unknown Resource-Priority",
107+
420: "Bad Extension",
108+
421: "Extension Required",
109+
422: "Session Interval Too Small",
110+
423: "Interval Too Brief",
111+
428: "Use Identity Header",
112+
429: "Provide Referrer Identity",
113+
430: "Flow Failed",
114+
433: "Anonymity Disallowed",
115+
436: "Bad Identity-Info",
116+
437: "Unsupported Certificate",
117+
438: "Invalid Identity Header",
118+
439: "First Hop Lacks Outbound Support",
119+
440: "Max-Breadth Exceeded",
120+
469: "Bad Info Package",
121+
470: "Consent Needed",
122+
478: "Unresolvable Destination",
123+
480: "Temporarily Unavailable",
124+
481: "Call/Transaction Does Not Exist",
125+
482: "Loop Detected",
126+
483: "Too Many Hops",
127+
484: "Address Incomplete",
128+
485: "Ambiguous",
129+
486: "Busy Here",
130+
487: "Request Terminated",
131+
488: "Not Acceptable Here",
132+
489: "Bad Event",
133+
491: "Request Pending",
134+
493: "Undecipherable",
135+
494: "Security Agreement Required",
136+
500: "Internal Server Error",
137+
501: "Not Implemented",
138+
502: "Bad Gateway",
139+
503: "Service Unavailable",
140+
504: "Server Time-out",
141+
505: "Version Not Supported",
142+
513: "Message Too Large",
143+
580: "Precondition Failure",
144+
600: "Busy Everywhere",
145+
603: "Decline",
146+
604: "Does Not Exist Anywhere",
147+
606: "Not Acceptable"
148+
};
149+
/* SIP Option Tags
150+
* DOC: http://www.iana.org/assignments/sip-parameters/sip-parameters.xhtml#sip-parameters-4
151+
*/
152+
C.OPTION_TAGS = {
153+
"100rel": true,
154+
"199": true,
155+
"answermode": true,
156+
"early-session": true,
157+
"eventlist": true,
158+
"explicitsub": true,
159+
"from-change": true,
160+
"geolocation-http": true,
161+
"geolocation-sip": true,
162+
"gin": true,
163+
"gruu": true,
164+
"histinfo": true,
165+
"ice": true,
166+
"join": true,
167+
"multiple-refer": true,
168+
"norefersub": true,
169+
"nosub": true,
170+
"outbound": true,
171+
"path": true,
172+
"policy": true,
173+
"precondition": true,
174+
"pref": true,
175+
"privacy": true,
176+
"recipient-list-invite": true,
177+
"recipient-list-message": true,
178+
"recipient-list-subscribe": true,
179+
"replaces": true,
180+
"resource-priority": true,
181+
"sdp-anat": true,
182+
"sec-agree": true,
183+
"tdialog": true,
184+
"timer": true,
185+
"uui": true // RFC 7433
186+
};
187+
var dtmfType;
188+
(function (dtmfType) {
189+
dtmfType["INFO"] = "info";
190+
dtmfType["RTP"] = "rtp";
191+
})(dtmfType = C.dtmfType || (C.dtmfType = {}));
192+
})(C = exports.C || (exports.C = {}));

0 commit comments

Comments
 (0)