@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,CAoChE;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAOvE"}
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
- agentOpenEndpoints.forEach((openEndpoint) => {
10
- const agentUrl = new URL(openEndpoint);
11
- if (areUrlsEqualIgnoringQuery(agentUrl, requestedUrl)) {
12
- urlMatching = new URL(openEndpoint);
13
- matches = true;
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
- agentEndpoints.forEach((ep) => {
20
- const [verb, url] = Object.entries(ep)[0];
21
- const _url = new URL(url);
22
- const fn = match(_url.pathname, { decode: decodeURIComponent });
23
- if (fn(requestedUrl.pathname) && (verb.toLowerCase() === requestedHTTPVerb || verb === '*')) {
24
- matches = true;
25
- urlMatching = _url;
26
- verbMatching = verb;
27
- return;
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nevermined-io/core-kit",
3
- "version": "0.0.50",
3
+ "version": "0.0.52",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",