@routr/connect 2.6.2 → 2.6.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/handlers/register.d.ts +1 -1
- package/dist/utils.js +30 -22
- package/package.json +2 -2
@@ -1,4 +1,4 @@
|
|
1
|
-
import { MessageRequest, Response } from "@routr/processor";
|
2
1
|
import { ILocationService } from "@routr/location";
|
2
|
+
import { MessageRequest, Response } from "@routr/processor";
|
3
3
|
import { CommonConnect as CC } from "@routr/common";
|
4
4
|
export declare const handleRegister: (apiClient: CC.APIClient, location: ILocationService) => (request: MessageRequest, res: Response) => Promise<void>;
|
package/dist/utils.js
CHANGED
@@ -54,12 +54,13 @@ exports.getVerifierImpl = exports.hasXConnectObjectHeader = exports.getSIPURI =
|
|
54
54
|
* See the License for the specific language governing permissions and
|
55
55
|
* limitations under the License.
|
56
56
|
*/
|
57
|
+
const grpc = __importStar(require("@grpc/grpc-js"));
|
57
58
|
const jwt = __importStar(require("jsonwebtoken"));
|
59
|
+
const envs_1 = require("./envs");
|
58
60
|
const fs_1 = __importDefault(require("fs"));
|
59
61
|
const common_1 = require("@routr/common");
|
60
62
|
const processor_1 = require("@routr/processor");
|
61
63
|
const types_1 = require("./types");
|
62
|
-
const envs_1 = require("./envs");
|
63
64
|
// OMG, this is so ugly and hacky
|
64
65
|
const isKind = (res, kind) => {
|
65
66
|
if (res == null && kind === common_1.CommonConnect.Kind.UNKNOWN) {
|
@@ -94,27 +95,34 @@ const findNumberByTelUrl = (apiClient, telUrl) => __awaiter(void 0, void 0, void
|
|
94
95
|
});
|
95
96
|
exports.findNumberByTelUrl = findNumberByTelUrl;
|
96
97
|
const findResource = (apiClient, domainUri, userpart) => __awaiter(void 0, void 0, void 0, function* () {
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
98
|
+
try {
|
99
|
+
const domain = yield (0, exports.findDomain)(apiClient, domainUri);
|
100
|
+
// First, try to find a number
|
101
|
+
const number = yield (0, exports.findNumberByTelUrl)(apiClient, `tel:${userpart}`);
|
102
|
+
if (number != null)
|
103
|
+
return number;
|
104
|
+
// Next, try to find an agent
|
105
|
+
const agent = (yield apiClient.agents.findBy({
|
106
|
+
fieldName: "username",
|
107
|
+
fieldValue: userpart
|
108
|
+
})).items[0];
|
109
|
+
if (agent && agent.domain.ref != (domain === null || domain === void 0 ? void 0 : domain.ref)) {
|
110
|
+
// Not in the same domain
|
111
|
+
return null;
|
112
|
+
}
|
113
|
+
if (agent != null)
|
114
|
+
return agent;
|
115
|
+
// Next, try to find a peer
|
116
|
+
return (yield apiClient.peers.findBy({
|
117
|
+
fieldName: "username",
|
118
|
+
fieldValue: userpart
|
119
|
+
})).items[0];
|
120
|
+
}
|
121
|
+
catch (err) {
|
122
|
+
if (err.code === grpc.status.NOT_FOUND) {
|
123
|
+
return null;
|
124
|
+
}
|
125
|
+
}
|
118
126
|
});
|
119
127
|
exports.findResource = findResource;
|
120
128
|
const getRoutingDirection = (caller, callee) => {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@routr/connect",
|
3
|
-
"version": "2.6.
|
3
|
+
"version": "2.6.3",
|
4
4
|
"description": "Default processor",
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
6
6
|
"homepage": "https://github.com/fonoster/routr#readme",
|
@@ -49,5 +49,5 @@
|
|
49
49
|
"bugs": {
|
50
50
|
"url": "https://github.com/fonoster/routr/issues"
|
51
51
|
},
|
52
|
-
"gitHead": "
|
52
|
+
"gitHead": "917a3bac2a626cada27ed6f11654ae312bf95a12"
|
53
53
|
}
|