Skip to content

Commit 2d191f9

Browse files
author
James Criscuolo
committed
dist/ lib/ files for 0.14.3
1 parent 159af4d commit 2d191f9

File tree

244 files changed

+62880
-0
lines changed

Some content is hidden

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

244 files changed

+62880
-0
lines changed

dist/sip-0.14.3.js

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

dist/sip-0.14.3.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: 19902 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: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/// <reference types="node" />
2+
import { EventEmitter } from "events";
3+
import { IncomingResponseMessage, Logger, NameAddrHeader, OutgoingRequestMessage, URI } from "./core";
4+
import { TypeStrings } from "./Enums";
5+
import { BodyObj } from "./session-description-handler";
6+
import { UA } from "./UA";
7+
export declare namespace ClientContext {
8+
interface Options {
9+
body?: string;
10+
contentType?: string;
11+
extraHeaders?: Array<string>;
12+
params?: {
13+
fromUri?: string | URI;
14+
toUri?: string | URI;
15+
toDisplayName?: string;
16+
};
17+
}
18+
}
19+
export declare class ClientContext extends EventEmitter {
20+
static initializer(objToConstruct: ClientContext, ua: UA, method: string, originalTarget: string | URI, options?: ClientContext.Options): void;
21+
type: TypeStrings;
22+
data: any;
23+
ua: UA;
24+
logger: Logger;
25+
request: OutgoingRequestMessage;
26+
method: string;
27+
body: BodyObj | undefined;
28+
localIdentity: NameAddrHeader;
29+
remoteIdentity: NameAddrHeader;
30+
constructor(ua: UA, method: string, target: string | URI, options?: ClientContext.Options);
31+
send(): this;
32+
receiveResponse(response: IncomingResponseMessage): void;
33+
onRequestTimeout(): void;
34+
onTransportError(): void;
35+
}

lib/ClientContext.js

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
var tslib_1 = require("tslib");
4+
var events_1 = require("events");
5+
var Constants_1 = require("./Constants");
6+
var core_1 = require("./core");
7+
var Enums_1 = require("./Enums");
8+
var Utils_1 = require("./Utils");
9+
var ClientContext = /** @class */ (function (_super) {
10+
tslib_1.__extends(ClientContext, _super);
11+
function ClientContext(ua, method, target, options) {
12+
var _this = _super.call(this) || this;
13+
_this.data = {};
14+
ClientContext.initializer(_this, ua, method, target, options);
15+
return _this;
16+
}
17+
ClientContext.initializer = function (objToConstruct, ua, method, originalTarget, options) {
18+
objToConstruct.type = Enums_1.TypeStrings.ClientContext;
19+
// Validate arguments
20+
if (originalTarget === undefined) {
21+
throw new TypeError("Not enough arguments");
22+
}
23+
objToConstruct.ua = ua;
24+
objToConstruct.logger = ua.getLogger("sip.clientcontext");
25+
objToConstruct.method = method;
26+
var target = ua.normalizeTarget(originalTarget);
27+
if (!target) {
28+
throw new TypeError("Invalid target: " + originalTarget);
29+
}
30+
var fromURI = ua.userAgentCore.configuration.aor;
31+
if (options && options.params && options.params.fromUri) {
32+
fromURI =
33+
(typeof options.params.fromUri === "string") ?
34+
core_1.Grammar.URIParse(options.params.fromUri) :
35+
options.params.fromUri;
36+
if (!fromURI) {
37+
throw new TypeError("Invalid from URI: " + options.params.fromUri);
38+
}
39+
}
40+
var toURI = target;
41+
if (options && options.params && options.params.toUri) {
42+
toURI =
43+
(typeof options.params.toUri === "string") ?
44+
core_1.Grammar.URIParse(options.params.toUri) :
45+
options.params.toUri;
46+
if (!toURI) {
47+
throw new TypeError("Invalid to URI: " + options.params.toUri);
48+
}
49+
}
50+
/* Options
51+
* - extraHeaders
52+
* - params
53+
* - contentType
54+
* - body
55+
*/
56+
options = Object.create(options || Object.prototype);
57+
options = options || {};
58+
var extraHeaders = (options.extraHeaders || []).slice();
59+
var params = options.params || {};
60+
var bodyObj;
61+
if (options.body) {
62+
bodyObj = {
63+
body: options.body,
64+
contentType: options.contentType ? options.contentType : "application/sdp"
65+
};
66+
objToConstruct.body = bodyObj;
67+
}
68+
var body;
69+
if (bodyObj) {
70+
body = Utils_1.Utils.fromBodyObj(bodyObj);
71+
}
72+
// Build the request
73+
objToConstruct.request = ua.userAgentCore.makeOutgoingRequestMessage(method, target, fromURI, toURI, params, extraHeaders, body);
74+
/* Set other properties from the request */
75+
if (objToConstruct.request.from) {
76+
objToConstruct.localIdentity = objToConstruct.request.from;
77+
}
78+
if (objToConstruct.request.to) {
79+
objToConstruct.remoteIdentity = objToConstruct.request.to;
80+
}
81+
};
82+
ClientContext.prototype.send = function () {
83+
var _this = this;
84+
this.ua.userAgentCore.request(this.request, {
85+
onAccept: function (response) { return _this.receiveResponse(response.message); },
86+
onProgress: function (response) { return _this.receiveResponse(response.message); },
87+
onRedirect: function (response) { return _this.receiveResponse(response.message); },
88+
onReject: function (response) { return _this.receiveResponse(response.message); },
89+
onTrying: function (response) { return _this.receiveResponse(response.message); }
90+
});
91+
return this;
92+
};
93+
ClientContext.prototype.receiveResponse = function (response) {
94+
var statusCode = response.statusCode || 0;
95+
var cause = Utils_1.Utils.getReasonPhrase(statusCode);
96+
switch (true) {
97+
case /^1[0-9]{2}$/.test(statusCode.toString()):
98+
this.emit("progress", response, cause);
99+
break;
100+
case /^2[0-9]{2}$/.test(statusCode.toString()):
101+
if (this.ua.applicants[this.toString()]) {
102+
delete this.ua.applicants[this.toString()];
103+
}
104+
this.emit("accepted", response, cause);
105+
break;
106+
default:
107+
if (this.ua.applicants[this.toString()]) {
108+
delete this.ua.applicants[this.toString()];
109+
}
110+
this.emit("rejected", response, cause);
111+
this.emit("failed", response, cause);
112+
break;
113+
}
114+
};
115+
ClientContext.prototype.onRequestTimeout = function () {
116+
this.emit("failed", undefined, Constants_1.C.causes.REQUEST_TIMEOUT);
117+
};
118+
ClientContext.prototype.onTransportError = function () {
119+
this.emit("failed", undefined, Constants_1.C.causes.CONNECTION_ERROR);
120+
};
121+
return ClientContext;
122+
}(events_1.EventEmitter));
123+
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+
}

0 commit comments

Comments
 (0)