@routr/common 2.0.8-alpha.21 → 2.0.8-alpha.23

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.
@@ -33,4 +33,5 @@ export declare const isValidAOROrThrow: (aor: string) => void;
33
33
  export declare const hasAORLinkOrThrow: (aorLink: string) => void;
34
34
  export declare const isValidAORLinkOrThrow: (aorLink: string) => void;
35
35
  export declare const isValidContactAddressOrThrow: (contactAddress: string) => void;
36
+ export declare const isValidE164OrThrow: (e164Number: string, countryISOCode: string, validateMobilePrefix: boolean) => void;
36
37
  export declare const hasValidOutboundUrisOrThrow: (outboundUris: TrunkURI[]) => void;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasValidOutboundUrisOrThrow = exports.isValidContactAddressOrThrow = exports.isValidAORLinkOrThrow = exports.hasAORLinkOrThrow = exports.isValidAOROrThrow = exports.hasAOROrThrow = exports.isValidInboundUriOrThrow = exports.hasInboundUriOrThrow = exports.hasCountryISOCodeOrThrow = exports.hasCountryOrThrow = exports.hasCityOrThrow = exports.isValidSessionAffinityHeaderOrThrow = exports.hasTelUrlOrThrow = exports.isValidDomainUriOrThrow = exports.hasDomainUriOrThrow = exports.hasPasswordOrThrow = exports.isValidUsernameOrThrow = exports.hasUsernameOrThrow = exports.isValidNameOrThrow = exports.hasNameOrThrow = exports.hasRefenceOrThrow = exports.hasValidACLRulesOrThrow = exports.hasACLRulesOrThrow = exports.isValidBalancingAlgorithmOrThrow = exports.hasValidHeadersOrThrow = void 0;
3
+ exports.hasValidOutboundUrisOrThrow = exports.isValidE164OrThrow = exports.isValidContactAddressOrThrow = exports.isValidAORLinkOrThrow = exports.hasAORLinkOrThrow = exports.isValidAOROrThrow = exports.hasAOROrThrow = exports.isValidInboundUriOrThrow = exports.hasInboundUriOrThrow = exports.hasCountryISOCodeOrThrow = exports.hasCountryOrThrow = exports.hasCityOrThrow = exports.isValidSessionAffinityHeaderOrThrow = exports.hasTelUrlOrThrow = exports.isValidDomainUriOrThrow = exports.hasDomainUriOrThrow = exports.hasPasswordOrThrow = exports.isValidUsernameOrThrow = exports.hasUsernameOrThrow = exports.isValidNameOrThrow = exports.hasNameOrThrow = exports.hasRefenceOrThrow = exports.hasValidACLRulesOrThrow = exports.hasACLRulesOrThrow = exports.isValidBalancingAlgorithmOrThrow = exports.hasValidHeadersOrThrow = void 0;
4
4
  /*
5
5
  * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
6
6
  * http://github.com/fonoster
@@ -85,6 +85,13 @@ const isValidAORLinkOrThrow = (aorLink) => validOrThrow(validations_1.isValidAOR
85
85
  exports.isValidAORLinkOrThrow = isValidAORLinkOrThrow;
86
86
  const isValidContactAddressOrThrow = (contactAddress) => validOrThrow(validations_1.isValidContactAddress, contactAddress);
87
87
  exports.isValidContactAddressOrThrow = isValidContactAddressOrThrow;
88
+ const isValidE164OrThrow = (e164Number, countryISOCode, validateMobilePrefix) => {
89
+ const R = (0, validations_1.isValidE164)(e164Number, countryISOCode, validateMobilePrefix);
90
+ if (R instanceof errors_1.BadRequestError) {
91
+ throw R;
92
+ }
93
+ };
94
+ exports.isValidE164OrThrow = isValidE164OrThrow;
88
95
  const hasValidOutboundUrisOrThrow = (outboundUris) => outboundUris === null || outboundUris === void 0 ? void 0 : outboundUris.forEach((uri) => {
89
96
  if ((0, validations_1.hasHost)(uri.host) instanceof errors_1.BadRequestError) {
90
97
  throw (0, validations_1.hasHost)(uri.host);
@@ -40,3 +40,4 @@ export declare const isValidHost: (host: string) => true | BadRequestError;
40
40
  export declare const isValidContactAddress: (contactAddress: string) => BadRequestError;
41
41
  export declare const isValidPriority: (priority: string) => BadRequestError;
42
42
  export declare const isValidWeight: (weight: string) => BadRequestError;
43
+ export declare const isValidE164: (e164Number: string, countryISOCode: string, validateMobilePrefix?: boolean) => BadRequestError;
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.isValidWeight = exports.isValidPriority = exports.isValidContactAddress = exports.isValidHost = exports.hasHost = exports.isValidPort = exports.isValidBalancingAlgorithm = exports.isValidInboundUri = exports.hasInboundUri = exports.hasValidACLRules = exports.isValidACLRule = exports.hasACLRules = exports.hasCountryISOCode = exports.hasCountry = exports.hasCity = exports.isValidAORLink = exports.hasAORLink = exports.isValidAOR = exports.hasAOR = exports.hasValidHeaders = exports.isValidHeader = exports.isValidSessionAffinityHeader = exports.hasTelUrl = exports.isValidDomainUri = exports.hasDomainUri = exports.hasPassword = exports.isValidUsername = exports.hasUsername = exports.isValidName = exports.hasName = exports.hasReference = void 0;
26
+ exports.isValidE164 = exports.isValidWeight = exports.isValidPriority = exports.isValidContactAddress = exports.isValidHost = exports.hasHost = exports.isValidPort = exports.isValidBalancingAlgorithm = exports.isValidInboundUri = exports.hasInboundUri = exports.hasValidACLRules = exports.isValidACLRule = exports.hasACLRules = exports.hasCountryISOCode = exports.hasCountry = exports.hasCity = exports.isValidAORLink = exports.hasAORLink = exports.isValidAOR = exports.hasAOR = exports.hasValidHeaders = exports.isValidHeader = exports.isValidSessionAffinityHeader = exports.hasTelUrl = exports.isValidDomainUri = exports.hasDomainUri = exports.hasPassword = exports.isValidUsername = exports.hasUsername = exports.isValidName = exports.hasName = exports.hasReference = void 0;
27
27
  /*
28
28
  * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
29
29
  * http://github.com/fonoster
@@ -45,6 +45,7 @@ exports.isValidWeight = exports.isValidPriority = exports.isValidContactAddress
45
45
  const Validator = __importStar(require("validator"));
46
46
  const errors_1 = require("../errors");
47
47
  const types_1 = require("../types");
48
+ const phone_1 = require("phone");
48
49
  const hasReference = (ref) => ref ? true : new errors_1.BadRequestError("the reference to the resource is required");
49
50
  exports.hasReference = hasReference;
50
51
  const hasName = (name) => name
@@ -259,3 +260,13 @@ const isValidWeight = (weight) => {
259
260
  }
260
261
  };
261
262
  exports.isValidWeight = isValidWeight;
263
+ const isValidE164 = (e164Number, countryISOCode, validateMobilePrefix = false) => {
264
+ const result = (0, phone_1.phone)(e164Number, {
265
+ country: countryISOCode,
266
+ validateMobilePrefix
267
+ });
268
+ if (!result.isValid) {
269
+ return new errors_1.BadRequestError("the telUrl must be a valid e164 number");
270
+ }
271
+ };
272
+ exports.isValidE164 = isValidE164;
package/dist/envs.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare const ENFORCE_E164: boolean;
2
+ export declare const ENFORCE_E164_WITH_MOBILE_PREFIX: boolean;
package/dist/envs.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ENFORCE_E164_WITH_MOBILE_PREFIX = exports.ENFORCE_E164 = void 0;
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
+ exports.ENFORCE_E164 = process.env.ENFORCE_E164 === "true" ? true : false;
23
+ exports.ENFORCE_E164_WITH_MOBILE_PREFIX = process.env.ENFORCE_E164_WITH_MOBILE_PREFIX === "true" ? true : false;
package/dist/index.d.ts CHANGED
@@ -12,3 +12,4 @@ export * as CommonRequester from "./requester";
12
12
  export * as CommonTypes from "./types";
13
13
  export * as CommonErrors from "./errors";
14
14
  export * as ConnectSchemas from "./connect/schemas";
15
+ export * as Environment from "./envs";
package/dist/index.js CHANGED
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.ConnectSchemas = exports.CommonErrors = exports.CommonTypes = exports.CommonRequester = exports.CommonConnect = exports.Assertions = exports.Tracer = exports.IpUtils = exports.Helper = exports.Redis = exports.Auth = exports.LOCATION_OBJECT_PROTO = exports.PROCESSOR_OBJECT_PROTO = exports.Method = exports.Transport = exports.getObjectProto = exports.createService = void 0;
26
+ exports.Environment = exports.ConnectSchemas = exports.CommonErrors = exports.CommonTypes = exports.CommonRequester = exports.CommonConnect = exports.Assertions = exports.Tracer = exports.IpUtils = exports.Helper = exports.Redis = exports.Auth = exports.LOCATION_OBJECT_PROTO = exports.PROCESSOR_OBJECT_PROTO = exports.Method = exports.Transport = exports.getObjectProto = exports.createService = void 0;
27
27
  /*
28
28
  * Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
29
29
  * http://github.com/fonoster/routr
@@ -61,3 +61,4 @@ exports.CommonRequester = __importStar(require("./requester"));
61
61
  exports.CommonTypes = __importStar(require("./types"));
62
62
  exports.CommonErrors = __importStar(require("./errors"));
63
63
  exports.ConnectSchemas = __importStar(require("./connect/schemas"));
64
+ exports.Environment = __importStar(require("./envs"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routr/common",
3
- "version": "2.0.8-alpha.21",
3
+ "version": "2.0.8-alpha.23",
4
4
  "description": "Common package",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/routr#readme",
@@ -29,6 +29,7 @@
29
29
  "ip-utils": "^2.4.0",
30
30
  "js-yaml": "^4.1.0",
31
31
  "pb-util": "^1.0.3",
32
+ "phone": "^3.1.32",
32
33
  "toml": "^3.0.0",
33
34
  "validator": "^13.7.0"
34
35
  },
@@ -52,5 +53,5 @@
52
53
  "devDependencies": {
53
54
  "@types/js-yaml": "^4.0.5"
54
55
  },
55
- "gitHead": "1841d2d8d51bebfdc3af7e81435064e81b176449"
56
+ "gitHead": "1347b753f0dbdd3bdf423f2691867aa250b768af"
56
57
  }