@routr/connect 2.0.8-alpha.10 → 2.0.8-alpha.12

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.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { MessageRequest, CommonConnect as CC } from "@routr/common";
1
+ import { MessageRequest, CommonTypes as CT, CommonConnect as CC } from "@routr/common";
2
2
  import { RoutingDirection } from "./types";
3
3
  export declare const checkAccess: (accessRequest: {
4
4
  dataAPI: CC.DataAPI;
@@ -9,7 +9,7 @@ export declare const checkAccess: (accessRequest: {
9
9
  }) => Promise<Record<string, unknown>>;
10
10
  export declare const checkAgentOrPeerAccess: (dataAPI: CC.DataAPI, request: MessageRequest, caller: CC.Resource) => Promise<{
11
11
  message: {
12
- responseType: number;
12
+ responseType: CT.ResponseType;
13
13
  wwwAuthenticate: {
14
14
  scheme: string;
15
15
  realm: string;
@@ -23,6 +23,6 @@ export declare const checkAgentOrPeerAccess: (dataAPI: CC.DataAPI, request: Mess
23
23
  }>;
24
24
  export declare const checkAccessFromPSTN: (dataAPI: CC.DataAPI, request: MessageRequest, callee: CC.Resource) => Promise<{
25
25
  message: {
26
- responseType: number;
26
+ responseType: CT.ResponseType;
27
27
  };
28
28
  }>;
package/dist/access.js CHANGED
@@ -83,19 +83,19 @@ const checkAccessFromPSTN = (dataAPI, request, callee) => __awaiter(void 0, void
83
83
  try {
84
84
  const acl = yield dataAPI.get(trunk.spec.inbound.accessControlListRef);
85
85
  if (!acl) {
86
- // Should never happen since the ACL is required
86
+ // Should never happen since the ACL is required on start
87
87
  return common_1.Auth.createServerInternalErrorResponse();
88
88
  }
89
89
  const allow = acl.spec.accessControlList.allow.filter((net) => {
90
90
  return common_1.IpUtils.hasIp(net, request.sender.host);
91
91
  })[0];
92
92
  if (!allow) {
93
- // TODO: Replace with Unauthorized
94
93
  return common_1.Auth.createUnauthorizedResponseWithoutChallenge();
95
94
  }
96
95
  }
97
96
  catch (e) {
98
97
  logger.error(e);
98
+ return common_1.Auth.createServerInternalErrorResponse();
99
99
  }
100
100
  }
101
101
  // If the Trunk has a User/Password we must verify that the User/Password are valid
package/dist/errors.js CHANGED
@@ -71,7 +71,7 @@ class UnsuportedRoutingError extends Error {
71
71
  */
72
72
  constructor(routingDirection) {
73
73
  super("unsupported routing direction: " + routingDirection);
74
- this.code = grpc.status.UNKNOWN;
74
+ this.code = grpc.status.UNIMPLEMENTED;
75
75
  // Set the prototype explicitly.
76
76
  Object.setPrototypeOf(this, ServiceUnavailableError.prototype);
77
77
  }
@@ -3,4 +3,4 @@ import { ILocationService } from "@routr/location";
3
3
  import { CommonConnect as CC } from "@routr/common";
4
4
  export declare const handleRegister: (dataAPI: CC.DataAPI, location: ILocationService) => (request: MessageRequest, res: Response) => Promise<void>;
5
5
  export declare const handleRegistry: (req: MessageRequest, res: Response) => void;
6
- export declare const handleRequest: (location: ILocationService, dataAPI?: CC.DataAPI) => (req: MessageRequest, res: Response) => Promise<void | MessageRequest>;
6
+ export declare const handleRequest: (location: ILocationService, dataAPI?: CC.DataAPI) => (req: MessageRequest, res: Response) => Promise<void>;
package/dist/handlers.js CHANGED
@@ -71,7 +71,7 @@ exports.handleRegister = handleRegister;
71
71
  // TODO: Needs test
72
72
  const handleRegistry = (req, res) => {
73
73
  const route = processor_1.Helper.createRouteFromLastMessage(req);
74
- res.send((0, function_1.pipe)(req, processor_1.Alterations.addSelfVia(route), processor_1.Alterations.decreaseMaxForwards, processor_1.Alterations.removeAuthorization, processor_1.Alterations.removeRoutes, processor_1.Alterations.removeXEdgePortRef));
74
+ res.send((0, function_1.pipe)(req, processor_1.Alterations.addSelfVia(route), processor_1.Alterations.decreaseMaxForwards, processor_1.Alterations.removeAuthorization, processor_1.Alterations.removeSelfRoutes, processor_1.Alterations.removeXEdgePortRef));
75
75
  };
76
76
  exports.handleRegistry = handleRegistry;
77
77
  // TODO: If request has X-Connect-Token then validate the JWT value and continue
@@ -83,13 +83,15 @@ const handleRequest = (location, dataAPI) => (req, res) => __awaiter(void 0, voi
83
83
  if (!route)
84
84
  return res.sendNotFound();
85
85
  // If route is not type Route then return
86
- if (!("user" in route)) {
86
+ if (!("listeningPoints" in route)) {
87
87
  return res.send(route);
88
88
  }
89
89
  else {
90
90
  // Forward request to peer edgeport
91
91
  if (req.edgePortRef !== route.edgePortRef) {
92
- return (0, function_1.pipe)(req, processor_1.Alterations.addSelfVia(route), processor_1.Alterations.addRouteToPeerEdgePort(route), processor_1.Alterations.addXEdgePortRef, processor_1.Alterations.decreaseMaxForwards);
92
+ return res.send((0, function_1.pipe)(req, processor_1.Alterations.addSelfVia(route), processor_1.Alterations.addSelfRecordRoute(route),
93
+ // The order of the routes is important
94
+ processor_1.Alterations.addRouteToPeerEdgePort(route), processor_1.Alterations.addRouteToNextHop(route), processor_1.Alterations.addXEdgePortRef, processor_1.Alterations.decreaseMaxForwards));
93
95
  }
94
96
  res.send((0, tailor_1.tailor)(route, req));
95
97
  }
package/dist/router.js CHANGED
@@ -40,15 +40,21 @@ const logger = (0, logger_1.getLogger)({ service: "connect", filePath: __filenam
40
40
  // eslint-disable-next-line require-jsdoc
41
41
  function router(location, dataAPI) {
42
42
  return (request) => __awaiter(this, void 0, void 0, function* () {
43
+ var _a;
43
44
  const fromURI = request.message.from.address.uri;
44
45
  const requestURI = request.message.requestUri;
45
- logger.verbose("routing request from: " +
46
- (0, utils_1.getSIPURI)(fromURI) +
47
- ", to: " +
48
- (0, utils_1.getSIPURI)(requestURI), { fromURI: (0, utils_1.getSIPURI)(fromURI), requestURI: (0, utils_1.getSIPURI)(requestURI) });
49
46
  const caller = yield (0, utils_1.findResource)(dataAPI, fromURI.host, fromURI.user);
50
47
  const callee = yield (0, utils_1.findResource)(dataAPI, requestURI.host, requestURI.user);
51
48
  const routingDirection = (0, utils_1.getRoutingDirection)(caller, callee);
49
+ logger.verbose("routing request from: " +
50
+ (0, utils_1.getSIPURI)(fromURI) +
51
+ ", to: " +
52
+ (0, utils_1.getSIPURI)(requestURI), {
53
+ fromURI: (0, utils_1.getSIPURI)(fromURI),
54
+ requestURI: (0, utils_1.getSIPURI)(requestURI),
55
+ routingDirection,
56
+ sessionAffinityHeader: (_a = callee === null || callee === void 0 ? void 0 : callee.spec.location) === null || _a === void 0 ? void 0 : _a.sessionAffinityHeader
57
+ });
52
58
  if (request.method === common_1.CommonTypes.Method.INVITE) {
53
59
  const failedCheck = yield (0, access_1.checkAccess)({
54
60
  dataAPI,
@@ -67,7 +73,7 @@ function router(location, dataAPI) {
67
73
  case types_1.RoutingDirection.AGENT_TO_PSTN:
68
74
  return yield agentToPSTN(dataAPI, request, caller, requestURI.user);
69
75
  case types_1.RoutingDirection.FROM_PSTN:
70
- return yield fromPSTN(location, callee);
76
+ return yield fromPSTN(location, callee, request);
71
77
  case types_1.RoutingDirection.PEER_TO_PSTN:
72
78
  return yield peerToPSTN(dataAPI, request);
73
79
  default:
@@ -79,7 +85,7 @@ exports.router = router;
79
85
  // eslint-disable-next-line require-jsdoc
80
86
  function agentToAgent(location, req) {
81
87
  return __awaiter(this, void 0, void 0, function* () {
82
- return (yield location.findRoutes({ aor: processor_1.Target.getTargetAOR(req) }))[0];
88
+ return (yield location.findRoutes({ aor: processor_1.Target.getTargetAOR(req), callId: req.ref }))[0];
83
89
  });
84
90
  }
85
91
  /**
@@ -87,20 +93,24 @@ function agentToAgent(location, req) {
87
93
  *
88
94
  * @param {ILocationService} location - Location service
89
95
  * @param {Resource} callee - The callee
96
+ * @param {MessageRequest} req - The request
90
97
  * @return {Promise<Route>}
91
98
  */
92
- function fromPSTN(location, callee) {
99
+ function fromPSTN(location, callee, req) {
93
100
  var _a;
94
101
  return __awaiter(this, void 0, void 0, function* () {
102
+ const sessionAffinityRef = processor_1.Extensions.getHeaderValue(req, callee.spec.location.sessionAffinityHeader);
95
103
  const route = (yield location.findRoutes({
96
- aor: callee.spec.location.aorLink
104
+ aor: callee.spec.location.aorLink,
105
+ callId: req.ref,
106
+ sessionAffinityRef
97
107
  }))[0];
98
108
  if (!route) {
99
109
  throw new location_1.NotRoutesFoundForAOR(callee.spec.location.aorLink);
100
110
  }
101
111
  if (!route.headers)
102
112
  route.headers = [];
103
- (_a = callee.spec.location.props) === null || _a === void 0 ? void 0 : _a.forEach((prop) => {
113
+ (_a = callee.spec.location.extraHeaders) === null || _a === void 0 ? void 0 : _a.forEach((prop) => {
104
114
  const p = {
105
115
  name: prop.name,
106
116
  value: prop.value,
package/dist/service.js CHANGED
@@ -78,7 +78,7 @@ function ConnectProcessor(config) {
78
78
  res.send((0, tailor_1.tailor)(processor_1.Helper.createRouteFromLastMessage(req), req));
79
79
  break;
80
80
  default:
81
- yield (0, handlers_1.handleRequest)(location, common_2.CommonConnect.dataAPI(config.apiAddr))(req, res);
81
+ (0, handlers_1.handleRequest)(location, common_2.CommonConnect.dataAPI(config.apiAddr))(req, res);
82
82
  }
83
83
  }));
84
84
  }
package/dist/tailor.js CHANGED
@@ -22,7 +22,6 @@ exports.tailor = void 0;
22
22
  const processor_1 = require("@routr/processor");
23
23
  const function_1 = require("fp-ts/function");
24
24
  // Q: Should we add support for strict routing?
25
- const tailor = (route, req) => (0, function_1.pipe)(req, processor_1.Alterations.addSelfVia(route), processor_1.Alterations.applyXHeaders(route), processor_1.Alterations.addRoute(route), processor_1.Alterations.addSelfRecordRoute(route), processor_1.Alterations.decreaseMaxForwards, processor_1.Alterations.removeAuthorization, processor_1.Alterations.removeRoutes, processor_1.Alterations.removeXEdgePortRef
26
- // Add updateContact for SIP.js support
27
- );
25
+ // TODO: Add updateContact for SIP.js support
26
+ const tailor = (route, req) => (0, function_1.pipe)(req, processor_1.Alterations.decreaseMaxForwards, processor_1.Alterations.removeAuthorization, processor_1.Alterations.removeSelfRoutes, processor_1.Alterations.removeXEdgePortRef, processor_1.Alterations.addSelfVia(route), processor_1.Alterations.applyXHeaders(route), processor_1.Alterations.addSelfRecordRoute(route), processor_1.Alterations.addRouteToNextHop(route));
28
27
  exports.tailor = tailor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routr/connect",
3
- "version": "2.0.8-alpha.10",
3
+ "version": "2.0.8-alpha.12",
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.0.8-alpha.10",
32
- "@routr/location": "^2.0.8-alpha.10",
33
- "@routr/processor": "^2.0.8-alpha.10"
31
+ "@routr/common": "^2.0.8-alpha.12",
32
+ "@routr/location": "^2.0.8-alpha.12",
33
+ "@routr/processor": "^2.0.8-alpha.12"
34
34
  },
35
35
  "files": [
36
36
  "dist"
@@ -45,5 +45,5 @@
45
45
  "bugs": {
46
46
  "url": "https://github.com/fonoster/routr/issues"
47
47
  },
48
- "gitHead": "5082233fb155ddb8535f934550fa4013da87468e"
48
+ "gitHead": "57f6f94ceeba177909e209222d5ad0a1bc375896"
49
49
  }