@routr/processor 2.31.4 → 2.31.5

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.
@@ -37,8 +37,8 @@ export declare const isAnonymous: (uri: CommonTypes.SipURI) => boolean;
37
37
  */
38
38
  export declare const rewriteFromWithNumber: (route: Route) => (request: MessageRequest) => MessageRequest;
39
39
  /**
40
- * The Record-Route parameters that remember how the identity alterations changed
41
- * a request's From and To. Both ends of the dialog copy Record-Route into the
40
+ * The identity mapping that remembers how the identity alterations changed a
41
+ * request's From and To; addSelfRecordRoute writes it in its Record-Route URI. Both ends of the dialog copy Record-Route into the
42
42
  * Route of their in-dialog requests, so the mapping comes back to Routr on every
43
43
  * BYE, re-INVITE and ACK without any state in Routr (see swapIdentityFromRouteSet).
44
44
  *
@@ -22,7 +22,7 @@ exports.swapIdentityFromRouteSet = exports.identityRewriteParameters = exports.r
22
22
  const common_1 = require("@routr/common");
23
23
  const phone_1 = require("phone");
24
24
  const helper_1 = require("./helper");
25
- const { IDENTITY_PARAMETERS, encodeIdentity, decodeIdentity, decodeIdentityUser } = common_1.Identity;
25
+ const { IDENTITY_PARAMETERS, encodeIdentity, encodeIdentityUser, decodeIdentity, decodeIdentityUser, portOf } = common_1.Identity;
26
26
  // Forces the requestURI to be the same as the trunk uri.
27
27
  // This is a workaround for Twilio.
28
28
  const fixRequestURI = (route) => (request) => {
@@ -146,10 +146,13 @@ const applyXHeaders = (route) => (request) => {
146
146
  return req;
147
147
  };
148
148
  exports.applyXHeaders = applyXHeaders;
149
- // The parameters argument is merged into every Record-Route entry this adds;
150
- // identityRewriteParameters uses it to carry a rewritten From or To.
149
+ // The parameters argument is the identity mapping from identityRewriteParameters.
150
+ // It goes in the URI user part of every Record-Route entry this adds, which a
151
+ // user agent keeps (RFC 3261 section 12.1.2), so a rewritten From or To comes
152
+ // back on the dialog's later requests (see swapIdentityFromRouteSet).
151
153
  const addSelfRecordRoute = (route, parameters = {}) => (request) => {
152
154
  const req = common_1.Helper.deepCopy(request);
155
+ const user = encodeIdentityUser(parameters);
153
156
  const originIntf = (0, helper_1.getEdgeInterface)({
154
157
  listeningPoints: request.listeningPoints,
155
158
  localnets: request.localnets,
@@ -169,12 +172,7 @@ const addSelfRecordRoute = (route, parameters = {}) => (request) => {
169
172
  });
170
173
  const originRoute = {
171
174
  address: {
172
- uri: {
173
- host: originIntf.host,
174
- port: originIntf.port,
175
- transportParam: originIntf.transport,
176
- lrParam: true
177
- }
175
+ uri: Object.assign(Object.assign({}, (user ? { user } : {})), { host: originIntf.host, port: originIntf.port, transportParam: originIntf.transport, lrParam: true })
178
176
  }
179
177
  };
180
178
  if (originIntf.host !== targetIntf.host ||
@@ -182,17 +180,16 @@ const addSelfRecordRoute = (route, parameters = {}) => (request) => {
182
180
  originIntf.transport !== targetIntf.transport) {
183
181
  const targetRoute = {
184
182
  address: {
185
- uri: {
186
- host: targetIntf.host,
187
- port: targetIntf.port,
188
- transportParam: targetIntf.transport,
189
- lrParam: true
190
- }
183
+ uri: Object.assign(Object.assign({}, (user ? { user } : {})), { host: targetIntf.host, port: targetIntf.port, transportParam: targetIntf.transport, lrParam: true })
191
184
  },
192
- parameters: Object.assign({ r2: "on" }, parameters)
185
+ parameters: {
186
+ r2: "on"
187
+ }
193
188
  };
194
189
  // Add r2 on to origin route
195
- originRoute.parameters = Object.assign({ r2: "on" }, parameters);
190
+ originRoute.parameters = {
191
+ r2: "on"
192
+ };
196
193
  req.message.recordRoute = [
197
194
  targetRoute,
198
195
  originRoute,
@@ -200,9 +197,6 @@ const addSelfRecordRoute = (route, parameters = {}) => (request) => {
200
197
  ];
201
198
  }
202
199
  else {
203
- if (Object.keys(parameters).length > 0) {
204
- originRoute.parameters = Object.assign({}, parameters);
205
- }
206
200
  req.message.recordRoute = [originRoute, ...req.message.recordRoute];
207
201
  }
208
202
  return req;
@@ -386,11 +380,12 @@ const changed = (a, b) => {
386
380
  var _a, _b, _c, _d;
387
381
  return ((_a = a.user) !== null && _a !== void 0 ? _a : "") !== ((_b = b.user) !== null && _b !== void 0 ? _b : "") ||
388
382
  a.host !== b.host ||
383
+ portOf(a) !== portOf(b) ||
389
384
  ((_c = a.userParam) !== null && _c !== void 0 ? _c : "") !== ((_d = b.userParam) !== null && _d !== void 0 ? _d : "");
390
385
  };
391
386
  /**
392
- * The Record-Route parameters that remember how the identity alterations changed
393
- * a request's From and To. Both ends of the dialog copy Record-Route into the
387
+ * The identity mapping that remembers how the identity alterations changed a
388
+ * request's From and To; addSelfRecordRoute writes it in its Record-Route URI. Both ends of the dialog copy Record-Route into the
394
389
  * Route of their in-dialog requests, so the mapping comes back to Routr on every
395
390
  * BYE, re-INVITE and ACK without any state in Routr (see swapIdentityFromRouteSet).
396
391
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routr/processor",
3
- "version": "2.31.4",
3
+ "version": "2.31.5",
4
4
  "description": "Processor server and API",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/routr#readme",
@@ -15,7 +15,7 @@
15
15
  "@fonoster/logger": "0.6.0",
16
16
  "@grpc/grpc-js": "~1.14.6",
17
17
  "@grpc/proto-loader": "~0.7.10",
18
- "@routr/common": "^2.31.4",
18
+ "@routr/common": "^2.31.5",
19
19
  "fp-ts": "^2.11.8",
20
20
  "phone": "^3.1.68"
21
21
  },
@@ -36,5 +36,5 @@
36
36
  "bugs": {
37
37
  "url": "https://github.com/fonoster/routr/issues"
38
38
  },
39
- "gitHead": "11c1ca25e5892aeea6f5b836b35cf9f90f020279"
39
+ "gitHead": "c0b54abe054aee1c28d6bc5c3402ba4bedba31a9"
40
40
  }