@routr/common 2.0.5-alpha.6 → 2.0.5-alpha.9

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/auth.js CHANGED
@@ -23,7 +23,7 @@ const calculateAuthResponse = (res, credentials) => {
23
23
  const ha1 = md5hex(a1);
24
24
  const ha2 = md5hex(a2);
25
25
  return res.qop === 'auth'
26
- ? md5hex(`${ha1}:${res.nonce}:${decToHex(res.nonce_count)}:${res.c_nonce}:${res.qop}:${ha2}`)
26
+ ? md5hex(`${ha1}:${res.nonce}:${decToHex(res.nonceCount)}:${res.cNonce}:${res.qop}:${ha2}`)
27
27
  : md5hex(`${ha1}:${res.nonce}:${ha2}`);
28
28
  };
29
29
  exports.calculateAuthResponse = calculateAuthResponse;
package/dist/index.d.ts CHANGED
@@ -4,3 +4,4 @@ import { ServiceUnavailableError } from "./errors";
4
4
  import { Transport, ProcessorConfig, MessageRequest, MessageResponse, NetInterface, Method, ObjectProto, ServiceInfo, Route } from "./types";
5
5
  export { createService, getObjectProto, generateNonce, calculateAuthResponse, Route, ServiceUnavailableError, Transport, ProcessorConfig, MessageRequest, MessageResponse, NetInterface, Method, ObjectProto, ServiceInfo, PROCESSOR_OBJECT_PROTO, LOCATION_OBJECT_PROTO };
6
6
  export * as Helper from "./helper";
7
+ export * as IpUtils from "./ip_utils";
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
19
19
  return result;
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.Helper = exports.LOCATION_OBJECT_PROTO = exports.PROCESSOR_OBJECT_PROTO = exports.ServiceUnavailableError = exports.calculateAuthResponse = exports.generateNonce = exports.getObjectProto = exports.createService = void 0;
22
+ exports.IpUtils = exports.Helper = exports.LOCATION_OBJECT_PROTO = exports.PROCESSOR_OBJECT_PROTO = exports.Method = exports.Transport = exports.ServiceUnavailableError = exports.calculateAuthResponse = exports.generateNonce = exports.getObjectProto = exports.createService = void 0;
23
23
  /*
24
24
  * Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
25
25
  * http://github.com/fonoster/routr
@@ -48,4 +48,8 @@ Object.defineProperty(exports, "calculateAuthResponse", { enumerable: true, get:
48
48
  Object.defineProperty(exports, "generateNonce", { enumerable: true, get: function () { return auth_1.generateNonce; } });
49
49
  const errors_1 = require("./errors");
50
50
  Object.defineProperty(exports, "ServiceUnavailableError", { enumerable: true, get: function () { return errors_1.ServiceUnavailableError; } });
51
+ const types_1 = require("./types");
52
+ Object.defineProperty(exports, "Transport", { enumerable: true, get: function () { return types_1.Transport; } });
53
+ Object.defineProperty(exports, "Method", { enumerable: true, get: function () { return types_1.Method; } });
51
54
  exports.Helper = __importStar(require("./helper"));
55
+ exports.IpUtils = __importStar(require("./ip_utils"));
@@ -0,0 +1,4 @@
1
+ export declare const formatNet: (net: string) => string;
2
+ export declare const hasIp: (net: string, addr: string) => boolean;
3
+ export declare const addressCount: (net: string) => number;
4
+ export declare const isLocalnet: (nets: string[], addr: string) => boolean;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isLocalnet = exports.addressCount = exports.hasIp = exports.formatNet = void 0;
4
+ /*
5
+ * Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
6
+ * http://github.com/fonoster/routr
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 ip_utils_1 = require("ip-utils");
23
+ const formatNet = (net) => {
24
+ if (net.split('/').length === 1) {
25
+ if (ip_utils_1.isValidIpv4(net))
26
+ return `${net}/32`;
27
+ if (ip_utils_1.isValidIpv6(net))
28
+ return `${net}/128`;
29
+ throw 'Invalid address! Must be a valid Ipv4 or Ipv6';
30
+ }
31
+ const p1 = net.split('/')[0];
32
+ const p2 = net.split('/')[1];
33
+ return ip_utils_1.isValidIpv4(p2)
34
+ ? `${p1}/${ip_utils_1.subnetInfo(p1, p2).cidrMask}`
35
+ : `${p1}/${p2}`;
36
+ };
37
+ exports.formatNet = formatNet;
38
+ const hasIp = (net, addr) => ip_utils_1.subnet(exports.formatNet(net)).contains(addr);
39
+ exports.hasIp = hasIp;
40
+ const addressCount = (net) => ip_utils_1.cidrInfo(exports.formatNet(net)).inclusiveNumberHosts;
41
+ exports.addressCount = addressCount;
42
+ const isLocalnet = (nets, addr) => nets && nets.length > 0 && nets.filter(net => exports.hasIp(net, addr)).length > 0;
43
+ exports.isLocalnet = isLocalnet;
@@ -8,8 +8,8 @@ option java_outer_classname = "CommonProto";
8
8
  option objc_class_prefix = "CM";
9
9
 
10
10
  enum Transport {
11
- TCP = 0;
12
- UDP = 1;
11
+ UDP = 0;
12
+ TCP = 1;
13
13
  TLS = 2;
14
14
  SCTP = 3;
15
15
  WS = 4;
@@ -8,6 +8,7 @@ option java_outer_classname = "LocationProto";
8
8
  option objc_class_prefix = "LC";
9
9
 
10
10
  import "common.proto";
11
+ import "processor.proto";
11
12
 
12
13
  service Location {
13
14
  rpc AddRoute (AddRouteRequest) returns (fonoster.routr.common.v2draft1.Empty) {}
@@ -25,6 +26,7 @@ message Route {
25
26
  int32 expires = 6;
26
27
  int32 session_count = 7;
27
28
  string edge_port_ref = 8;
29
+ fonoster.routr.processor.v2draft1.NetInterface listening_point = 9;
28
30
  // During route creation, an endpoint can requet to add labels than can later be
29
31
  // used as selector. For example, a Softphone can add a label `priority=1` to indicate
30
32
  // that it is the prefer endpoint for the given AOR.
@@ -33,7 +35,7 @@ message Route {
33
35
  // feature. For example, we could use the label `backend=voice` to indicate that this
34
36
  // route can serve voice applications. If the FindRoutes method includes the label the
35
37
  // Location Service will only return routes that includes such label.
36
- map<string, string> labels = 9;
38
+ map<string, string> labels = 10;
37
39
  }
38
40
 
39
41
  message AddRouteRequest {
@@ -38,9 +38,10 @@ message MessageRequest {
38
38
  string edge_port_ref = 2;
39
39
  Method method = 3;
40
40
  NetInterface sender = 4;
41
- repeated NetInterface external_addrs = 5;
42
- repeated string localnets = 6;
43
- fonoster.routr.sipmessage.v2draft1.SIPMessage message = 7;
41
+ NetInterface listening_point = 5;
42
+ repeated string external_ips = 6;
43
+ repeated string localnets = 7;
44
+ fonoster.routr.sipmessage.v2draft1.SIPMessage message = 8;
44
45
  // .google.protobuf.Struct metadata = 8;
45
46
  }
46
47
 
@@ -121,7 +121,7 @@ message SipURI {
121
121
  string m_addr_param = 5;
122
122
  string method_param = 6;
123
123
  string user_param = 7;
124
- int32 t_t_l_param = 8;
124
+ int32 ttl_param = 8;
125
125
  int32 port = 9;
126
126
  bool lr_param = 10;
127
127
  bool secure = 11;
@@ -129,7 +129,7 @@ message SipURI {
129
129
 
130
130
  message Address {
131
131
  SipURI uri = 1;
132
- string display_name = 2;
132
+ string displayName = 2;
133
133
  bool wildcard = 3;
134
134
  }
135
135
 
package/dist/service.js CHANGED
@@ -9,7 +9,7 @@ const logger_1 = __importDefault(require("@fonoster/logger"));
9
9
  const protoLoader = require('@grpc/proto-loader');
10
10
  const grpc = require('@grpc/grpc-js');
11
11
  const loadOptions = {
12
- keepCase: true,
12
+ keepCase: false,
13
13
  longs: String,
14
14
  enums: String,
15
15
  defaults: true,
package/dist/types.d.ts CHANGED
@@ -1,5 +1,20 @@
1
- export declare type Method = 'UNKNOWN' | 'REGISTER' | 'INVITE' | 'MESSAGE' | 'PUBLISH' | 'NOTIFY' | 'SUBSCRIBE';
2
- export declare type Transport = 'TCP' | 'UDP' | 'TLS' | 'SCTP' | 'WS' | 'WSS';
1
+ export declare enum Method {
2
+ UNKNOWN = "UNKNOWN",
3
+ REGISTER = "REGISTER",
4
+ INVITE = "INVITE",
5
+ MESSAGE = "MESSAGE",
6
+ PUBLISH = "PUBLISH",
7
+ NOTIFY = "NOTIFY",
8
+ SUBSCRIBE = "SUBSCRIBE"
9
+ }
10
+ export declare enum Transport {
11
+ TCP = "TCP",
12
+ UDP = "UDP",
13
+ TLS = "TLS",
14
+ SCTP = "SCTP",
15
+ WS = "WS",
16
+ WSS = "WSS"
17
+ }
3
18
  export interface NetInterface {
4
19
  host: string;
5
20
  port: number;
@@ -7,10 +22,11 @@ export interface NetInterface {
7
22
  }
8
23
  export interface MessageRequest {
9
24
  ref: string;
10
- edge_port_ref: string;
25
+ edgePortRef: string;
11
26
  method: Method;
12
27
  sender: NetInterface;
13
- external_addrs: NetInterface[];
28
+ listeningPoint: NetInterface;
29
+ externalIps: string[];
14
30
  localnets: string[];
15
31
  message: Record<string, unknown>;
16
32
  }
@@ -53,8 +69,8 @@ export interface AuthChallengeResponse {
53
69
  realm: string;
54
70
  domain: string;
55
71
  scheme: string;
56
- c_nonce: string;
57
- nonce_count: number;
72
+ cNonce: string;
73
+ nonceCount: number;
58
74
  response: string;
59
75
  username: string;
60
76
  nonce: string;
@@ -69,10 +85,11 @@ export interface Route {
69
85
  user: string;
70
86
  host: string;
71
87
  port: number;
72
- transport: string;
88
+ transport: Transport;
73
89
  registeredOn: number;
74
90
  sessionCount?: number;
75
91
  expires: number;
76
92
  edgePortRef: string;
93
+ listeningPoint: NetInterface;
77
94
  labels?: Map<string, string>;
78
95
  }
package/dist/types.js CHANGED
@@ -1,2 +1,40 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Transport = exports.Method = void 0;
4
+ /*
5
+ * Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
6
+ * http://github.com/fonoster/routr
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
+ var Method;
23
+ (function (Method) {
24
+ Method["UNKNOWN"] = "UNKNOWN";
25
+ Method["REGISTER"] = "REGISTER";
26
+ Method["INVITE"] = "INVITE";
27
+ Method["MESSAGE"] = "MESSAGE";
28
+ Method["PUBLISH"] = "PUBLISH";
29
+ Method["NOTIFY"] = "NOTIFY";
30
+ Method["SUBSCRIBE"] = "SUBSCRIBE";
31
+ })(Method = exports.Method || (exports.Method = {}));
32
+ var Transport;
33
+ (function (Transport) {
34
+ Transport["TCP"] = "TCP";
35
+ Transport["UDP"] = "UDP";
36
+ Transport["TLS"] = "TLS";
37
+ Transport["SCTP"] = "SCTP";
38
+ Transport["WS"] = "WS";
39
+ Transport["WSS"] = "WSS";
40
+ })(Transport = exports.Transport || (exports.Transport = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routr/common",
3
- "version": "2.0.5-alpha.6",
3
+ "version": "2.0.5-alpha.9",
4
4
  "description": "Common package",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/routr#readme",
@@ -16,7 +16,8 @@
16
16
  "@fonoster/logger": "^0.3.3",
17
17
  "@grpc/grpc-js": "^1.5.9",
18
18
  "@grpc/proto-loader": "^0.6.9",
19
- "fp-ts": "^2.11.8"
19
+ "fp-ts": "^2.11.8",
20
+ "ip-utils": "^2.4.0"
20
21
  },
21
22
  "directories": {
22
23
  "src": "src",
@@ -35,5 +36,5 @@
35
36
  "bugs": {
36
37
  "url": "https://github.com/fonoster/routr/issues"
37
38
  },
38
- "gitHead": "ac4963e735fbc4ad3045379463796137e650509c"
39
+ "gitHead": "9eeafebb3f16625aca520268ed6f44896656f3a6"
39
40
  }