@routr/connect 2.14.0 → 2.15.0
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/router.js +11 -3
- package/package.json +5 -5
package/dist/router.js
CHANGED
|
@@ -145,8 +145,13 @@ function router(location, apiClient) {
|
|
|
145
145
|
const route = yield fromPSTN(apiClient, location, callee, request);
|
|
146
146
|
return result(routingDirection, route, callee.extended);
|
|
147
147
|
}
|
|
148
|
-
case types_1.RoutingDirection.PEER_TO_PSTN:
|
|
149
|
-
|
|
148
|
+
case types_1.RoutingDirection.PEER_TO_PSTN: {
|
|
149
|
+
const routeOrResponse = yield peerToPSTN(apiClient, request);
|
|
150
|
+
// An error response (e.g. Bad Request, Not Found) is returned as-is
|
|
151
|
+
return "message" in routeOrResponse
|
|
152
|
+
? routeOrResponse
|
|
153
|
+
: result(routingDirection, routeOrResponse, callee === null || callee === void 0 ? void 0 : callee.extended);
|
|
154
|
+
}
|
|
150
155
|
default:
|
|
151
156
|
throw new errors_1.UnsupportedRoutingError(routingDirection);
|
|
152
157
|
}
|
|
@@ -277,9 +282,12 @@ function peerToPSTN(apiClient, req) {
|
|
|
277
282
|
return __awaiter(this, void 0, void 0, function* () {
|
|
278
283
|
const numberTel = processor_1.Extensions.getHeaderValue(req, common_1.CommonTypes.ExtraHeader.DOD_NUMBER);
|
|
279
284
|
const privacy = processor_1.Extensions.getHeaderValue(req, common_1.CommonTypes.ExtraHeader.DOD_PRIVACY);
|
|
285
|
+
if (!numberTel) {
|
|
286
|
+
return common_1.CommonResponse.createBadRequestResponse(`Missing or empty '${common_1.CommonTypes.ExtraHeader.DOD_NUMBER}' header required for peer-to-pstn routing`);
|
|
287
|
+
}
|
|
280
288
|
const number = yield (0, utils_1.findNumberByTelUrl)(apiClient, `tel:${numberTel}`);
|
|
281
289
|
if (!number) {
|
|
282
|
-
|
|
290
|
+
return common_1.CommonResponse.createNotFoundResponse(`No Number found for tel:${numberTel}`);
|
|
283
291
|
}
|
|
284
292
|
if (!number.trunk) {
|
|
285
293
|
// TODO: Create custom error
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@routr/connect",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.15.0",
|
|
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.
|
|
32
|
-
"@routr/location": "^2.
|
|
33
|
-
"@routr/processor": "^2.
|
|
31
|
+
"@routr/common": "^2.15.0",
|
|
32
|
+
"@routr/location": "^2.15.0",
|
|
33
|
+
"@routr/processor": "^2.15.0",
|
|
34
34
|
"jsonwebtoken": "^9.0.3"
|
|
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": "4cfe8529e9325b7a2f32aff615cf3db65c71cf29"
|
|
53
53
|
}
|