@routr/connect 2.17.0 → 2.18.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/envs.d.ts +1 -0
- package/dist/envs.js +21 -1
- package/dist/handlers/register.js +3 -2
- package/dist/service.js +4 -0
- package/package.json +4 -4
package/dist/envs.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare const API_ADDR: string;
|
|
|
4
4
|
export declare const CONNECT_VERIFIER_ADDR: string;
|
|
5
5
|
export declare const CONNECT_VERIFIER_PUBLIC_KEY_PATH: string;
|
|
6
6
|
export declare const CONNECT_VERIFIER_OPTIONS: any;
|
|
7
|
+
export declare const REGISTER_DEFAULT_EXPIRES: number;
|
|
7
8
|
export declare const DEFAULT_UNTRUSTED_HEADERS_TO_STRIP: string[];
|
|
8
9
|
export declare const UNTRUSTED_HEADERS_TO_STRIP: string[];
|
|
9
10
|
export declare const TRUSTED_EDGEPORTS: string[];
|
package/dist/envs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.TRUSTED_EDGEPORT_ADDRESSES = exports.TRUSTED_EDGEPORTS = exports.UNTRUSTED_HEADERS_TO_STRIP = exports.DEFAULT_UNTRUSTED_HEADERS_TO_STRIP = exports.CONNECT_VERIFIER_OPTIONS = exports.CONNECT_VERIFIER_PUBLIC_KEY_PATH = exports.CONNECT_VERIFIER_ADDR = exports.API_ADDR = exports.LOCATION_ADDR = exports.BIND_ADDR = void 0;
|
|
4
|
+
exports.TRUSTED_EDGEPORT_ADDRESSES = exports.TRUSTED_EDGEPORTS = exports.UNTRUSTED_HEADERS_TO_STRIP = exports.DEFAULT_UNTRUSTED_HEADERS_TO_STRIP = exports.REGISTER_DEFAULT_EXPIRES = exports.CONNECT_VERIFIER_OPTIONS = exports.CONNECT_VERIFIER_PUBLIC_KEY_PATH = exports.CONNECT_VERIFIER_ADDR = exports.API_ADDR = exports.LOCATION_ADDR = exports.BIND_ADDR = void 0;
|
|
5
5
|
/*
|
|
6
6
|
* Copyright (C) 2026 by Fonoster Inc (https://fonoster.com)
|
|
7
7
|
* http://github.com/fonoster/routr
|
|
@@ -22,6 +22,22 @@ exports.TRUSTED_EDGEPORT_ADDRESSES = exports.TRUSTED_EDGEPORTS = exports.UNTRUST
|
|
|
22
22
|
*/
|
|
23
23
|
const assertions_1 = require("./assertions");
|
|
24
24
|
(0, assertions_1.assertOnlyOneEnvIsSet)(["CONNECT_VERIFIER_ADDR", "CONNECT_VERIFIER_PUBLIC_KEY"]);
|
|
25
|
+
/**
|
|
26
|
+
* Parses an optional environment variable that must hold a positive integer.
|
|
27
|
+
*
|
|
28
|
+
* @param {string} name - The variable name, used in the error message
|
|
29
|
+
* @param {string} value - The raw value
|
|
30
|
+
* @return {number | undefined} the parsed value, or undefined when unset
|
|
31
|
+
*/
|
|
32
|
+
function parsePositiveInt(name, value) {
|
|
33
|
+
if (value === undefined || value.trim() === "")
|
|
34
|
+
return undefined;
|
|
35
|
+
const parsed = Number(value);
|
|
36
|
+
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
37
|
+
throw new Error(`${name} must be a positive integer, got "${value}"`);
|
|
38
|
+
}
|
|
39
|
+
return parsed;
|
|
40
|
+
}
|
|
25
41
|
exports.BIND_ADDR = (_a = process.env.BIND_ADDR) !== null && _a !== void 0 ? _a : "0.0.0.0:51904";
|
|
26
42
|
exports.LOCATION_ADDR = process.env.LOCATION_ADDR;
|
|
27
43
|
exports.API_ADDR = process.env.API_ADDR;
|
|
@@ -30,6 +46,10 @@ exports.CONNECT_VERIFIER_PUBLIC_KEY_PATH = process.env.CONNECT_VERIFIER_PUBLIC_K
|
|
|
30
46
|
exports.CONNECT_VERIFIER_OPTIONS = process.env.CONNECT_VERIFIER_OPTIONS
|
|
31
47
|
? JSON.parse(process.env.CONNECT_VERIFIER_OPTIONS)
|
|
32
48
|
: { expiresIn: "1h", algorithm: ["RS256"] };
|
|
49
|
+
// Expiry, in seconds, granted to a REGISTER that carries neither a Contact
|
|
50
|
+
// expires parameter nor an Expires header (RFC 3261 section 10.3, step 7).
|
|
51
|
+
// Unset leaves the processor's default in place.
|
|
52
|
+
exports.REGISTER_DEFAULT_EXPIRES = parsePositiveInt("REGISTER_DEFAULT_EXPIRES", process.env.REGISTER_DEFAULT_EXPIRES);
|
|
33
53
|
// Platform headers a caller must never be able to set. They are removed from
|
|
34
54
|
// requests that come from untrusted sources (e.g., the PSTN or a client using a
|
|
35
55
|
// Connect Token) before Routr adds its own. Override with a comma-separated list;
|
|
@@ -66,6 +66,7 @@ const location_1 = require("@routr/location");
|
|
|
66
66
|
const processor_1 = require("@routr/processor");
|
|
67
67
|
const common_1 = require("@routr/common");
|
|
68
68
|
const utils_1 = require("../utils");
|
|
69
|
+
const envs_1 = require("../envs");
|
|
69
70
|
const logger_1 = require("@fonoster/logger");
|
|
70
71
|
const logger = (0, logger_1.getLogger)({ service: "connect", filePath: __filename });
|
|
71
72
|
const jwtVerifier = (0, utils_1.getVerifierImpl)();
|
|
@@ -93,7 +94,7 @@ const handleRegister = (apiClient, location) => {
|
|
|
93
94
|
try {
|
|
94
95
|
yield location.addRoute({
|
|
95
96
|
aor: "aor" in peerOrAgent ? peerOrAgent.aor : processor_1.Target.getTargetAOR(request),
|
|
96
|
-
route: location_1.Helper.createRoute(request),
|
|
97
|
+
route: location_1.Helper.createRoute(request, envs_1.REGISTER_DEFAULT_EXPIRES),
|
|
97
98
|
maxContacts: peerOrAgent.maxContacts
|
|
98
99
|
});
|
|
99
100
|
res.sendRegisterOk(request);
|
|
@@ -118,7 +119,7 @@ const handleRegister = (apiClient, location) => {
|
|
|
118
119
|
}
|
|
119
120
|
yield location.addRoute({
|
|
120
121
|
aor: payload.aor,
|
|
121
|
-
route: location_1.Helper.createRoute(request),
|
|
122
|
+
route: location_1.Helper.createRoute(request, envs_1.REGISTER_DEFAULT_EXPIRES),
|
|
122
123
|
maxContacts: (_a = payload.maxContacts) !== null && _a !== void 0 ? _a : -1
|
|
123
124
|
});
|
|
124
125
|
res.sendRegisterOk(request);
|
package/dist/service.js
CHANGED
|
@@ -101,11 +101,15 @@ const createDispatcher = (deps) => (req, res) => __awaiter(void 0, void 0, void
|
|
|
101
101
|
(0, utils_1.isInDialog)(req)) {
|
|
102
102
|
return forwardInDialog(req, res);
|
|
103
103
|
}
|
|
104
|
+
// Out-of-dialog REFER (RFC 3515 allows it) would be routed as a new call below;
|
|
105
|
+
// it is refused so transfer only happens on a dialog this proxy already
|
|
106
|
+
// authorized. SIP Connect 1.1 section 12.1 keeps REFER out of scope anyway.
|
|
104
107
|
switch (req.method) {
|
|
105
108
|
case common_1.Method.PUBLISH:
|
|
106
109
|
case common_1.Method.NOTIFY:
|
|
107
110
|
case common_1.Method.SUBSCRIBE:
|
|
108
111
|
case common_1.Method.MESSAGE:
|
|
112
|
+
case common_1.Method.REFER:
|
|
109
113
|
res.sendMethodNotAllowed();
|
|
110
114
|
break;
|
|
111
115
|
case common_1.Method.REGISTER:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@routr/connect",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.18.0",
|
|
4
4
|
"description": "Default processor",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/routr#readme",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@fonoster/logger": "0.6.0",
|
|
23
23
|
"@routr/common": "^2.17.0",
|
|
24
|
-
"@routr/location": "^2.
|
|
25
|
-
"@routr/processor": "^2.
|
|
24
|
+
"@routr/location": "^2.18.0",
|
|
25
|
+
"@routr/processor": "^2.18.0",
|
|
26
26
|
"jsonwebtoken": "^9.0.3"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"bugs": {
|
|
42
42
|
"url": "https://github.com/fonoster/routr/issues"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "53d48803760e0d8d6af1efa63db2414594d79454"
|
|
45
45
|
}
|