@routr/connect 2.0.8-alpha.40 → 2.0.8-alpha.42
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/access.d.ts +17 -0
- package/dist/handlers.js +5 -2
- package/dist/router.js +20 -8
- package/dist/utils.js +2 -2
- package/package.json +5 -5
package/dist/access.d.ts
CHANGED
@@ -10,6 +10,7 @@ export declare const checkAccess: (accessRequest: {
|
|
10
10
|
export declare const checkAgentOrPeerAccess: (request: MessageRequest, caller: CC.RoutableResourceUnion) => Promise<{
|
11
11
|
message: {
|
12
12
|
responseType: CT.ResponseType;
|
13
|
+
reasonPhrase: string;
|
13
14
|
wwwAuthenticate: {
|
14
15
|
scheme: string;
|
15
16
|
realm: string;
|
@@ -24,5 +25,21 @@ export declare const checkAgentOrPeerAccess: (request: MessageRequest, caller: C
|
|
24
25
|
export declare const checkAccessFromPSTN: (apiClient: CC.APIClient, request: MessageRequest, callee: CC.INumber) => Promise<{
|
25
26
|
message: {
|
26
27
|
responseType: CT.ResponseType;
|
28
|
+
reasonPhrase: string;
|
29
|
+
wwwAuthenticate: {
|
30
|
+
scheme: string;
|
31
|
+
realm: string;
|
32
|
+
qop: string;
|
33
|
+
opaque: string;
|
34
|
+
stale: boolean;
|
35
|
+
nonce: string;
|
36
|
+
algorithm: string;
|
37
|
+
};
|
38
|
+
};
|
39
|
+
} | {
|
40
|
+
metadata: Record<string, string>;
|
41
|
+
message: {
|
42
|
+
responseType: CT.ResponseType;
|
43
|
+
reasonPhrase: string;
|
27
44
|
};
|
28
45
|
}>;
|
package/dist/handlers.js
CHANGED
@@ -101,11 +101,13 @@ exports.handleRegistry = handleRegistry;
|
|
101
101
|
const handleRequest = (location, apiClient) => (request, res) => __awaiter(void 0, void 0, void 0, function* () {
|
102
102
|
try {
|
103
103
|
const req = common_1.Environment.ENFORCE_E164 ? enforceE164(request) : request;
|
104
|
+
// Must get the metadata here before the request is forwarded
|
104
105
|
const route = processor_1.Extensions.getHeaderValue(req, common_1.CommonTypes.ExtraHeader.EDGEPORT_REF)
|
105
106
|
? location_1.Helper.createRouteFromLastMessage(req)
|
106
107
|
: yield (0, router_1.router)(location, apiClient)(req);
|
107
108
|
if (!route)
|
108
109
|
return res.sendNotFound();
|
110
|
+
logger.error(JSON.stringify({ route }, null, 2));
|
109
111
|
// If route is not type Route then return
|
110
112
|
if (!("listeningPoints" in route)) {
|
111
113
|
return res.send(route);
|
@@ -117,13 +119,14 @@ const handleRequest = (location, apiClient) => (request, res) => __awaiter(void
|
|
117
119
|
// The order of the routes is important
|
118
120
|
processor_1.Alterations.addRouteToPeerEdgePort(route), processor_1.Alterations.addRouteToNextHop(route), processor_1.Alterations.addXEdgePortRef, processor_1.Alterations.decreaseMaxForwards));
|
119
121
|
}
|
122
|
+
// TODO: We should add this the Tailor API
|
123
|
+
req.metadata = route.metadata;
|
120
124
|
res.send((0, tailor_1.tailor)(route, req));
|
121
125
|
}
|
122
126
|
}
|
123
127
|
catch (err) {
|
124
|
-
res.sendInternalServerError();
|
125
128
|
logger.error(err);
|
126
|
-
|
129
|
+
res.sendInternalServerError();
|
127
130
|
}
|
128
131
|
});
|
129
132
|
exports.handleRequest = handleRequest;
|
package/dist/router.js
CHANGED
@@ -48,6 +48,9 @@ function router(location, apiClient) {
|
|
48
48
|
if ((0, utils_1.hasXConnectObjectHeader)(request)) {
|
49
49
|
const connectToken = processor_1.Extensions.getHeaderValue(request, common_1.CommonTypes.ExtraHeader.CONNECT_TOKEN);
|
50
50
|
try {
|
51
|
+
if (!jwtVerifier) {
|
52
|
+
return common_1.Auth.createServerInternalErrorResponse();
|
53
|
+
}
|
51
54
|
const payload = (yield jwtVerifier.verify(connectToken));
|
52
55
|
const domain = yield (0, utils_1.findDomain)(apiClient, payload.domain);
|
53
56
|
if (!payload.allowedMethods.includes(common_1.Method.INVITE)) {
|
@@ -101,15 +104,24 @@ function router(location, apiClient) {
|
|
101
104
|
return failedCheck;
|
102
105
|
}
|
103
106
|
}
|
107
|
+
// We add metadata to the route object so we can use it later to link to an account
|
104
108
|
switch (routingDirection) {
|
105
|
-
case types_1.RoutingDirection.AGENT_TO_AGENT:
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
case types_1.RoutingDirection.
|
110
|
-
|
111
|
-
|
112
|
-
|
109
|
+
case types_1.RoutingDirection.AGENT_TO_AGENT: {
|
110
|
+
const route = yield agentToAgent(location, request);
|
111
|
+
return Object.assign(Object.assign({}, route), { metadata: caller.extended });
|
112
|
+
}
|
113
|
+
case types_1.RoutingDirection.AGENT_TO_PEER: {
|
114
|
+
const route = yield agentToPeer(location, callee, request);
|
115
|
+
return Object.assign(Object.assign({}, route), { metadata: caller.extended });
|
116
|
+
}
|
117
|
+
case types_1.RoutingDirection.AGENT_TO_PSTN: {
|
118
|
+
const route = yield agentToPSTN(request, caller, requestURI.user);
|
119
|
+
return Object.assign(Object.assign({}, route), { metadata: caller.extended });
|
120
|
+
}
|
121
|
+
case types_1.RoutingDirection.FROM_PSTN: {
|
122
|
+
const route = yield fromPSTN(apiClient, location, callee, request);
|
123
|
+
return Object.assign(Object.assign({}, route), { metadata: callee.extended });
|
124
|
+
}
|
113
125
|
case types_1.RoutingDirection.PEER_TO_PSTN:
|
114
126
|
return yield peerToPSTN(apiClient, request);
|
115
127
|
default:
|
package/dist/utils.js
CHANGED
@@ -68,13 +68,13 @@ const isKind = (res, kind) => {
|
|
68
68
|
else if (res == null) {
|
69
69
|
return false;
|
70
70
|
}
|
71
|
-
else if ("
|
71
|
+
else if ("privacy" in res && kind === common_1.CommonConnect.Kind.AGENT) {
|
72
72
|
return true;
|
73
73
|
}
|
74
74
|
else if ("telUrl" in res && kind === common_1.CommonConnect.Kind.NUMBER) {
|
75
75
|
return true;
|
76
76
|
}
|
77
|
-
else if ("
|
77
|
+
else if ("username" in res && kind === common_1.CommonConnect.Kind.PEER) {
|
78
78
|
return true;
|
79
79
|
}
|
80
80
|
};
|
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.42",
|
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,9 @@
|
|
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.42",
|
33
|
+
"@routr/location": "^2.0.8-alpha.42",
|
34
|
+
"@routr/processor": "^2.0.8-alpha.42",
|
35
35
|
"jsonwebtoken": "^9.0.0"
|
36
36
|
},
|
37
37
|
"devDependencies": {
|
@@ -50,5 +50,5 @@
|
|
50
50
|
"bugs": {
|
51
51
|
"url": "https://github.com/fonoster/routr/issues"
|
52
52
|
},
|
53
|
-
"gitHead": "
|
53
|
+
"gitHead": "d52dbb834a74e0d0630521d5f9074ca25b0104c0"
|
54
54
|
}
|