@routr/connect 2.0.8-alpha.41 → 2.0.8-alpha.43

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
@@ -8,9 +8,6 @@ export declare const checkAccess: (accessRequest: {
8
8
  routingDirection: RoutingDirection;
9
9
  }) => Promise<Record<string, unknown>>;
10
10
  export declare const checkAgentOrPeerAccess: (request: MessageRequest, caller: CC.RoutableResourceUnion) => Promise<{
11
- metadata: {
12
- accessKeyId: string;
13
- };
14
11
  message: {
15
12
  responseType: CT.ResponseType;
16
13
  reasonPhrase: string;
@@ -28,5 +25,21 @@ export declare const checkAgentOrPeerAccess: (request: MessageRequest, caller: C
28
25
  export declare const checkAccessFromPSTN: (apiClient: CC.APIClient, request: MessageRequest, callee: CC.INumber) => Promise<{
29
26
  message: {
30
27
  responseType: CT.ResponseType;
28
+ reasonPhrase: string;
29
+ wwwAuthenticate: {
30
+ scheme: string;
31
+ realm: string;
32
+ qop: string;
33
+ opaque: string;
34
+ stale: boolean;
35
+ nonce: string;
36
+ algorithm: string;
37
+ };
38
+ };
39
+ } | {
40
+ metadata: Record<string, string>;
41
+ message: {
42
+ responseType: CT.ResponseType;
43
+ reasonPhrase: string;
31
44
  };
32
45
  }>;
package/dist/handlers.js CHANGED
@@ -101,9 +101,7 @@ exports.handleRegistry = handleRegistry;
101
101
  const handleRequest = (location, apiClient) => (request, res) => __awaiter(void 0, void 0, void 0, function* () {
102
102
  try {
103
103
  const req = common_1.Environment.ENFORCE_E164 ? enforceE164(request) : request;
104
- req.metadata = {
105
- accessKeyId: "xxxxxxxxx"
106
- };
104
+ // Must get the metadata here before the request is forwarded
107
105
  const route = processor_1.Extensions.getHeaderValue(req, common_1.CommonTypes.ExtraHeader.EDGEPORT_REF)
108
106
  ? location_1.Helper.createRouteFromLastMessage(req)
109
107
  : yield (0, router_1.router)(location, apiClient)(req);
@@ -120,13 +118,14 @@ const handleRequest = (location, apiClient) => (request, res) => __awaiter(void
120
118
  // The order of the routes is important
121
119
  processor_1.Alterations.addRouteToPeerEdgePort(route), processor_1.Alterations.addRouteToNextHop(route), processor_1.Alterations.addXEdgePortRef, processor_1.Alterations.decreaseMaxForwards));
122
120
  }
121
+ // TODO: We should add this the Tailor API
122
+ req.metadata = route.metadata;
123
123
  res.send((0, tailor_1.tailor)(route, req));
124
124
  }
125
125
  }
126
126
  catch (err) {
127
- res.sendInternalServerError();
128
127
  logger.error(err);
129
- // res.sendError(err)
128
+ res.sendInternalServerError();
130
129
  }
131
130
  });
132
131
  exports.handleRequest = handleRequest;
package/dist/router.js CHANGED
@@ -104,15 +104,24 @@ function router(location, apiClient) {
104
104
  return failedCheck;
105
105
  }
106
106
  }
107
+ // We add metadata to the route object so we can use it later to link to an account
107
108
  switch (routingDirection) {
108
- case types_1.RoutingDirection.AGENT_TO_AGENT:
109
- return agentToAgent(location, request);
110
- case types_1.RoutingDirection.AGENT_TO_PEER:
111
- return yield agentToPeer(location, callee, request);
112
- case types_1.RoutingDirection.AGENT_TO_PSTN:
113
- return yield agentToPSTN(request, caller, requestURI.user);
114
- case types_1.RoutingDirection.FROM_PSTN:
115
- return yield fromPSTN(apiClient, location, callee, request);
109
+ case types_1.RoutingDirection.AGENT_TO_AGENT: {
110
+ const route = yield agentToAgent(location, request);
111
+ return Object.assign(Object.assign({}, route), { metadata: caller.extended });
112
+ }
113
+ case types_1.RoutingDirection.AGENT_TO_PEER: {
114
+ const route = yield agentToPeer(location, callee, request);
115
+ return Object.assign(Object.assign({}, route), { metadata: caller.extended });
116
+ }
117
+ case types_1.RoutingDirection.AGENT_TO_PSTN: {
118
+ const route = yield agentToPSTN(request, caller, requestURI.user);
119
+ return Object.assign(Object.assign({}, route), { metadata: caller.extended });
120
+ }
121
+ case types_1.RoutingDirection.FROM_PSTN: {
122
+ const route = yield fromPSTN(apiClient, location, callee, request);
123
+ return Object.assign(Object.assign({}, route), { metadata: callee.extended });
124
+ }
116
125
  case types_1.RoutingDirection.PEER_TO_PSTN:
117
126
  return yield peerToPSTN(apiClient, request);
118
127
  default:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routr/connect",
3
- "version": "2.0.8-alpha.41",
3
+ "version": "2.0.8-alpha.43",
4
4
  "description": "Default processor",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/routr#readme",
@@ -16,8 +16,7 @@
16
16
  "build": "tsc -b tsconfig.json"
17
17
  },
18
18
  "bin": {
19
- "run_connect": "dist/runner.js",
20
- "healthcheck_connect": "dist/healthcheck.js"
19
+ "run_connect": "dist/runner.js"
21
20
  },
22
21
  "dependencies": {
23
22
  "@fonoster/logger": "0.3.20",
@@ -29,9 +28,9 @@
29
28
  "@opentelemetry/sdk-trace-base": "^1.0.4",
30
29
  "@opentelemetry/sdk-trace-node": "^1.0.4",
31
30
  "@opentelemetry/semantic-conventions": "^1.0.4",
32
- "@routr/common": "^2.0.8-alpha.41",
33
- "@routr/location": "^2.0.8-alpha.41",
34
- "@routr/processor": "^2.0.8-alpha.41",
31
+ "@routr/common": "^2.0.8-alpha.43",
32
+ "@routr/location": "^2.0.8-alpha.43",
33
+ "@routr/processor": "^2.0.8-alpha.43",
35
34
  "jsonwebtoken": "^9.0.0"
36
35
  },
37
36
  "devDependencies": {
@@ -50,5 +49,5 @@
50
49
  "bugs": {
51
50
  "url": "https://github.com/fonoster/routr/issues"
52
51
  },
53
- "gitHead": "52f44320b57824dfea40f48b02b44b9a8e6bdda3"
52
+ "gitHead": "344a384c57bc0510c0daa65a7bbbd25b03d849b0"
54
53
  }
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,24 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- /*
5
- * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
6
- * http://github.com/fonoster
7
- *
8
- * This file is part of Routr.
9
- *
10
- * Licensed under the MIT License (the "License");
11
- * you may not use this file except in compliance with
12
- * the License. You may obtain a copy of the License at
13
- *
14
- * https://opensource.org/licenses/MIT
15
- *
16
- * Unless required by applicable law or agreed to in writing, software
17
- * distributed under the License is distributed on an "AS IS" BASIS,
18
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
- * See the License for the specific language governing permissions and
20
- * limitations under the License.
21
- */
22
- const common_1 = require("@routr/common");
23
- const envs_1 = require("./envs");
24
- common_1.HealthCheck.check(envs_1.BIND_ADDR);