@routr/connect 2.0.8-alpha.37 → 2.0.8-alpha.39
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/assertions.d.ts +1 -0
- package/dist/assertions.js +31 -0
- package/dist/envs.d.ts +3 -0
- package/dist/envs.js +8 -3
- package/dist/handlers.js +26 -2
- package/dist/router.js +58 -6
- package/dist/runner.js +2 -0
- package/dist/tailor.js +1 -2
- package/dist/types.d.ts +1 -0
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +13 -1
- package/dist/utils.js +51 -3
- package/package.json +9 -5
@@ -0,0 +1 @@
|
|
1
|
+
export declare const assertOnlyOneEnvIsSet: (envs: string[]) => void;
|
@@ -0,0 +1,31 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.assertOnlyOneEnvIsSet = void 0;
|
4
|
+
/*
|
5
|
+
* Copyright (C) 2023 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 logger_1 = require("@fonoster/logger");
|
23
|
+
const logger = (0, logger_1.getLogger)({ service: "common", filePath: __filename });
|
24
|
+
const assertOnlyOneEnvIsSet = (envs) => {
|
25
|
+
const envsSet = envs.filter((env) => process.env[env] != null);
|
26
|
+
if (envsSet.length > 1) {
|
27
|
+
logger.error(`only one of the following environment variables can be set: ${envs.join(", ")}.`);
|
28
|
+
process.exit(1);
|
29
|
+
}
|
30
|
+
};
|
31
|
+
exports.assertOnlyOneEnvIsSet = assertOnlyOneEnvIsSet;
|
package/dist/envs.d.ts
CHANGED
@@ -1,3 +1,6 @@
|
|
1
1
|
export declare const BIND_ADDR: string;
|
2
2
|
export declare const LOCATION_ADDR: string;
|
3
3
|
export declare const API_ADDR: string;
|
4
|
+
export declare const CONNECT_VERIFIER_ADDR: string;
|
5
|
+
export declare const CONNECT_VERIFIER_PUBLIC_KEY_PATH: string;
|
6
|
+
export declare const CONNECT_VERIFIER_OPTIONS: any;
|
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.API_ADDR = exports.LOCATION_ADDR = exports.BIND_ADDR = void 0;
|
4
|
+
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) 2023 by Fonoster Inc (https://fonoster.com)
|
7
7
|
* http://github.com/fonoster
|
@@ -20,8 +20,13 @@ exports.API_ADDR = exports.LOCATION_ADDR = exports.BIND_ADDR = void 0;
|
|
20
20
|
* See the License for the specific language governing permissions and
|
21
21
|
* limitations under the License.
|
22
22
|
*/
|
23
|
-
const
|
24
|
-
|
23
|
+
const assertions_1 = require("./assertions");
|
24
|
+
(0, assertions_1.assertOnlyOneEnvIsSet)(["CONNECT_VERIFIER_ADDR", "CONNECT_VERIFIER_PUBLIC_KEY"]);
|
25
25
|
exports.BIND_ADDR = (_a = process.env.BIND_ADDR) !== null && _a !== void 0 ? _a : "0.0.0.0:51904";
|
26
26
|
exports.LOCATION_ADDR = process.env.LOCATION_ADDR;
|
27
27
|
exports.API_ADDR = process.env.API_ADDR;
|
28
|
+
exports.CONNECT_VERIFIER_ADDR = process.env.CONNECT_VERIFIER_ADDR;
|
29
|
+
exports.CONNECT_VERIFIER_PUBLIC_KEY_PATH = process.env.CONNECT_VERIFIER_PUBLIC_KEY_PATH;
|
30
|
+
exports.CONNECT_VERIFIER_OPTIONS = process.env.CONNECT_VERIFIER_OPTIONS
|
31
|
+
? JSON.parse(process.env.CONNECT_VERIFIER_OPTIONS)
|
32
|
+
: { expiresIn: "1h", algorithm: ["RS256"] };
|
package/dist/handlers.js
CHANGED
@@ -35,7 +35,10 @@ const function_1 = require("fp-ts/function");
|
|
35
35
|
const router_1 = require("./router");
|
36
36
|
const common_1 = require("@routr/common");
|
37
37
|
const utils_1 = require("./utils");
|
38
|
+
const logger_1 = require("@fonoster/logger");
|
39
|
+
const logger = (0, logger_1.getLogger)({ service: "connect", filePath: __filename });
|
38
40
|
const enforceE164 = processor_1.Alterations.enforceE164(common_1.Environment.ENFORCE_E164, common_1.Environment.ENFORCE_E164_WITH_MOBILE_PREFIX);
|
41
|
+
const jwtVerifier = (0, utils_1.getVerifierImpl)();
|
39
42
|
const handleRegister = (apiClient, location) => {
|
40
43
|
return (request, res) => __awaiter(void 0, void 0, void 0, function* () {
|
41
44
|
// Calculate and return challenge
|
@@ -63,8 +66,27 @@ const handleRegister = (apiClient, location) => {
|
|
63
66
|
});
|
64
67
|
res.sendOk();
|
65
68
|
}
|
69
|
+
else if ((0, utils_1.hasXConnectObjectHeader)(request)) {
|
70
|
+
const connectToken = processor_1.Extensions.getHeaderValue(request, common_1.CommonTypes.ExtraHeader.CONNECT_TOKEN);
|
71
|
+
try {
|
72
|
+
const payload = yield jwtVerifier.verify(connectToken);
|
73
|
+
if (!payload.allowedMethods.includes(common_1.Method.REGISTER)) {
|
74
|
+
return res.send(common_1.Auth.createForbideenResponse());
|
75
|
+
}
|
76
|
+
yield location.addRoute({
|
77
|
+
aor: payload.aor,
|
78
|
+
route: location_1.Helper.createRoute(request)
|
79
|
+
});
|
80
|
+
}
|
81
|
+
catch (e) {
|
82
|
+
logger.verbose("unable to validate connect token", {
|
83
|
+
originalError: e.message
|
84
|
+
});
|
85
|
+
res.send(common_1.Auth.createForbideenResponse());
|
86
|
+
}
|
87
|
+
}
|
66
88
|
else {
|
67
|
-
|
89
|
+
res.send(common_1.Auth.createUnauthorizedResponse(request.message.requestUri.host));
|
68
90
|
}
|
69
91
|
});
|
70
92
|
};
|
@@ -99,7 +121,9 @@ const handleRequest = (location, apiClient) => (request, res) => __awaiter(void
|
|
99
121
|
}
|
100
122
|
}
|
101
123
|
catch (err) {
|
102
|
-
res.
|
124
|
+
res.sendInternalServerError();
|
125
|
+
logger.error(err);
|
126
|
+
// res.sendError(err)
|
103
127
|
}
|
104
128
|
});
|
105
129
|
exports.handleRequest = handleRequest;
|
package/dist/router.js
CHANGED
@@ -32,18 +32,53 @@ const types_1 = require("./types");
|
|
32
32
|
const common_1 = require("@routr/common");
|
33
33
|
const utils_1 = require("./utils");
|
34
34
|
const processor_1 = require("@routr/processor");
|
35
|
-
const location_1 = require("@routr/location");
|
36
35
|
const errors_1 = require("./errors");
|
37
36
|
const logger_1 = require("@fonoster/logger");
|
38
37
|
const access_1 = require("./access");
|
39
38
|
const logger = (0, logger_1.getLogger)({ service: "connect", filePath: __filename });
|
39
|
+
const jwtVerifier = (0, utils_1.getVerifierImpl)();
|
40
40
|
// eslint-disable-next-line require-jsdoc
|
41
41
|
function router(location, apiClient) {
|
42
42
|
return (request) => __awaiter(this, void 0, void 0, function* () {
|
43
|
+
var _a;
|
43
44
|
const fromURI = request.message.from.address.uri;
|
44
45
|
const requestURI = request.message.requestUri;
|
45
|
-
|
46
|
-
|
46
|
+
let caller;
|
47
|
+
let callee;
|
48
|
+
if ((0, utils_1.hasXConnectObjectHeader)(request)) {
|
49
|
+
const connectToken = processor_1.Extensions.getHeaderValue(request, common_1.CommonTypes.ExtraHeader.CONNECT_TOKEN);
|
50
|
+
try {
|
51
|
+
const payload = yield jwtVerifier.verify(connectToken);
|
52
|
+
const domain = yield (0, utils_1.findDomain)(apiClient, payload.domain);
|
53
|
+
if (!payload.allowedMethods.includes(common_1.Method.INVITE)) {
|
54
|
+
return common_1.Auth.createForbideenResponse();
|
55
|
+
}
|
56
|
+
caller = {
|
57
|
+
apiVersion: common_1.CommonConnect.APIVersion.V2,
|
58
|
+
ref: payload.ref,
|
59
|
+
name: (_a = request.message.from.address.displayName) !== null && _a !== void 0 ? _a : common_1.CommonTypes.ANONYMOUS,
|
60
|
+
domain: domain,
|
61
|
+
domainRef: payload.domainRef,
|
62
|
+
username: common_1.CommonTypes.ANONYMOUS,
|
63
|
+
privacy: processor_1.Extensions.getHeaderValue(request, "Privacy"),
|
64
|
+
enabled: true
|
65
|
+
};
|
66
|
+
callee = (yield apiClient.peers.findBy({
|
67
|
+
fieldName: "aor",
|
68
|
+
fieldValue: payload.aorLink
|
69
|
+
})).items[0];
|
70
|
+
}
|
71
|
+
catch (e) {
|
72
|
+
logger.verbose("unable to validate connect token", {
|
73
|
+
originalError: e.message
|
74
|
+
});
|
75
|
+
return common_1.Auth.createForbideenResponse();
|
76
|
+
}
|
77
|
+
}
|
78
|
+
else {
|
79
|
+
caller = yield (0, utils_1.findResource)(apiClient, fromURI.host, fromURI.user);
|
80
|
+
callee = yield (0, utils_1.findResource)(apiClient, requestURI.host, requestURI.user);
|
81
|
+
}
|
47
82
|
const routingDirection = (0, utils_1.getRoutingDirection)(caller, callee);
|
48
83
|
logger.verbose("routing request from: " +
|
49
84
|
(0, utils_1.getSIPURI)(fromURI) +
|
@@ -52,9 +87,9 @@ function router(location, apiClient) {
|
|
52
87
|
fromURI: (0, utils_1.getSIPURI)(fromURI),
|
53
88
|
requestURI: (0, utils_1.getSIPURI)(requestURI),
|
54
89
|
routingDirection
|
55
|
-
// sessionAffinityHeader: callee?.spec.location?.sessionAffinityHeader
|
56
90
|
});
|
57
|
-
if (
|
91
|
+
if (!(0, utils_1.hasXConnectObjectHeader)(request) &&
|
92
|
+
request.method === common_1.CommonTypes.Method.INVITE) {
|
58
93
|
const failedCheck = yield (0, access_1.checkAccess)({
|
59
94
|
apiClient,
|
60
95
|
request,
|
@@ -69,6 +104,8 @@ function router(location, apiClient) {
|
|
69
104
|
switch (routingDirection) {
|
70
105
|
case types_1.RoutingDirection.AGENT_TO_AGENT:
|
71
106
|
return agentToAgent(location, request);
|
107
|
+
case types_1.RoutingDirection.AGENT_TO_PEER:
|
108
|
+
return yield agentToPeer(location, callee, request);
|
72
109
|
case types_1.RoutingDirection.AGENT_TO_PSTN:
|
73
110
|
return yield agentToPSTN(request, caller, requestURI.user);
|
74
111
|
case types_1.RoutingDirection.FROM_PSTN:
|
@@ -119,7 +156,7 @@ function fromPSTN(apiClient, location, callee, req) {
|
|
119
156
|
backend
|
120
157
|
}))[0];
|
121
158
|
if (!route) {
|
122
|
-
|
159
|
+
return null;
|
123
160
|
}
|
124
161
|
if (!route.headers)
|
125
162
|
route.headers = [];
|
@@ -183,6 +220,21 @@ function agentToPSTN(req, agent, calleeNumber) {
|
|
183
220
|
});
|
184
221
|
}
|
185
222
|
// eslint-disable-next-line require-jsdoc
|
223
|
+
function agentToPeer(location, callee, req) {
|
224
|
+
return __awaiter(this, void 0, void 0, function* () {
|
225
|
+
const backend = {
|
226
|
+
ref: callee.ref,
|
227
|
+
balancingAlgorithm: callee.balancingAlgorithm,
|
228
|
+
withSessionAffinity: callee.withSessionAffinity
|
229
|
+
};
|
230
|
+
return (yield location.findRoutes({
|
231
|
+
aor: callee.aor,
|
232
|
+
callId: req.ref,
|
233
|
+
backend
|
234
|
+
}))[0];
|
235
|
+
});
|
236
|
+
}
|
237
|
+
// eslint-disable-next-line require-jsdoc
|
186
238
|
function peerToPSTN(apiClient, req) {
|
187
239
|
return __awaiter(this, void 0, void 0, function* () {
|
188
240
|
const numberTel = processor_1.Extensions.getHeaderValue(req, common_1.CommonTypes.ExtraHeader.DOD_NUMBER);
|
package/dist/runner.js
CHANGED
@@ -25,7 +25,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
26
26
|
require("./tracer").init("dispatcher");
|
27
27
|
const service_1 = __importDefault(require("./service"));
|
28
|
+
const common_1 = require("@routr/common");
|
28
29
|
const envs_1 = require("./envs");
|
30
|
+
common_1.Assertions.assertEnvsAreSet(["LOCATION_ADDR", "API_ADDR"]);
|
29
31
|
(0, service_1.default)({
|
30
32
|
bindAddr: envs_1.BIND_ADDR,
|
31
33
|
locationAddr: envs_1.LOCATION_ADDR,
|
package/dist/tailor.js
CHANGED
@@ -22,6 +22,5 @@ exports.tailor = void 0;
|
|
22
22
|
const processor_1 = require("@routr/processor");
|
23
23
|
const function_1 = require("fp-ts/function");
|
24
24
|
// Q: Should we add support for strict routing?
|
25
|
-
|
26
|
-
const tailor = (route, req) => (0, function_1.pipe)(req, processor_1.Alterations.decreaseMaxForwards, processor_1.Alterations.removeAuthorization, processor_1.Alterations.removeSelfRoutes, processor_1.Alterations.removeXEdgePortRef, processor_1.Alterations.fixNatedContact, processor_1.Alterations.addSelfVia(route), processor_1.Alterations.applyXHeaders(route), processor_1.Alterations.addSelfRecordRoute(route), processor_1.Alterations.addRouteToNextHop(route));
|
25
|
+
const tailor = (route, req) => (0, function_1.pipe)(req, processor_1.Alterations.decreaseMaxForwards, processor_1.Alterations.removeAuthorization, processor_1.Alterations.removeSelfRoutes, processor_1.Alterations.removeXEdgePortRef, processor_1.Alterations.fixInvalidContact, processor_1.Alterations.addSelfVia(route), processor_1.Alterations.applyXHeaders(route), processor_1.Alterations.addSelfRecordRoute(route), processor_1.Alterations.addRouteToNextHop(route));
|
27
26
|
exports.tailor = tailor;
|
package/dist/types.d.ts
CHANGED
package/dist/types.js
CHANGED
@@ -6,6 +6,7 @@ var RoutingDirection;
|
|
6
6
|
RoutingDirection["FROM_PSTN"] = "from-pstn";
|
7
7
|
RoutingDirection["AGENT_TO_AGENT"] = "agent-to-agent";
|
8
8
|
RoutingDirection["AGENT_TO_PSTN"] = "agent-to-pstn";
|
9
|
+
RoutingDirection["AGENT_TO_PEER"] = "agent-to-peer";
|
9
10
|
// WARNING: This is not supported yet
|
10
11
|
RoutingDirection["PEER_TO_AGENT"] = "peer-to-agent";
|
11
12
|
RoutingDirection["PEER_TO_PSTN"] = "peer-to-pstn";
|
package/dist/utils.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { HeaderModifier, MessageRequest, Transport, CommonConnect as CC } from "@routr/common";
|
1
|
+
import { HeaderModifier, MessageRequest, Transport, CommonConnect as CC, Method } from "@routr/common";
|
2
2
|
import { RoutingDirection } from "./types";
|
3
3
|
export declare const isKind: (res: CC.RoutableResourceUnion, kind: CC.Kind) => boolean;
|
4
4
|
export declare const findDomain: (apiClient: CC.APIClient, domainUri: string) => Promise<CC.Domain>;
|
@@ -18,3 +18,15 @@ export declare const getSIPURI: (uri: {
|
|
18
18
|
user?: string;
|
19
19
|
host: string;
|
20
20
|
}) => string;
|
21
|
+
export declare const hasXConnectObjectHeader: (req: MessageRequest) => string;
|
22
|
+
export declare const getVerifierImpl: () => {
|
23
|
+
verify: (token: string) => Promise<{
|
24
|
+
ref: string;
|
25
|
+
domain: string;
|
26
|
+
domainRef: string;
|
27
|
+
aor: string;
|
28
|
+
aorLink: string;
|
29
|
+
username: string;
|
30
|
+
allowedMethods: Method[];
|
31
|
+
}>;
|
32
|
+
};
|
package/dist/utils.js
CHANGED
@@ -1,4 +1,27 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
@@ -8,8 +31,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
32
|
});
|
10
33
|
};
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
36
|
+
};
|
11
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
exports.getSIPURI = exports.getTrunkURI = exports.createTrunkAuthentication = exports.createRemotePartyId = exports.createPAssertedIdentity = exports.getRoutingDirection = exports.findResource = exports.findNumberByTelUrl = exports.findDomain = exports.isKind = void 0;
|
38
|
+
exports.getVerifierImpl = exports.hasXConnectObjectHeader = exports.getSIPURI = exports.getTrunkURI = exports.createTrunkAuthentication = exports.createRemotePartyId = exports.createPAssertedIdentity = exports.getRoutingDirection = exports.findResource = exports.findNumberByTelUrl = exports.findDomain = exports.isKind = void 0;
|
13
39
|
/*
|
14
40
|
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
15
41
|
* http://github.com/fonoster/routr
|
@@ -28,8 +54,12 @@ exports.getSIPURI = exports.getTrunkURI = exports.createTrunkAuthentication = ex
|
|
28
54
|
* See the License for the specific language governing permissions and
|
29
55
|
* limitations under the License.
|
30
56
|
*/
|
57
|
+
const jwt = __importStar(require("jsonwebtoken"));
|
58
|
+
const fs_1 = __importDefault(require("fs"));
|
31
59
|
const common_1 = require("@routr/common");
|
60
|
+
const processor_1 = require("@routr/processor");
|
32
61
|
const types_1 = require("./types");
|
62
|
+
const envs_1 = require("./envs");
|
33
63
|
// OMG, this is so ugly and hacky
|
34
64
|
const isKind = (res, kind) => {
|
35
65
|
if (res == null && kind === common_1.CommonConnect.Kind.UNKNOWN) {
|
@@ -38,13 +68,13 @@ const isKind = (res, kind) => {
|
|
38
68
|
else if (res == null) {
|
39
69
|
return false;
|
40
70
|
}
|
41
|
-
else if ("
|
71
|
+
else if ("domainRef" in res && kind === common_1.CommonConnect.Kind.AGENT) {
|
42
72
|
return true;
|
43
73
|
}
|
44
74
|
else if ("telUrl" in res && kind === common_1.CommonConnect.Kind.NUMBER) {
|
45
75
|
return true;
|
46
76
|
}
|
47
|
-
else if ("
|
77
|
+
else if ("aor" in res && kind === common_1.CommonConnect.Kind.PEER) {
|
48
78
|
return true;
|
49
79
|
}
|
50
80
|
};
|
@@ -97,6 +127,9 @@ const getRoutingDirection = (caller, callee) => {
|
|
97
127
|
if ((0, exports.isKind)(caller, common_1.CommonConnect.Kind.PEER) && (0, exports.isKind)(callee, common_1.CommonConnect.Kind.AGENT)) {
|
98
128
|
return types_1.RoutingDirection.PEER_TO_AGENT;
|
99
129
|
}
|
130
|
+
if ((0, exports.isKind)(caller, common_1.CommonConnect.Kind.AGENT) && (0, exports.isKind)(callee, common_1.CommonConnect.Kind.PEER)) {
|
131
|
+
return types_1.RoutingDirection.AGENT_TO_PEER;
|
132
|
+
}
|
100
133
|
// All we know is that the Number is managed by this instance of Routr
|
101
134
|
if ((0, exports.isKind)(callee, common_1.CommonConnect.Kind.NUMBER)) {
|
102
135
|
return types_1.RoutingDirection.FROM_PSTN;
|
@@ -154,3 +187,18 @@ const getTrunkURI = (trunk) => {
|
|
154
187
|
exports.getTrunkURI = getTrunkURI;
|
155
188
|
const getSIPURI = (uri) => uri.user ? `sip:${uri.user}@${uri.host}` : `sip:${uri.host}`;
|
156
189
|
exports.getSIPURI = getSIPURI;
|
190
|
+
const hasXConnectObjectHeader = (req) => processor_1.Extensions.getHeaderValue(req, common_1.CommonTypes.ExtraHeader.CONNECT_TOKEN);
|
191
|
+
exports.hasXConnectObjectHeader = hasXConnectObjectHeader;
|
192
|
+
// TODO: Add support for GRPCVerifier
|
193
|
+
const getVerifierImpl = () => {
|
194
|
+
if (envs_1.CONNECT_VERIFIER_PUBLIC_KEY_PATH) {
|
195
|
+
const publicKey = fs_1.default.readFileSync(envs_1.CONNECT_VERIFIER_PUBLIC_KEY_PATH, "utf8");
|
196
|
+
return {
|
197
|
+
verify: (token) => __awaiter(void 0, void 0, void 0, function* () {
|
198
|
+
return jwt.verify(token, publicKey, envs_1.CONNECT_VERIFIER_OPTIONS);
|
199
|
+
})
|
200
|
+
};
|
201
|
+
}
|
202
|
+
return null;
|
203
|
+
};
|
204
|
+
exports.getVerifierImpl = getVerifierImpl;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@routr/connect",
|
3
|
-
"version": "2.0.8-alpha.
|
3
|
+
"version": "2.0.8-alpha.39",
|
4
4
|
"description": "Default processor",
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
6
6
|
"homepage": "https://github.com/fonoster/routr#readme",
|
@@ -29,9 +29,13 @@
|
|
29
29
|
"@opentelemetry/sdk-trace-base": "^1.0.4",
|
30
30
|
"@opentelemetry/sdk-trace-node": "^1.0.4",
|
31
31
|
"@opentelemetry/semantic-conventions": "^1.0.4",
|
32
|
-
"@routr/common": "^2.0.8-alpha.
|
33
|
-
"@routr/location": "^2.0.8-alpha.
|
34
|
-
"@routr/processor": "^2.0.8-alpha.
|
32
|
+
"@routr/common": "^2.0.8-alpha.39",
|
33
|
+
"@routr/location": "^2.0.8-alpha.39",
|
34
|
+
"@routr/processor": "^2.0.8-alpha.39",
|
35
|
+
"jsonwebtoken": "^9.0.0"
|
36
|
+
},
|
37
|
+
"devDependencies": {
|
38
|
+
"@types/jsonwebtoken": "^9.0.1"
|
35
39
|
},
|
36
40
|
"files": [
|
37
41
|
"dist"
|
@@ -46,5 +50,5 @@
|
|
46
50
|
"bugs": {
|
47
51
|
"url": "https://github.com/fonoster/routr/issues"
|
48
52
|
},
|
49
|
-
"gitHead": "
|
53
|
+
"gitHead": "43d5cae0cb5a2c373ed7b219f5d73a42319b9ba5"
|
50
54
|
}
|