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

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
@@ -83,13 +83,13 @@ 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.addRouteToPeerEdgePort(route), processor_1.Alterations.addXEdgePortRef, processor_1.Alterations.decreaseMaxForwards));
93
93
  }
94
94
  res.send((0, tailor_1.tailor)(route, req));
95
95
  }
package/dist/router.js CHANGED
@@ -67,7 +67,7 @@ function router(location, dataAPI) {
67
67
  case types_1.RoutingDirection.AGENT_TO_PSTN:
68
68
  return yield agentToPSTN(dataAPI, request, caller, requestURI.user);
69
69
  case types_1.RoutingDirection.FROM_PSTN:
70
- return yield fromPSTN(location, callee);
70
+ return yield fromPSTN(location, callee, request);
71
71
  case types_1.RoutingDirection.PEER_TO_PSTN:
72
72
  return yield peerToPSTN(dataAPI, request);
73
73
  default:
@@ -79,7 +79,7 @@ exports.router = router;
79
79
  // eslint-disable-next-line require-jsdoc
80
80
  function agentToAgent(location, req) {
81
81
  return __awaiter(this, void 0, void 0, function* () {
82
- return (yield location.findRoutes({ aor: processor_1.Target.getTargetAOR(req) }))[0];
82
+ return (yield location.findRoutes({ aor: processor_1.Target.getTargetAOR(req), callId: req.ref }))[0];
83
83
  });
84
84
  }
85
85
  /**
@@ -87,20 +87,24 @@ function agentToAgent(location, req) {
87
87
  *
88
88
  * @param {ILocationService} location - Location service
89
89
  * @param {Resource} callee - The callee
90
+ * @param {MessageRequest} req - The request
90
91
  * @return {Promise<Route>}
91
92
  */
92
- function fromPSTN(location, callee) {
93
+ function fromPSTN(location, callee, req) {
93
94
  var _a;
94
95
  return __awaiter(this, void 0, void 0, function* () {
96
+ const sessionAffinityRef = processor_1.Extensions.getHeaderValue(req, callee.spec.location.sessionAffinityHeader);
95
97
  const route = (yield location.findRoutes({
96
- aor: callee.spec.location.aorLink
98
+ aor: callee.spec.location.aorLink,
99
+ callId: req.ref,
100
+ sessionAffinityRef
97
101
  }))[0];
98
102
  if (!route) {
99
103
  throw new location_1.NotRoutesFoundForAOR(callee.spec.location.aorLink);
100
104
  }
101
105
  if (!route.headers)
102
106
  route.headers = [];
103
- (_a = callee.spec.location.props) === null || _a === void 0 ? void 0 : _a.forEach((prop) => {
107
+ (_a = callee.spec.location.extraHeaders) === null || _a === void 0 ? void 0 : _a.forEach((prop) => {
104
108
  const p = {
105
109
  name: prop.name,
106
110
  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/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.11",
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.11",
32
+ "@routr/location": "^2.0.8-alpha.11",
33
+ "@routr/processor": "^2.0.8-alpha.11"
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": "627659ac51d0814a3106bcaac31a15c581a5809f"
49
49
  }