@routr/processor 2.0.8-alpha.25 → 2.0.8-alpha.28
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.
- package/dist/alterations.d.ts +1 -0
- package/dist/alterations.js +15 -2
- package/dist/helper.d.ts +8 -1
- package/dist/helper.js +19 -1
- package/dist/response.d.ts +5 -0
- package/dist/response.js +50 -6
- package/package.json +3 -3
package/dist/alterations.d.ts
CHANGED
|
@@ -11,4 +11,5 @@ export declare const removeAuthorization: (request: MessageRequest) => MessageRe
|
|
|
11
11
|
export declare const removeSelfRoutes: (request: MessageRequest) => MessageRequest;
|
|
12
12
|
export declare const removeTopVia: (request: MessageRequest) => MessageRequest;
|
|
13
13
|
export declare const decreaseMaxForwards: (request: MessageRequest) => MessageRequest;
|
|
14
|
+
export declare const fixNatedContact: (request: MessageRequest) => MessageRequest;
|
|
14
15
|
export declare const enforceE164: (enforceE164: boolean, validateMobilePrefix: boolean) => (request: MessageRequest) => MessageRequest;
|
package/dist/alterations.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.enforceE164 = exports.decreaseMaxForwards = exports.removeTopVia = exports.removeSelfRoutes = exports.removeAuthorization = exports.removeXEdgePortRef = exports.addXEdgePortRef = exports.addSelfRecordRoute = exports.applyXHeaders = exports.addRouteToPeerEdgePort = exports.addRouteToNextHop = exports.addSelfVia = exports.updateRequestURI = void 0;
|
|
3
|
+
exports.enforceE164 = exports.fixNatedContact = exports.decreaseMaxForwards = exports.removeTopVia = exports.removeSelfRoutes = exports.removeAuthorization = exports.removeXEdgePortRef = exports.addXEdgePortRef = exports.addSelfRecordRoute = exports.applyXHeaders = exports.addRouteToPeerEdgePort = exports.addRouteToNextHop = exports.addSelfVia = exports.updateRequestURI = void 0;
|
|
4
4
|
/*
|
|
5
5
|
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
|
6
6
|
* http://github.com/fonoster/routr
|
|
@@ -41,7 +41,10 @@ const addSelfVia = (route) => (request) => {
|
|
|
41
41
|
const req = common_1.Helper.deepCopy(request);
|
|
42
42
|
const routingObjects = request.edgePortRef === route.edgePortRef ? route : request;
|
|
43
43
|
const targetIntf = (0, helper_1.getEdgeInterface)(Object.assign(Object.assign({}, routingObjects), { endpointIntf: route }));
|
|
44
|
-
req.message.via = [
|
|
44
|
+
req.message.via = [
|
|
45
|
+
Object.assign(Object.assign({}, targetIntf), { rPortFlag: true }),
|
|
46
|
+
...req.message.via
|
|
47
|
+
];
|
|
45
48
|
return req;
|
|
46
49
|
};
|
|
47
50
|
exports.addSelfVia = addSelfVia;
|
|
@@ -209,6 +212,16 @@ const decreaseMaxForwards = (request) => {
|
|
|
209
212
|
return req;
|
|
210
213
|
};
|
|
211
214
|
exports.decreaseMaxForwards = decreaseMaxForwards;
|
|
215
|
+
const fixNatedContact = (request) => {
|
|
216
|
+
var _a;
|
|
217
|
+
const req = common_1.Helper.deepCopy(request);
|
|
218
|
+
if ((_a = req.message.contact) === null || _a === void 0 ? void 0 : _a.address.uri.host.includes(".invalid")) {
|
|
219
|
+
req.message.contact.address.uri.host = request.sender.host;
|
|
220
|
+
req.message.contact.address.uri.port = request.sender.port;
|
|
221
|
+
}
|
|
222
|
+
return req;
|
|
223
|
+
};
|
|
224
|
+
exports.fixNatedContact = fixNatedContact;
|
|
212
225
|
// Will do the best effort to normalize from/to/requestUri users as e164 values
|
|
213
226
|
const enforceE164 = (enforceE164, validateMobilePrefix) => (request) => {
|
|
214
227
|
var _a, _b, _c;
|
package/dist/helper.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MessageRequest, Route, NetInterface } from "@routr/common";
|
|
1
|
+
import { MessageRequest, Route, Transport, NetInterface } from "@routr/common";
|
|
2
2
|
export declare const isTypeResponse: (request: MessageRequest) => boolean;
|
|
3
3
|
export declare const isTypeRequest: (request: MessageRequest) => boolean;
|
|
4
4
|
export declare const getEdgeInterface: (nets: {
|
|
@@ -15,3 +15,10 @@ export declare const getEdgeInterface: (nets: {
|
|
|
15
15
|
* @return {Route} the route
|
|
16
16
|
*/
|
|
17
17
|
export declare function createRouteFromLastMessage(request: MessageRequest): Route;
|
|
18
|
+
export declare const hasSDP: (request: MessageRequest) => boolean;
|
|
19
|
+
export declare const isOk: (request: MessageRequest) => boolean;
|
|
20
|
+
export declare const isRinging: (request: MessageRequest) => boolean;
|
|
21
|
+
export declare const isWebRTC: (transport: Transport) => boolean;
|
|
22
|
+
export declare const isInviteOrAckWithSDP: (request: MessageRequest) => boolean;
|
|
23
|
+
export declare const isOkOrRingingWithSDP: (request: MessageRequest) => boolean;
|
|
24
|
+
export declare const isBye: (request: MessageRequest) => boolean;
|
package/dist/helper.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createRouteFromLastMessage = exports.getEdgeInterface = exports.isTypeRequest = exports.isTypeResponse = void 0;
|
|
3
|
+
exports.isBye = exports.isOkOrRingingWithSDP = exports.isInviteOrAckWithSDP = exports.isWebRTC = exports.isRinging = exports.isOk = exports.hasSDP = exports.createRouteFromLastMessage = exports.getEdgeInterface = exports.isTypeRequest = exports.isTypeResponse = void 0;
|
|
4
4
|
/*
|
|
5
5
|
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
|
6
6
|
* http://github.com/fonoster/routr
|
|
@@ -72,3 +72,21 @@ function createRouteFromLastMessage(request) {
|
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
74
|
exports.createRouteFromLastMessage = createRouteFromLastMessage;
|
|
75
|
+
const hasSDP = (request) => { var _a; return ((_a = request.message.body) === null || _a === void 0 ? void 0 : _a.length) > 0; };
|
|
76
|
+
exports.hasSDP = hasSDP;
|
|
77
|
+
const isOk = (request) => request.message.responseType === common_1.CommonTypes.ResponseType.OK;
|
|
78
|
+
exports.isOk = isOk;
|
|
79
|
+
const isRinging = (request) => request.message.responseType === common_1.CommonTypes.ResponseType.RINGING;
|
|
80
|
+
exports.isRinging = isRinging;
|
|
81
|
+
const isWebRTC = (transport) => transport === common_1.Transport.WS || transport === common_1.Transport.WSS;
|
|
82
|
+
exports.isWebRTC = isWebRTC;
|
|
83
|
+
const isInviteOrAckWithSDP = (request) => (0, exports.isTypeRequest)(request) &&
|
|
84
|
+
(0, exports.hasSDP)(request) &&
|
|
85
|
+
(request.method === common_1.Method.INVITE || request.method === common_1.Method.ACK);
|
|
86
|
+
exports.isInviteOrAckWithSDP = isInviteOrAckWithSDP;
|
|
87
|
+
const isOkOrRingingWithSDP = (request) => (0, exports.isTypeResponse)(request) &&
|
|
88
|
+
(0, exports.hasSDP)(request) &&
|
|
89
|
+
((0, exports.isOk)(request) || (0, exports.isRinging)(request));
|
|
90
|
+
exports.isOkOrRingingWithSDP = isOkOrRingingWithSDP;
|
|
91
|
+
const isBye = (request) => (0, exports.isTypeRequest)(request) && request.method === common_1.Method.BYE;
|
|
92
|
+
exports.isBye = isBye;
|
package/dist/response.d.ts
CHANGED
|
@@ -31,6 +31,10 @@ export default class Response {
|
|
|
31
31
|
* Sends a not implemented response.
|
|
32
32
|
*/
|
|
33
33
|
sendNotImplemented(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Sends a internal server error response.
|
|
36
|
+
*/
|
|
37
|
+
sendInternalServerError(): void;
|
|
34
38
|
/**
|
|
35
39
|
* Sends a response with a SIP Message.
|
|
36
40
|
*
|
|
@@ -41,6 +45,7 @@ export default class Response {
|
|
|
41
45
|
* Sends an error response.
|
|
42
46
|
*
|
|
43
47
|
* @param {Error} error - The error to be sent.
|
|
48
|
+
* @deprecated
|
|
44
49
|
*/
|
|
45
50
|
sendError(error: Error): void;
|
|
46
51
|
}
|
package/dist/response.js
CHANGED
|
@@ -1,7 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
|
5
|
+
* http://github.com/fonoster/routr
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Routr
|
|
8
|
+
*
|
|
9
|
+
* Licensed under the MIT License (the "License")
|
|
10
|
+
* you may not use this file except in compliance with
|
|
11
|
+
* the License. You may obtain a copy of the License at
|
|
12
|
+
*
|
|
13
|
+
* https://opensource.org/licenses/MIT
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
* See the License for the specific language governing permissions and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
const common_1 = require("@routr/common");
|
|
22
|
+
const buildResponse = (info) => {
|
|
23
|
+
return {
|
|
24
|
+
message: {
|
|
25
|
+
responseType: info.code,
|
|
26
|
+
reasonPhrase: info.reasonPhrase,
|
|
27
|
+
extensions: info.extraHeaders
|
|
28
|
+
}
|
|
29
|
+
};
|
|
5
30
|
};
|
|
6
31
|
/**
|
|
7
32
|
* Response object.
|
|
@@ -21,25 +46,43 @@ class Response {
|
|
|
21
46
|
* @param {object[]} extraHeaders - Optional extra headers to be sent.
|
|
22
47
|
*/
|
|
23
48
|
sendOk(extraHeaders) {
|
|
24
|
-
this.callback(null, buildResponse(
|
|
49
|
+
this.callback(null, buildResponse({ code: common_1.CommonTypes.ResponseType.OK, extraHeaders }));
|
|
25
50
|
}
|
|
26
51
|
/**
|
|
27
52
|
* Sends a method not allowed response.
|
|
28
53
|
*/
|
|
29
54
|
sendMethodNotAllowed() {
|
|
30
|
-
this.callback(null, buildResponse(
|
|
55
|
+
this.callback(null, buildResponse({
|
|
56
|
+
code: common_1.CommonTypes.ResponseType.METHOD_NOT_ALLOWED,
|
|
57
|
+
reasonPhrase: "Method Not Allowed"
|
|
58
|
+
}));
|
|
31
59
|
}
|
|
32
60
|
/**
|
|
33
61
|
* Sends a not found response.
|
|
34
62
|
*/
|
|
35
63
|
sendNotFound() {
|
|
36
|
-
this.callback(null, buildResponse(
|
|
64
|
+
this.callback(null, buildResponse({
|
|
65
|
+
code: common_1.CommonTypes.ResponseType.NOT_FOUND,
|
|
66
|
+
reasonPhrase: "Not Found"
|
|
67
|
+
}));
|
|
37
68
|
}
|
|
38
69
|
/**
|
|
39
70
|
* Sends a not implemented response.
|
|
40
71
|
*/
|
|
41
72
|
sendNotImplemented() {
|
|
42
|
-
this.callback(null, buildResponse(
|
|
73
|
+
this.callback(null, buildResponse({
|
|
74
|
+
code: common_1.CommonTypes.ResponseType.NOT_IMPLEMENTED,
|
|
75
|
+
reasonPhrase: "Not Implemented"
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Sends a internal server error response.
|
|
80
|
+
*/
|
|
81
|
+
sendInternalServerError() {
|
|
82
|
+
this.callback(null, buildResponse({
|
|
83
|
+
code: common_1.CommonTypes.ResponseType.SERVER_INTERNAL_ERROR,
|
|
84
|
+
reasonPhrase: "Internal Server Error"
|
|
85
|
+
}));
|
|
43
86
|
}
|
|
44
87
|
/**
|
|
45
88
|
* Sends a response with a SIP Message.
|
|
@@ -53,6 +96,7 @@ class Response {
|
|
|
53
96
|
* Sends an error response.
|
|
54
97
|
*
|
|
55
98
|
* @param {Error} error - The error to be sent.
|
|
99
|
+
* @deprecated
|
|
56
100
|
*/
|
|
57
101
|
sendError(error) {
|
|
58
102
|
this.callback(error, null);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@routr/processor",
|
|
3
|
-
"version": "2.0.8-alpha.
|
|
3
|
+
"version": "2.0.8-alpha.28",
|
|
4
4
|
"description": "Processor server and API",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/routr#readme",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@opentelemetry/sdk-trace-base": "^1.0.4",
|
|
24
24
|
"@opentelemetry/sdk-trace-node": "^1.0.4",
|
|
25
25
|
"@opentelemetry/semantic-conventions": "^1.0.4",
|
|
26
|
-
"@routr/common": "^2.0.8-alpha.
|
|
26
|
+
"@routr/common": "^2.0.8-alpha.28",
|
|
27
27
|
"fp-ts": "^2.11.8",
|
|
28
28
|
"phone": "^3.1.32"
|
|
29
29
|
},
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"bugs": {
|
|
45
45
|
"url": "https://github.com/fonoster/routr/issues"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "d28aabb2fce0600aaae94aa37709e89ed7112c99"
|
|
48
48
|
}
|