@routr/processor 2.0.8-alpha.33 → 2.0.8-alpha.39

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.
@@ -11,5 +11,5 @@ export declare const removeAuthorization: (request: MessageRequest) => MessageRe
11
11
  export declare const removeSelfRoutes: (request: MessageRequest) => MessageRequest;
12
12
  export declare const removeTopVia: (request: MessageRequest) => MessageRequest;
13
13
  export declare const decreaseMaxForwards: (request: MessageRequest) => MessageRequest;
14
- export declare const fixNatedContact: (request: MessageRequest) => MessageRequest;
14
+ export declare const fixInvalidContact: (request: MessageRequest) => MessageRequest;
15
15
  export declare const enforceE164: (enforceE164: boolean, validateMobilePrefix: boolean) => (request: MessageRequest) => MessageRequest;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.enforceE164 = exports.fixNatedContact = exports.decreaseMaxForwards = exports.removeTopVia = exports.removeSelfRoutes = exports.removeAuthorization = exports.removeXEdgePortRef = exports.addXEdgePortRef = exports.addSelfRecordRoute = exports.applyXHeaders = exports.addRouteToPeerEdgePort = exports.addRouteToNextHop = exports.addSelfVia = exports.updateRequestURI = void 0;
3
+ exports.enforceE164 = exports.fixInvalidContact = exports.decreaseMaxForwards = exports.removeTopVia = exports.removeSelfRoutes = exports.removeAuthorization = exports.removeXEdgePortRef = exports.addXEdgePortRef = exports.addSelfRecordRoute = exports.applyXHeaders = exports.addRouteToPeerEdgePort = exports.addRouteToNextHop = exports.addSelfVia = exports.updateRequestURI = void 0;
4
4
  /*
5
5
  * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
6
6
  * http://github.com/fonoster/routr
@@ -212,16 +212,20 @@ const decreaseMaxForwards = (request) => {
212
212
  return req;
213
213
  };
214
214
  exports.decreaseMaxForwards = decreaseMaxForwards;
215
- const fixNatedContact = (request) => {
215
+ const fixInvalidContact = (request) => {
216
216
  var _a;
217
217
  const req = common_1.Helper.deepCopy(request);
218
+ const via = req.message.via[0];
218
219
  if ((_a = req.message.contact) === null || _a === void 0 ? void 0 : _a.address.uri.host.includes(".invalid")) {
219
- req.message.contact.address.uri.host = request.sender.host;
220
- req.message.contact.address.uri.port = request.sender.port;
220
+ req.message.contact.address.uri.host = via.received || via.host;
221
+ req.message.contact.address.uri.port =
222
+ via.rPort !== -1 ? via.rPort : via.port;
223
+ req.message.contact.address.uri.transportParam =
224
+ via.transport.toUpperCase();
221
225
  }
222
226
  return req;
223
227
  };
224
- exports.fixNatedContact = fixNatedContact;
228
+ exports.fixInvalidContact = fixInvalidContact;
225
229
  // Will do the best effort to normalize from/to/requestUri users as e164 values
226
230
  const enforceE164 = (enforceE164, validateMobilePrefix) => (request) => {
227
231
  var _a, _b, _c;
package/dist/helper.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { MessageRequest, Route, Transport, NetInterface } from "@routr/common";
1
+ import { MessageRequest, Transport, NetInterface } from "@routr/common";
2
2
  export declare const isTypeResponse: (request: MessageRequest) => boolean;
3
3
  export declare const isTypeRequest: (request: MessageRequest) => boolean;
4
4
  export declare const getEdgeInterface: (nets: {
@@ -7,14 +7,6 @@ export declare const getEdgeInterface: (nets: {
7
7
  localnets: string[];
8
8
  externalAddrs: string[];
9
9
  }) => NetInterface;
10
- /**
11
- * A request traversing a second EdgePort would have updated the requestUri.
12
- * Therefore, we are able to re-construct the Route from the request.
13
- *
14
- * @param {MessageRequest} request - the request
15
- * @return {Route} the route
16
- */
17
- export declare function createRouteFromLastMessage(request: MessageRequest): Route;
18
10
  export declare const hasSDP: (request: MessageRequest) => boolean;
19
11
  export declare const isOk: (request: MessageRequest) => boolean;
20
12
  export declare const isRinging: (request: MessageRequest) => boolean;
package/dist/helper.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isBye = exports.isOkOrRingingWithSDP = exports.isInviteOrAckWithSDP = exports.isWebRTC = exports.isRinging = exports.isOk = exports.hasSDP = exports.createRouteFromLastMessage = exports.getEdgeInterface = exports.isTypeRequest = exports.isTypeResponse = void 0;
3
+ exports.isBye = exports.isOkOrRingingWithSDP = exports.isInviteOrAckWithSDP = exports.isWebRTC = exports.isRinging = exports.isOk = exports.hasSDP = exports.getEdgeInterface = exports.isTypeRequest = exports.isTypeResponse = void 0;
4
4
  /*
5
5
  * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
6
6
  * http://github.com/fonoster/routr
@@ -21,7 +21,6 @@ exports.isBye = exports.isOkOrRingingWithSDP = exports.isInviteOrAckWithSDP = ex
21
21
  */
22
22
  const common_1 = require("@routr/common");
23
23
  const common_2 = require("@routr/common");
24
- const index_1 = require("./index");
25
24
  const isTypeResponse = (request) => request.message.messageType === common_1.CommonTypes.MessageType.RESPONSE;
26
25
  exports.isTypeResponse = isTypeResponse;
27
26
  const isTypeRequest = (request) => !(0, exports.isTypeResponse)(request);
@@ -44,34 +43,6 @@ const getEdgeInterface = (nets) => {
44
43
  };
45
44
  };
46
45
  exports.getEdgeInterface = getEdgeInterface;
47
- /**
48
- * A request traversing a second EdgePort would have updated the requestUri.
49
- * Therefore, we are able to re-construct the Route from the request.
50
- *
51
- * @param {MessageRequest} request - the request
52
- * @return {Route} the route
53
- */
54
- function createRouteFromLastMessage(request) {
55
- var _a;
56
- const uri = request.message.requestUri;
57
- const sessionCount = index_1.Extensions.getHeaderValue(request, common_1.CommonTypes.ExtraHeader.SESSION_COUNT)
58
- ? parseInt(index_1.Extensions.getHeaderValue(request, common_1.CommonTypes.ExtraHeader.SESSION_COUNT))
59
- : -1;
60
- return {
61
- edgePortRef: request.edgePortRef,
62
- user: uri.user,
63
- host: uri.host,
64
- port: uri.port,
65
- transport: (_a = uri.transportParam) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
66
- registeredOn: Date.now(),
67
- sessionCount,
68
- expires: index_1.Target.getTargetExpires(request),
69
- listeningPoints: request.listeningPoints,
70
- localnets: request.localnets,
71
- externalAddrs: request.externalAddrs
72
- };
73
- }
74
- exports.createRouteFromLastMessage = createRouteFromLastMessage;
75
46
  const hasSDP = (request) => { var _a; return ((_a = request.message.body) === null || _a === void 0 ? void 0 : _a.length) > 0; };
76
47
  exports.hasSDP = hasSDP;
77
48
  const isOk = (request) => request.message.responseType === common_1.CommonTypes.ResponseType.OK;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routr/processor",
3
- "version": "2.0.8-alpha.33",
3
+ "version": "2.0.8-alpha.39",
4
4
  "description": "Processor server and API",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/routr#readme",
@@ -23,7 +23,7 @@
23
23
  "@opentelemetry/sdk-trace-base": "^1.0.4",
24
24
  "@opentelemetry/sdk-trace-node": "^1.0.4",
25
25
  "@opentelemetry/semantic-conventions": "^1.0.4",
26
- "@routr/common": "^2.0.8-alpha.33",
26
+ "@routr/common": "^2.0.8-alpha.39",
27
27
  "fp-ts": "^2.11.8",
28
28
  "phone": "^3.1.32"
29
29
  },
@@ -44,5 +44,5 @@
44
44
  "bugs": {
45
45
  "url": "https://github.com/fonoster/routr/issues"
46
46
  },
47
- "gitHead": "ba083087c734dcc29b190bacd12b41c480d11563"
47
+ "gitHead": "43d5cae0cb5a2c373ed7b219f5d73a42319b9ba5"
48
48
  }