@nevermined-io/core-kit 0.0.50 → 0.0.52
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentUtils.d.ts","sourceRoot":"","sources":["../../../src/nevermined/utils/AgentUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAGnD,wBAAgB,2BAA2B,CACzC,eAAe,EAAE,MAAM,EACvB,iBAAiB,EAAE,MAAM,EACzB,cAAc,EAAE,WAAW,EAAE,EAC7B,kBAAkB,GAAE,MAAM,EAAO,GAChC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,GAAG,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"AgentUtils.d.ts","sourceRoot":"","sources":["../../../src/nevermined/utils/AgentUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAGnD,wBAAgB,2BAA2B,CACzC,eAAe,EAAE,MAAM,EACvB,iBAAiB,EAAE,MAAM,EACzB,cAAc,EAAE,WAAW,EAAE,EAC7B,kBAAkB,GAAE,MAAM,EAAO,GAChC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,GAAG,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAkDhE;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAOvE"}
|
|
@@ -6,27 +6,41 @@ export function isEndpointRequestedIncluded(requestEndpoint, requestedHTTPVerb,
|
|
|
6
6
|
let urlMatching, verbMatching;
|
|
7
7
|
const requestedUrl = new URL(requestEndpoint);
|
|
8
8
|
// Is the endpoint an open endpoint?
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
for (const openEndpoint of agentOpenEndpoints) {
|
|
10
|
+
try {
|
|
11
|
+
const agentUrl = new URL(openEndpoint);
|
|
12
|
+
if (areUrlsEqualIgnoringQuery(agentUrl, requestedUrl)) {
|
|
13
|
+
urlMatching = new URL(openEndpoint);
|
|
14
|
+
matches = true;
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
14
17
|
}
|
|
15
|
-
|
|
18
|
+
catch (error) {
|
|
19
|
+
// Skip invalid URLs and continue with next endpoint
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
16
23
|
if (matches)
|
|
17
24
|
return { matches: true, urlMatching };
|
|
18
25
|
// check if the endpoint/verb is part of the list
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
for (const ep of agentEndpoints) {
|
|
27
|
+
try {
|
|
28
|
+
const [verb, url] = Object.entries(ep)[0];
|
|
29
|
+
const _url = new URL(url);
|
|
30
|
+
const fn = match(_url.pathname, { decode: decodeURIComponent });
|
|
31
|
+
if (fn(requestedUrl.pathname) &&
|
|
32
|
+
(verb.toLowerCase() === requestedHTTPVerb || verb === '*')) {
|
|
33
|
+
matches = true;
|
|
34
|
+
urlMatching = _url;
|
|
35
|
+
verbMatching = verb;
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
// Skip invalid patterns and continue with next endpoint
|
|
41
|
+
continue;
|
|
28
42
|
}
|
|
29
|
-
}
|
|
43
|
+
}
|
|
30
44
|
return { matches, urlMatching, verbMatching };
|
|
31
45
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
32
46
|
}
|