@routr/connect 2.13.1 → 2.13.3
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/access.js +3 -3
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +3 -3
- package/dist/handlers/register.js +3 -3
- package/dist/handlers/request.js +9 -1
- package/dist/router.js +7 -7
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +3 -3
- package/package.json +5 -5
package/dist/access.js
CHANGED
@@ -42,7 +42,7 @@ const checkAccess = (accessRequest) => __awaiter(void 0, void 0, void 0, functio
|
|
42
42
|
case types_1.RoutingDirection.FROM_PSTN:
|
43
43
|
return (0, exports.checkAccessFromPSTN)(apiClient, request, callee);
|
44
44
|
case types_1.RoutingDirection.UNKNOWN:
|
45
|
-
return common_1.CommonResponse.
|
45
|
+
return common_1.CommonResponse.createForbiddenResponse();
|
46
46
|
}
|
47
47
|
});
|
48
48
|
exports.checkAccess = checkAccess;
|
@@ -74,10 +74,10 @@ const checkAccessFromPSTN = (apiClient, request, callee) => __awaiter(void 0, vo
|
|
74
74
|
})).items[0];
|
75
75
|
// If the Trunk or Number doesn't exist reject the call
|
76
76
|
if (!callee || !trunk) {
|
77
|
-
return common_1.CommonResponse.
|
77
|
+
return common_1.CommonResponse.createForbiddenResponse();
|
78
78
|
}
|
79
79
|
if (callee.trunk.ref !== trunk.ref) {
|
80
|
-
return common_1.CommonResponse.
|
80
|
+
return common_1.CommonResponse.createForbiddenResponse();
|
81
81
|
}
|
82
82
|
// Verify that the IP is allowlist which means getting the access control list for the trunk
|
83
83
|
if (trunk.accessControlList) {
|
package/dist/errors.d.ts
CHANGED
@@ -14,7 +14,7 @@ export declare class ServiceUnavailableError extends Error {
|
|
14
14
|
/**
|
15
15
|
* Throw when the route is not supported.
|
16
16
|
*/
|
17
|
-
export declare class
|
17
|
+
export declare class UnsupportedRoutingError extends Error {
|
18
18
|
code: number;
|
19
19
|
/**
|
20
20
|
* Create a new ServiceUnavailableError.
|
package/dist/errors.js
CHANGED
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
23
23
|
return result;
|
24
24
|
};
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
-
exports.
|
26
|
+
exports.UnsupportedRoutingError = exports.ServiceUnavailableError = void 0;
|
27
27
|
/*
|
28
28
|
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
29
29
|
* http://github.com/fonoster/routr
|
@@ -63,7 +63,7 @@ exports.ServiceUnavailableError = ServiceUnavailableError;
|
|
63
63
|
/**
|
64
64
|
* Throw when the route is not supported.
|
65
65
|
*/
|
66
|
-
class
|
66
|
+
class UnsupportedRoutingError extends Error {
|
67
67
|
/**
|
68
68
|
* Create a new ServiceUnavailableError.
|
69
69
|
*
|
@@ -76,4 +76,4 @@ class UnsuportedRoutingError extends Error {
|
|
76
76
|
Object.setPrototypeOf(this, ServiceUnavailableError.prototype);
|
77
77
|
}
|
78
78
|
}
|
79
|
-
exports.
|
79
|
+
exports.UnsupportedRoutingError = UnsupportedRoutingError;
|
@@ -68,7 +68,7 @@ const handleRegister = (apiClient, location) => {
|
|
68
68
|
const fromURI = request.message.from.address.uri;
|
69
69
|
const peerOrAgent = (yield (0, utils_1.findResource)(apiClient, fromURI.host, fromURI.user));
|
70
70
|
if (!peerOrAgent) {
|
71
|
-
return res.send(common_1.CommonResponse.
|
71
|
+
return res.send(common_1.CommonResponse.createForbiddenResponse());
|
72
72
|
}
|
73
73
|
const credentials = peerOrAgent.credentials;
|
74
74
|
// Calculate response and compare with the one send by the endpoint
|
@@ -103,7 +103,7 @@ const handleRegister = (apiClient, location) => {
|
|
103
103
|
try {
|
104
104
|
const payload = (yield jwtVerifier.verify(connectToken));
|
105
105
|
if (!payload.allowedMethods.includes(common_1.Method.REGISTER)) {
|
106
|
-
return res.send(common_1.CommonResponse.
|
106
|
+
return res.send(common_1.CommonResponse.createForbiddenResponse());
|
107
107
|
}
|
108
108
|
yield location.addRoute({
|
109
109
|
aor: payload.aor,
|
@@ -116,7 +116,7 @@ const handleRegister = (apiClient, location) => {
|
|
116
116
|
logger.verbose("unable to validate connect token", {
|
117
117
|
originalError: e.message
|
118
118
|
});
|
119
|
-
res.send(common_1.CommonResponse.
|
119
|
+
res.send(common_1.CommonResponse.createForbiddenResponse());
|
120
120
|
}
|
121
121
|
}
|
122
122
|
else {
|
package/dist/handlers/request.js
CHANGED
@@ -52,11 +52,11 @@ exports.handleRequest = void 0;
|
|
52
52
|
* limitations under the License.
|
53
53
|
*/
|
54
54
|
const grpc = __importStar(require("@grpc/grpc-js"));
|
55
|
-
const location_1 = require("@routr/location");
|
56
55
|
const tailor_1 = require("../tailor");
|
57
56
|
const processor_1 = require("@routr/processor");
|
58
57
|
const function_1 = require("fp-ts/function");
|
59
58
|
const router_1 = require("../router");
|
59
|
+
const location_1 = require("@routr/location");
|
60
60
|
const common_1 = require("@routr/common");
|
61
61
|
const logger_1 = require("@fonoster/logger");
|
62
62
|
const types_1 = require("./../types");
|
@@ -83,6 +83,14 @@ const handleRequest = (location, apiClient) => (request, res) => __awaiter(void
|
|
83
83
|
else if (!routerResult.route) {
|
84
84
|
return res.sendTemporarilyUnavailable();
|
85
85
|
}
|
86
|
+
const p = {
|
87
|
+
name: common_1.CommonTypes.ExtraHeader.CALL_DIRECTION,
|
88
|
+
value: direction,
|
89
|
+
action: common_1.CommonTypes.HeaderModifierAction.ADD
|
90
|
+
};
|
91
|
+
if (!route.headers)
|
92
|
+
route.headers = [];
|
93
|
+
route.headers.push(p);
|
86
94
|
}
|
87
95
|
// Forward request to peer edgeport
|
88
96
|
if (req.edgePortRef !== route.edgePortRef) {
|
package/dist/router.js
CHANGED
@@ -54,7 +54,7 @@ function router(location, apiClient) {
|
|
54
54
|
const payload = (yield jwtVerifier.verify(connectToken));
|
55
55
|
const domain = yield (0, utils_1.findDomain)(apiClient, payload.domain);
|
56
56
|
if (!payload.allowedMethods.includes(common_1.Method.INVITE)) {
|
57
|
-
return common_1.CommonResponse.
|
57
|
+
return common_1.CommonResponse.createForbiddenResponse();
|
58
58
|
}
|
59
59
|
caller = {
|
60
60
|
apiVersion: common_1.CommonConnect.APIVersion.V2,
|
@@ -88,7 +88,7 @@ function router(location, apiClient) {
|
|
88
88
|
logger.verbose("unable to validate connect token", {
|
89
89
|
originalError: e.message
|
90
90
|
});
|
91
|
-
return common_1.CommonResponse.
|
91
|
+
return common_1.CommonResponse.createForbiddenResponse();
|
92
92
|
}
|
93
93
|
}
|
94
94
|
else {
|
@@ -97,11 +97,11 @@ function router(location, apiClient) {
|
|
97
97
|
}
|
98
98
|
const routingDirection = (0, utils_1.getRoutingDirection)(caller, callee);
|
99
99
|
logger.verbose("routing request from: " +
|
100
|
-
(0, utils_1.
|
100
|
+
(0, utils_1.getSipUri)(fromURI) +
|
101
101
|
", to: " +
|
102
|
-
(0, utils_1.
|
103
|
-
fromURI: (0, utils_1.
|
104
|
-
requestURI: (0, utils_1.
|
102
|
+
(0, utils_1.getSipUri)(requestURI), {
|
103
|
+
fromURI: (0, utils_1.getSipUri)(fromURI),
|
104
|
+
requestURI: (0, utils_1.getSipUri)(requestURI),
|
105
105
|
routingDirection
|
106
106
|
});
|
107
107
|
if (!(0, utils_1.hasXConnectObjectHeader)(request) &&
|
@@ -147,7 +147,7 @@ function router(location, apiClient) {
|
|
147
147
|
case types_1.RoutingDirection.PEER_TO_PSTN:
|
148
148
|
return result(routingDirection, yield peerToPSTN(apiClient, request), callee === null || callee === void 0 ? void 0 : callee.extended);
|
149
149
|
default:
|
150
|
-
throw new errors_1.
|
150
|
+
throw new errors_1.UnsupportedRoutingError(routingDirection);
|
151
151
|
}
|
152
152
|
});
|
153
153
|
}
|
package/dist/utils.d.ts
CHANGED
package/dist/utils.js
CHANGED
@@ -35,7 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
36
36
|
};
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
38
|
-
exports.getVerifierImpl = exports.hasXConnectObjectHeader = exports.
|
38
|
+
exports.getVerifierImpl = exports.hasXConnectObjectHeader = exports.getSipUri = exports.getTrunkURI = exports.createTrunkAuthentication = exports.createRemotePartyId = exports.createPAssertedIdentity = exports.getRoutingDirection = exports.findResource = exports.findNumberByTelUrl = exports.findDomain = exports.isKind = void 0;
|
39
39
|
/*
|
40
40
|
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
41
41
|
* http://github.com/fonoster/routr
|
@@ -194,8 +194,8 @@ const getTrunkURI = (trunk) => {
|
|
194
194
|
};
|
195
195
|
};
|
196
196
|
exports.getTrunkURI = getTrunkURI;
|
197
|
-
const
|
198
|
-
exports.
|
197
|
+
const getSipUri = (uri) => uri.user ? `sip:${uri.user}@${uri.host}` : `sip:${uri.host}`;
|
198
|
+
exports.getSipUri = getSipUri;
|
199
199
|
const hasXConnectObjectHeader = (req) => processor_1.Extensions.getHeaderValue(req, common_1.CommonTypes.ExtraHeader.CONNECT_TOKEN);
|
200
200
|
exports.hasXConnectObjectHeader = hasXConnectObjectHeader;
|
201
201
|
const getVerifierImpl = () => {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@routr/connect",
|
3
|
-
"version": "2.13.
|
3
|
+
"version": "2.13.3",
|
4
4
|
"description": "Default processor",
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
6
6
|
"homepage": "https://github.com/fonoster/routr#readme",
|
@@ -28,9 +28,9 @@
|
|
28
28
|
"@opentelemetry/sdk-trace-base": "^1.0.4",
|
29
29
|
"@opentelemetry/sdk-trace-node": "^1.0.4",
|
30
30
|
"@opentelemetry/semantic-conventions": "^1.0.4",
|
31
|
-
"@routr/common": "^2.13.
|
32
|
-
"@routr/location": "^2.13.
|
33
|
-
"@routr/processor": "^2.13.
|
31
|
+
"@routr/common": "^2.13.2",
|
32
|
+
"@routr/location": "^2.13.2",
|
33
|
+
"@routr/processor": "^2.13.2",
|
34
34
|
"jsonwebtoken": "^9.0.0"
|
35
35
|
},
|
36
36
|
"devDependencies": {
|
@@ -49,5 +49,5 @@
|
|
49
49
|
"bugs": {
|
50
50
|
"url": "https://github.com/fonoster/routr/issues"
|
51
51
|
},
|
52
|
-
"gitHead": "
|
52
|
+
"gitHead": "f889e9fd03a1fd4d1e41cb7f04ab049ab56238b1"
|
53
53
|
}
|