@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.
@@ -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
- const domain = yield (0, exports.findDomain)(apiClient, domainUri);
98
- // First, try to find a number
99
- const number = yield (0, exports.findNumberByTelUrl)(apiClient, `tel:${userpart}`);
100
- if (number != null)
101
- return number;
102
- // Next, try to find an agent
103
- const agent = (yield apiClient.agents.findBy({
104
- fieldName: "username",
105
- fieldValue: userpart
106
- })).items[0];
107
- if (agent && agent.domain.ref != (domain === null || domain === void 0 ? void 0 : domain.ref)) {
108
- // Not in the same domain
109
- return null;
110
- }
111
- if (agent != null)
112
- return agent;
113
- // Next, try to find a peer
114
- return (yield apiClient.peers.findBy({
115
- fieldName: "username",
116
- fieldValue: userpart
117
- })).items[0];
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.2",
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": "87f2724c378af3b3b3a4ae22b91dfa63201161d3"
52
+ "gitHead": "917a3bac2a626cada27ed6f11654ae312bf95a12"
53
53
  }