godprotocol 2.3.11 → 2.3.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "godprotocol",
3
- "version": "2.3.11",
3
+ "version": "2.3.12",
4
4
  "description": "A distributed computing environment for Web 4.0 — integrating AI, decentralisation, and virtual computation.",
5
5
  "main": "Index.js",
6
6
  "type": "module",
@@ -251,7 +251,12 @@ class Headers extends Services {
251
251
  };
252
252
 
253
253
  handle_security = async (name, request) => {
254
- if (this.active_version === "*") return true;
254
+ let config;
255
+ if (this.active_version === "*") {
256
+ let version = this.versions[this.active_version];
257
+
258
+ config = version.config;
259
+ }
255
260
 
256
261
  let route = await this.get_route(name);
257
262
 
@@ -260,14 +265,15 @@ class Headers extends Services {
260
265
  }
261
266
  if (!route?.config?.security?.length) return true;
262
267
 
263
- if (!this.check_security(route.config.security, request)) {
268
+ config = route.config;
269
+ if (!this.check_security(config.security, request)) {
264
270
  // debug("Unauthorized access attempt to route:", name);
265
271
  return {
266
272
  ok: false,
267
273
  status: 401,
268
274
  message:
269
275
  "Unauthorized: Missing required authentication headers of type(s): " +
270
- route.config.security.join(", "),
276
+ config.security.join(", "),
271
277
  };
272
278
  }
273
279
 
@@ -277,7 +283,7 @@ class Headers extends Services {
277
283
  if (authorisation) authorisation = authorisation.replace("Bearer ", "");
278
284
 
279
285
  let val;
280
- if (route.config.security?.includes("auth_token")) {
286
+ if (config.security?.includes("auth_token")) {
281
287
  if (authorisation?.startsWith("p")) {
282
288
  val = await this.validate_api_key(authorisation);
283
289
  } else
@@ -286,7 +292,7 @@ class Headers extends Services {
286
292
  authorisation,
287
293
  request,
288
294
  );
289
- } else if (route.config.security?.includes("api_key")) {
295
+ } else if (config.security?.includes("api_key")) {
290
296
  val = await this.validate_api_key(api_key, authorisation);
291
297
  }
292
298
 
@@ -44,7 +44,11 @@ class Route_table extends Headers {
44
44
  load_routes = async (routes) => {
45
45
  if (this.active_version === "*") {
46
46
  this.versions[this.active_version] = {
47
- handler: routes,
47
+ handler: routes.handler,
48
+ config: {
49
+ security: securities[config.security || "none"],
50
+ schema: routes.schema,
51
+ },
48
52
  };
49
53
  return;
50
54
  }