@routr/connect 2.0.8-alpha.6 → 2.0.8-alpha.8
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/handlers.d.ts +2 -2
- package/dist/handlers.js +24 -1
- package/dist/service.js +1 -1
- package/package.json +5 -5
package/dist/handlers.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { MessageRequest, Response } from "@routr/processor";
|
2
|
-
import { ILocationService } from "@routr/location
|
2
|
+
import { ILocationService } from "@routr/location";
|
3
3
|
import { CommonConnect as CC } from "@routr/common";
|
4
|
-
export declare const handleRegister: (location: ILocationService) => (request: MessageRequest, res: Response) => Promise<void>;
|
4
|
+
export declare const handleRegister: (dataAPI: CC.DataAPI, location: ILocationService) => (request: MessageRequest, res: Response) => Promise<void>;
|
5
5
|
export declare const handleRegistry: (req: MessageRequest, res: Response) => void;
|
6
6
|
export declare const handleRequest: (location: ILocationService, dataAPI?: CC.DataAPI) => (req: MessageRequest, res: Response) => Promise<void | MessageRequest>;
|
package/dist/handlers.js
CHANGED
@@ -34,8 +34,31 @@ const processor_1 = require("@routr/processor");
|
|
34
34
|
const function_1 = require("fp-ts/function");
|
35
35
|
const router_1 = require("./router");
|
36
36
|
const common_1 = require("@routr/common");
|
37
|
-
const
|
37
|
+
const utils_1 = require("./utils");
|
38
|
+
const handleRegister = (dataAPI, location) => {
|
38
39
|
return (request, res) => __awaiter(void 0, void 0, void 0, function* () {
|
40
|
+
// Calculate and return challenge
|
41
|
+
if (request.message.authorization) {
|
42
|
+
const auth = Object.assign({}, request.message.authorization);
|
43
|
+
auth.method = request.method;
|
44
|
+
const fromURI = request.message.from.address.uri;
|
45
|
+
const agent = yield (0, utils_1.findResource)(dataAPI, fromURI.host, fromURI.user);
|
46
|
+
if (!agent) {
|
47
|
+
return res.send(common_1.Auth.createForbideenResponse());
|
48
|
+
}
|
49
|
+
const credentials = yield dataAPI.get(agent === null || agent === void 0 ? void 0 : agent.spec.credentialsRef);
|
50
|
+
// Calculate response and compare with the one send by the endpoint
|
51
|
+
const calcRes = common_1.Auth.calculateAuthResponse(auth, {
|
52
|
+
username: credentials === null || credentials === void 0 ? void 0 : credentials.spec.credentials.username,
|
53
|
+
secret: credentials === null || credentials === void 0 ? void 0 : credentials.spec.credentials.password
|
54
|
+
});
|
55
|
+
if (calcRes !== auth.response) {
|
56
|
+
return res.send(common_1.Auth.createUnauthorizedResponse(request.message.requestUri.host));
|
57
|
+
}
|
58
|
+
}
|
59
|
+
else {
|
60
|
+
return res.send(common_1.Auth.createUnauthorizedResponse(request.message.requestUri.host));
|
61
|
+
}
|
39
62
|
yield location.addRoute({
|
40
63
|
aor: processor_1.Target.getTargetAOR(request),
|
41
64
|
route: location_1.Helper.createRoute(request)
|
package/dist/service.js
CHANGED
@@ -70,7 +70,7 @@ function ConnectProcessor(config) {
|
|
70
70
|
(0, handlers_1.handleRegistry)(req, res);
|
71
71
|
}
|
72
72
|
else {
|
73
|
-
(0, handlers_1.handleRegister)(location)(req, res);
|
73
|
+
(0, handlers_1.handleRegister)(common_2.CommonConnect.dataAPI(config.apiAddr), location)(req, res);
|
74
74
|
}
|
75
75
|
break;
|
76
76
|
case common_1.Method.BYE:
|
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.8",
|
4
4
|
"description": "Default processor",
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
6
6
|
"homepage": "https://github.com/fonoster/routr#readme",
|
@@ -28,9 +28,9 @@
|
|
28
28
|
"@opentelemetry/sdk-trace-base": "^1.0.4",
|
29
29
|
"@opentelemetry/sdk-trace-node": "^1.0.4",
|
30
30
|
"@opentelemetry/semantic-conventions": "^1.0.4",
|
31
|
-
"@routr/common": "^2.0.8-alpha.
|
32
|
-
"@routr/location": "^2.0.8-alpha.
|
33
|
-
"@routr/processor": "^2.0.8-alpha.
|
31
|
+
"@routr/common": "^2.0.8-alpha.8",
|
32
|
+
"@routr/location": "^2.0.8-alpha.8",
|
33
|
+
"@routr/processor": "^2.0.8-alpha.8"
|
34
34
|
},
|
35
35
|
"files": [
|
36
36
|
"dist"
|
@@ -45,5 +45,5 @@
|
|
45
45
|
"bugs": {
|
46
46
|
"url": "https://github.com/fonoster/routr/issues"
|
47
47
|
},
|
48
|
-
"gitHead": "
|
48
|
+
"gitHead": "bcc116fba248b34f661d88e425e5060f409be77c"
|
49
49
|
}
|