@routr/common 2.33.0 → 2.34.0
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/connect/country_iso_code_schema.d.ts +6 -0
- package/dist/connect/country_iso_code_schema.js +26 -0
- package/dist/connect/index.d.ts +4 -0
- package/dist/connect/index.js +4 -0
- package/dist/connect/protos/trunks.proto +4 -1
- package/dist/connect/schemas/trunk.js +4 -4
- package/dist/connect/tel_url_schema.d.ts +7 -0
- package/dist/connect/tel_url_schema.js +28 -0
- package/dist/connect/trunk_number_format_schema.d.ts +9 -0
- package/dist/connect/trunk_number_format_schema.js +5 -1
- package/dist/connect/validate_country_iso_code.d.ts +11 -0
- package/dist/connect/validate_country_iso_code.js +44 -0
- package/dist/connect/validate_tel_url.d.ts +10 -0
- package/dist/connect/validate_tel_url.js +50 -0
- package/dist/connect/validate_trunk_number_format.d.ts +5 -3
- package/dist/connect/validate_trunk_number_format.js +26 -10
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/parse_boolean_env.d.ts +10 -0
- package/dist/parse_boolean_env.js +37 -0
- package/dist/types.d.ts +3 -1
- package/dist/types.js +5 -1
- package/package.json +3 -2
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
/** Schema for checking the countryIsoCode of a new Number. */
|
|
3
|
+
export declare const validateCountryIsoCodeSchema: z.ZodObject<{
|
|
4
|
+
countryIsoCode: z.ZodString;
|
|
5
|
+
}, z.core.$strip>;
|
|
6
|
+
export type ValidateCountryIsoCodeInput = z.infer<typeof validateCountryIsoCodeSchema>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateCountryIsoCodeSchema = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (C) 2026 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 v4_1 = require("zod/v4");
|
|
23
|
+
/** Schema for checking the countryIsoCode of a new Number. */
|
|
24
|
+
exports.validateCountryIsoCodeSchema = v4_1.z.object({
|
|
25
|
+
countryIsoCode: v4_1.z.string({ error: "countryIsoCode must be a string" })
|
|
26
|
+
});
|
package/dist/connect/index.d.ts
CHANGED
|
@@ -9,4 +9,8 @@ export * from "./assertions";
|
|
|
9
9
|
export * from "./validations";
|
|
10
10
|
export * from "./number_aliases_schema";
|
|
11
11
|
export * from "./validate_number_aliases";
|
|
12
|
+
export * from "./tel_url_schema";
|
|
13
|
+
export * from "./validate_tel_url";
|
|
14
|
+
export * from "./country_iso_code_schema";
|
|
15
|
+
export * from "./validate_country_iso_code";
|
|
12
16
|
export * from "./connect_error";
|
package/dist/connect/index.js
CHANGED
|
@@ -43,4 +43,8 @@ __exportStar(require("./assertions"), exports);
|
|
|
43
43
|
__exportStar(require("./validations"), exports);
|
|
44
44
|
__exportStar(require("./number_aliases_schema"), exports);
|
|
45
45
|
__exportStar(require("./validate_number_aliases"), exports);
|
|
46
|
+
__exportStar(require("./tel_url_schema"), exports);
|
|
47
|
+
__exportStar(require("./validate_tel_url"), exports);
|
|
48
|
+
__exportStar(require("./country_iso_code_schema"), exports);
|
|
49
|
+
__exportStar(require("./validate_country_iso_code"), exports);
|
|
46
50
|
__exportStar(require("./connect_error"), exports);
|
|
@@ -68,8 +68,11 @@ enum NumberFormat {
|
|
|
68
68
|
E164 = 1;
|
|
69
69
|
// 442079460018
|
|
70
70
|
E164_WITHOUT_PLUS = 2;
|
|
71
|
-
// 02079460018
|
|
71
|
+
// 02079460018; a number of another country in international form
|
|
72
72
|
NATIONAL = 3;
|
|
73
|
+
// 00442079460018: the international prefix of the Number's country, the
|
|
74
|
+
// country code and the national number
|
|
75
|
+
INTERNATIONAL = 4;
|
|
73
76
|
}
|
|
74
77
|
|
|
75
78
|
// The message for the Trunk resource
|
|
@@ -65,21 +65,21 @@ exports.default = {
|
|
|
65
65
|
},
|
|
66
66
|
calledNumberFormat: {
|
|
67
67
|
description: "How the To and Request-URI users are written on calls leaving through this Trunk",
|
|
68
|
-
enum: ["e164", "e164-without-plus", "national"]
|
|
68
|
+
enum: ["e164", "e164-without-plus", "national", "international"]
|
|
69
69
|
},
|
|
70
70
|
calledNumberPrefix: {
|
|
71
71
|
description: "Prepended to the called number after formatting",
|
|
72
72
|
type: "string",
|
|
73
|
-
pattern: "^[0-9
|
|
73
|
+
pattern: "^[0-9*#]{1,20}$"
|
|
74
74
|
},
|
|
75
75
|
callerNumberFormat: {
|
|
76
76
|
description: "How the Number in P-Asserted-Identity, Remote-Party-ID and a rewritten From is written on calls leaving through this Trunk",
|
|
77
|
-
enum: ["e164", "e164-without-plus", "national"]
|
|
77
|
+
enum: ["e164", "e164-without-plus", "national", "international"]
|
|
78
78
|
},
|
|
79
79
|
callerNumberPrefix: {
|
|
80
80
|
description: "Prepended to the caller number after formatting",
|
|
81
81
|
type: "string",
|
|
82
|
-
pattern: "^[0-9
|
|
82
|
+
pattern: "^[0-9*#]{1,20}$"
|
|
83
83
|
},
|
|
84
84
|
trace: {
|
|
85
85
|
description: "Message recording for the calls that touch this Trunk",
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
/** Schema for checking the telUrl of a new Number. */
|
|
3
|
+
export declare const validateTelUrlSchema: z.ZodObject<{
|
|
4
|
+
telUrl: z.ZodString;
|
|
5
|
+
requireE164: z.ZodBoolean;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
export type ValidateTelUrlInput = z.infer<typeof validateTelUrlSchema>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateTelUrlSchema = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (C) 2026 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 v4_1 = require("zod/v4");
|
|
23
|
+
/** Schema for checking the telUrl of a new Number. */
|
|
24
|
+
exports.validateTelUrlSchema = v4_1.z.object({
|
|
25
|
+
telUrl: v4_1.z.string({ error: "telUrl must be a string" }),
|
|
26
|
+
// REQUIRE_E164_NUMBERS, read by the service and passed in
|
|
27
|
+
requireE164: v4_1.z.boolean({ error: "requireE164 must be a boolean" })
|
|
28
|
+
});
|
|
@@ -8,3 +8,12 @@ export declare const trunkNumberFormatSchema: z.ZodObject<{
|
|
|
8
8
|
callerNumberPrefix: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
9
9
|
}, z.core.$strip>;
|
|
10
10
|
export type TrunkNumberFormatInput = z.infer<typeof trunkNumberFormatSchema>;
|
|
11
|
+
/** Schema for the Trunk Update check: the request's ref and format fields. */
|
|
12
|
+
export declare const assertTrunkNumberFormatSchema: z.ZodObject<{
|
|
13
|
+
calledNumberFormat: z.ZodOptional<z.ZodNullable<z.ZodEnum<typeof NumberFormat>>>;
|
|
14
|
+
calledNumberPrefix: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
15
|
+
callerNumberFormat: z.ZodOptional<z.ZodNullable<z.ZodEnum<typeof NumberFormat>>>;
|
|
16
|
+
callerNumberPrefix: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
17
|
+
ref: z.ZodString;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export type AssertTrunkNumberFormatInput = z.infer<typeof assertTrunkNumberFormatSchema>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.trunkNumberFormatSchema = void 0;
|
|
3
|
+
exports.assertTrunkNumberFormatSchema = exports.trunkNumberFormatSchema = void 0;
|
|
4
4
|
/*
|
|
5
5
|
* Copyright (C) 2026 by Fonoster Inc (https://fonoster.com)
|
|
6
6
|
* http://github.com/fonoster/routr
|
|
@@ -34,3 +34,7 @@ exports.trunkNumberFormatSchema = v4_1.z.object({
|
|
|
34
34
|
callerNumberFormat: format,
|
|
35
35
|
callerNumberPrefix: prefix
|
|
36
36
|
});
|
|
37
|
+
/** Schema for the Trunk Update check: the request's ref and format fields. */
|
|
38
|
+
exports.assertTrunkNumberFormatSchema = exports.trunkNumberFormatSchema.extend({
|
|
39
|
+
ref: v4_1.z.string({ error: "ref must be a string" })
|
|
40
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks the countryIsoCode of a Number created through the API: an ISO
|
|
3
|
+
* 3166-1 alpha-2 code, any case, of a country libphonenumber-js has a
|
|
4
|
+
* numbering plan for. Connect reads the Number's national and international
|
|
5
|
+
* forms with it.
|
|
6
|
+
*
|
|
7
|
+
* @param {ValidateCountryIsoCodeInput} params - the countryIsoCode
|
|
8
|
+
* @throws {ValidationError} when params has the wrong shape
|
|
9
|
+
* @throws {BadRequestError} (INVALID_ARGUMENT) when no numbering plan has the code
|
|
10
|
+
*/
|
|
11
|
+
export declare function validateCountryIsoCode(params: unknown): void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateCountryIsoCode = validateCountryIsoCode;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (C) 2026 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 libphonenumber_js_1 = require("libphonenumber-js");
|
|
23
|
+
const errors_1 = require("../errors");
|
|
24
|
+
const validation_error_1 = require("../validation_error");
|
|
25
|
+
const country_iso_code_schema_1 = require("./country_iso_code_schema");
|
|
26
|
+
/**
|
|
27
|
+
* Checks the countryIsoCode of a Number created through the API: an ISO
|
|
28
|
+
* 3166-1 alpha-2 code, any case, of a country libphonenumber-js has a
|
|
29
|
+
* numbering plan for. Connect reads the Number's national and international
|
|
30
|
+
* forms with it.
|
|
31
|
+
*
|
|
32
|
+
* @param {ValidateCountryIsoCodeInput} params - the countryIsoCode
|
|
33
|
+
* @throws {ValidationError} when params has the wrong shape
|
|
34
|
+
* @throws {BadRequestError} (INVALID_ARGUMENT) when no numbering plan has the code
|
|
35
|
+
*/
|
|
36
|
+
function validateCountryIsoCode(params) {
|
|
37
|
+
const parsed = country_iso_code_schema_1.validateCountryIsoCodeSchema.safeParse(params);
|
|
38
|
+
if (!parsed.success)
|
|
39
|
+
throw new validation_error_1.ValidationError(parsed.error);
|
|
40
|
+
const { countryIsoCode } = parsed.data;
|
|
41
|
+
if (!(0, libphonenumber_js_1.isSupportedCountry)(countryIsoCode.toUpperCase())) {
|
|
42
|
+
throw new errors_1.BadRequestError(`countryIsoCode "${countryIsoCode}" is not a country with a numbering plan`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks the telUrl of a new Number. With requireE164 (REQUIRE_E164_NUMBERS)
|
|
3
|
+
* it must be tel:+ followed by an E.164 number; without it, it only has to
|
|
4
|
+
* start with tel:. A telUrl can't be updated, so only a create checks it.
|
|
5
|
+
*
|
|
6
|
+
* @param {ValidateTelUrlInput} params - the telUrl and whether it must be E.164
|
|
7
|
+
* @throws {ValidationError} when params has the wrong shape
|
|
8
|
+
* @throws {BadRequestError} (INVALID_ARGUMENT) when the telUrl breaks the rule
|
|
9
|
+
*/
|
|
10
|
+
export declare function validateTelUrl(params: unknown): void;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateTelUrl = validateTelUrl;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (C) 2026 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 errors_1 = require("../errors");
|
|
23
|
+
const validation_error_1 = require("../validation_error");
|
|
24
|
+
const tel_url_schema_1 = require("./tel_url_schema");
|
|
25
|
+
// tel:+ then 2 to 15 digits, the first not 0 (ITU-T E.164)
|
|
26
|
+
const E164_TEL_URL = /^tel:\+[1-9][0-9]{1,14}$/;
|
|
27
|
+
/**
|
|
28
|
+
* Checks the telUrl of a new Number. With requireE164 (REQUIRE_E164_NUMBERS)
|
|
29
|
+
* it must be tel:+ followed by an E.164 number; without it, it only has to
|
|
30
|
+
* start with tel:. A telUrl can't be updated, so only a create checks it.
|
|
31
|
+
*
|
|
32
|
+
* @param {ValidateTelUrlInput} params - the telUrl and whether it must be E.164
|
|
33
|
+
* @throws {ValidationError} when params has the wrong shape
|
|
34
|
+
* @throws {BadRequestError} (INVALID_ARGUMENT) when the telUrl breaks the rule
|
|
35
|
+
*/
|
|
36
|
+
function validateTelUrl(params) {
|
|
37
|
+
const parsed = tel_url_schema_1.validateTelUrlSchema.safeParse(params);
|
|
38
|
+
if (!parsed.success)
|
|
39
|
+
throw new validation_error_1.ValidationError(parsed.error);
|
|
40
|
+
const { telUrl, requireE164 } = parsed.data;
|
|
41
|
+
if (!requireE164) {
|
|
42
|
+
if (!telUrl.startsWith("tel:")) {
|
|
43
|
+
throw new errors_1.BadRequestError("the telUrl must start with `tel:`");
|
|
44
|
+
}
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (!E164_TEL_URL.test(telUrl)) {
|
|
48
|
+
throw new errors_1.BadRequestError(`telUrl "${telUrl}" is not E.164: use tel:+ followed by 2 to 15 digits, the first not 0; or set REQUIRE_E164_NUMBERS=false`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Checks the number format settings of a
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Checks the number format settings of a Trunk as it will be stored: a prefix
|
|
3
|
+
* holds 1 to 20 digits, * and #, and goes only with the format
|
|
4
|
+
* e164-without-plus, national or international. An empty prefix is no prefix.
|
|
5
|
+
* The API Server, simpledata and rctl all call this, so the rules and the
|
|
6
|
+
* messages are the same everywhere.
|
|
5
7
|
*
|
|
6
8
|
* @param {TrunkNumberFormatInput} params - the Trunk's calledNumberFormat,
|
|
7
9
|
* calledNumberPrefix, callerNumberFormat and callerNumberPrefix
|
|
@@ -20,14 +20,33 @@ exports.validateTrunkNumberFormat = validateTrunkNumberFormat;
|
|
|
20
20
|
* limitations under the License.
|
|
21
21
|
*/
|
|
22
22
|
const errors_1 = require("../errors");
|
|
23
|
+
const types_1 = require("../types");
|
|
23
24
|
const validation_error_1 = require("../validation_error");
|
|
24
25
|
const trunk_number_format_schema_1 = require("./trunk_number_format_schema");
|
|
25
26
|
// What a carrier's tech prefix is made of
|
|
26
|
-
const PREFIX = /^[0-9
|
|
27
|
+
const PREFIX = /^[0-9*#]{1,20}$/;
|
|
28
|
+
// The formats a prefix goes in front of: E164 starts with + and takes none
|
|
29
|
+
const FORMATS_WITH_PREFIX = [
|
|
30
|
+
types_1.NumberFormat.E164_WITHOUT_PLUS,
|
|
31
|
+
types_1.NumberFormat.NATIONAL,
|
|
32
|
+
types_1.NumberFormat.INTERNATIONAL
|
|
33
|
+
];
|
|
34
|
+
const checkPrefix = (name, formatName, prefix, format) => {
|
|
35
|
+
if (!prefix)
|
|
36
|
+
return;
|
|
37
|
+
if (!PREFIX.test(prefix)) {
|
|
38
|
+
throw new errors_1.BadRequestError(`${name} may contain only digits, * and # (up to 20)`);
|
|
39
|
+
}
|
|
40
|
+
if (!format || !FORMATS_WITH_PREFIX.includes(format)) {
|
|
41
|
+
throw new errors_1.BadRequestError(`${name} needs ${formatName} e164-without-plus, national or international`);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
27
44
|
/**
|
|
28
|
-
* Checks the number format settings of a
|
|
29
|
-
*
|
|
30
|
-
*
|
|
45
|
+
* Checks the number format settings of a Trunk as it will be stored: a prefix
|
|
46
|
+
* holds 1 to 20 digits, * and #, and goes only with the format
|
|
47
|
+
* e164-without-plus, national or international. An empty prefix is no prefix.
|
|
48
|
+
* The API Server, simpledata and rctl all call this, so the rules and the
|
|
49
|
+
* messages are the same everywhere.
|
|
31
50
|
*
|
|
32
51
|
* @param {TrunkNumberFormatInput} params - the Trunk's calledNumberFormat,
|
|
33
52
|
* calledNumberPrefix, callerNumberFormat and callerNumberPrefix
|
|
@@ -38,10 +57,7 @@ function validateTrunkNumberFormat(params) {
|
|
|
38
57
|
const parsed = trunk_number_format_schema_1.trunkNumberFormatSchema.safeParse(params);
|
|
39
58
|
if (!parsed.success)
|
|
40
59
|
throw new validation_error_1.ValidationError(parsed.error);
|
|
41
|
-
const { calledNumberPrefix, callerNumberPrefix } = parsed.data;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
throw new errors_1.BadRequestError("prefix may contain only digits and * (up to 20)");
|
|
45
|
-
}
|
|
46
|
-
});
|
|
60
|
+
const { calledNumberFormat, calledNumberPrefix, callerNumberFormat, callerNumberPrefix } = parsed.data;
|
|
61
|
+
checkPrefix("calledNumberPrefix", "calledNumberFormat", calledNumberPrefix, calledNumberFormat);
|
|
62
|
+
checkPrefix("callerNumberPrefix", "callerNumberFormat", callerNumberPrefix, callerNumberFormat);
|
|
47
63
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import createService, { getObjectProto, GRPC_SERVING_STATUS, statusMap, LOCATION
|
|
|
2
2
|
import { HeaderModifier, MessageRequest, MessageResponse, Method, NetInterface, ObjectProto, ProcessorConfig, Route, ServiceInfo, Transport } from "./types";
|
|
3
3
|
export { createService, getObjectProto, HeaderModifier, Route, Transport, ProcessorConfig, MessageRequest, MessageResponse, NetInterface, Method, ObjectProto, ServiceInfo, PROCESSOR_OBJECT_PROTO, LOCATION_OBJECT_PROTO, GRPC_SERVING_STATUS, statusMap };
|
|
4
4
|
export { withErrorHandlingAndValidation } from "./with_error_handling_and_validation";
|
|
5
|
+
export { parseBooleanEnv } from "./parse_boolean_env";
|
|
5
6
|
export * as Auth from "./auth";
|
|
6
7
|
export * as Redis from "./redis";
|
|
7
8
|
export * as Helper from "./helper";
|
package/dist/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.Config = exports.Identity = exports.Trace = exports.Verifier = exports.ConnectSchemas = exports.CommonErrors = exports.CommonTypes = exports.CommonResponse = exports.CommonRequester = exports.CommonConnect = exports.Assertions = exports.Tracer = exports.IpUtils = exports.Helper = exports.Redis = exports.Auth = exports.withErrorHandlingAndValidation = exports.statusMap = exports.GRPC_SERVING_STATUS = exports.LOCATION_OBJECT_PROTO = exports.PROCESSOR_OBJECT_PROTO = exports.Method = exports.Transport = exports.getObjectProto = exports.createService = void 0;
|
|
36
|
+
exports.Config = exports.Identity = exports.Trace = exports.Verifier = exports.ConnectSchemas = exports.CommonErrors = exports.CommonTypes = exports.CommonResponse = exports.CommonRequester = exports.CommonConnect = exports.Assertions = exports.Tracer = exports.IpUtils = exports.Helper = exports.Redis = exports.Auth = exports.parseBooleanEnv = exports.withErrorHandlingAndValidation = exports.statusMap = exports.GRPC_SERVING_STATUS = exports.LOCATION_OBJECT_PROTO = exports.PROCESSOR_OBJECT_PROTO = exports.Method = exports.Transport = exports.getObjectProto = exports.createService = void 0;
|
|
37
37
|
/*
|
|
38
38
|
* Copyright (C) 2026 by Fonoster Inc (https://fonoster.com)
|
|
39
39
|
* http://github.com/fonoster/routr
|
|
@@ -64,6 +64,8 @@ Object.defineProperty(exports, "Method", { enumerable: true, get: function () {
|
|
|
64
64
|
Object.defineProperty(exports, "Transport", { enumerable: true, get: function () { return types_1.Transport; } });
|
|
65
65
|
var with_error_handling_and_validation_1 = require("./with_error_handling_and_validation");
|
|
66
66
|
Object.defineProperty(exports, "withErrorHandlingAndValidation", { enumerable: true, get: function () { return with_error_handling_and_validation_1.withErrorHandlingAndValidation; } });
|
|
67
|
+
var parse_boolean_env_1 = require("./parse_boolean_env");
|
|
68
|
+
Object.defineProperty(exports, "parseBooleanEnv", { enumerable: true, get: function () { return parse_boolean_env_1.parseBooleanEnv; } });
|
|
67
69
|
exports.Auth = __importStar(require("./auth"));
|
|
68
70
|
exports.Redis = __importStar(require("./redis"));
|
|
69
71
|
exports.Helper = __importStar(require("./helper"));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses an optional environment variable that must hold true or false, such
|
|
3
|
+
* as REQUIRE_E164_NUMBERS. Unset or empty is false.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} name - The variable name, used in the error message
|
|
6
|
+
* @param {string} value - The raw value
|
|
7
|
+
* @return {boolean} the parsed value
|
|
8
|
+
* @throws {Error} when the value is neither true nor false
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseBooleanEnv(name: string, value?: string): boolean;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseBooleanEnv = parseBooleanEnv;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (C) 2026 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
|
+
/**
|
|
23
|
+
* Parses an optional environment variable that must hold true or false, such
|
|
24
|
+
* as REQUIRE_E164_NUMBERS. Unset or empty is false.
|
|
25
|
+
*
|
|
26
|
+
* @param {string} name - The variable name, used in the error message
|
|
27
|
+
* @param {string} value - The raw value
|
|
28
|
+
* @return {boolean} the parsed value
|
|
29
|
+
* @throws {Error} when the value is neither true nor false
|
|
30
|
+
*/
|
|
31
|
+
function parseBooleanEnv(name, value) {
|
|
32
|
+
if (value === undefined || value === "" || value === "false")
|
|
33
|
+
return false;
|
|
34
|
+
if (value === "true")
|
|
35
|
+
return true;
|
|
36
|
+
throw new Error(`${name} must be true or false, got "${value}"`);
|
|
37
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -37,7 +37,8 @@ export declare enum NumberFormat {
|
|
|
37
37
|
UNSPECIFIED = "UNSPECIFIED",
|
|
38
38
|
E164 = "E164",
|
|
39
39
|
E164_WITHOUT_PLUS = "E164_WITHOUT_PLUS",
|
|
40
|
-
NATIONAL = "NATIONAL"
|
|
40
|
+
NATIONAL = "NATIONAL",
|
|
41
|
+
INTERNATIONAL = "INTERNATIONAL"
|
|
41
42
|
}
|
|
42
43
|
export interface NumberFormatSetting {
|
|
43
44
|
format: NumberFormat;
|
|
@@ -49,6 +50,7 @@ export declare enum ExtraHeader {
|
|
|
49
50
|
EDGEPORT_REF = "X-Edgeport-Ref",
|
|
50
51
|
SESSION_COUNT = "X-Session-Count",
|
|
51
52
|
DOD_NUMBER = "X-DOD-Number",
|
|
53
|
+
DID_NUMBER = "X-DID-Number",
|
|
52
54
|
DOD_PRIVACY = "X-DOD-Privacy",
|
|
53
55
|
CONNECT_TOKEN = "X-Connect-Token",
|
|
54
56
|
CALL_DIRECTION = "X-Call-Direction",
|
package/dist/types.js
CHANGED
|
@@ -44,8 +44,11 @@ var NumberFormat;
|
|
|
44
44
|
NumberFormat["E164"] = "E164";
|
|
45
45
|
// 442079460018
|
|
46
46
|
NumberFormat["E164_WITHOUT_PLUS"] = "E164_WITHOUT_PLUS";
|
|
47
|
-
// 02079460018
|
|
47
|
+
// 02079460018; a number of another country in international form
|
|
48
48
|
NumberFormat["NATIONAL"] = "NATIONAL";
|
|
49
|
+
// 00442079460018: the international prefix of the Number's country, the
|
|
50
|
+
// country code and the national number
|
|
51
|
+
NumberFormat["INTERNATIONAL"] = "INTERNATIONAL";
|
|
49
52
|
})(NumberFormat || (exports.NumberFormat = NumberFormat = {}));
|
|
50
53
|
var ExtraHeader;
|
|
51
54
|
(function (ExtraHeader) {
|
|
@@ -54,6 +57,7 @@ var ExtraHeader;
|
|
|
54
57
|
ExtraHeader["EDGEPORT_REF"] = "X-Edgeport-Ref";
|
|
55
58
|
ExtraHeader["SESSION_COUNT"] = "X-Session-Count";
|
|
56
59
|
ExtraHeader["DOD_NUMBER"] = "X-DOD-Number";
|
|
60
|
+
ExtraHeader["DID_NUMBER"] = "X-DID-Number";
|
|
57
61
|
ExtraHeader["DOD_PRIVACY"] = "X-DOD-Privacy";
|
|
58
62
|
ExtraHeader["CONNECT_TOKEN"] = "X-Connect-Token";
|
|
59
63
|
ExtraHeader["CALL_DIRECTION"] = "X-Call-Direction";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@routr/common",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.34.0",
|
|
4
4
|
"description": "Common package",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/routr#readme",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"grpc-health-check": "^2.1.0",
|
|
37
37
|
"ip-utils": "^2.4.0",
|
|
38
38
|
"js-yaml": "^4.1.1",
|
|
39
|
+
"libphonenumber-js": "1.11.20",
|
|
39
40
|
"pb-util": "^1.0.3",
|
|
40
41
|
"phone": "^3.1.68",
|
|
41
42
|
"validator": "^13.15.26",
|
|
@@ -61,5 +62,5 @@
|
|
|
61
62
|
"devDependencies": {
|
|
62
63
|
"@types/js-yaml": "^4.0.5"
|
|
63
64
|
},
|
|
64
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "7d2faf42bc43b7f3f1ac7d77097ffbca1b7cf4d2"
|
|
65
66
|
}
|