godprotocol 2.2.83 → 2.2.85

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.2.83",
3
+ "version": "2.2.85",
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",
@@ -174,7 +174,13 @@ class Headers extends Services {
174
174
  headers["authorization"] = `Bearer ${authorization}`;
175
175
  }
176
176
 
177
- let third_party = xplatform !== this.platform_uri;
177
+ let third_party =
178
+ xplatform !== this.platform_uri &&
179
+ !gp_services.profile.endsWith(request.headers.host);
180
+ if (gp_services.profile.endsWith(request.headers.host)) {
181
+ headers["x-platform"] = xplatform;
182
+ }
183
+
178
184
  let res = await fetch(
179
185
  `${gp_services.profile}/${third_party ? "third_party_me" : "me"}`,
180
186
  {
@@ -234,13 +240,13 @@ class Headers extends Services {
234
240
  if (authorisation) authorisation = authorisation.replace("Bearer ", "");
235
241
 
236
242
  let val;
237
- if (api_key) {
238
- val = await this.validate_api_key(api_key, authorisation);
239
- } else if (authorisation) {
243
+ if (route.config.security?.includes("auth_token")) {
240
244
  val = await this.validate_third_party(
241
245
  xplatform || this.platform_uri,
242
246
  authorisation,
243
247
  );
248
+ } else if (route.config.security?.includes("api_key")) {
249
+ val = await this.validate_api_key(api_key, authorisation);
244
250
  }
245
251
 
246
252
  // debug(val);
@@ -119,7 +119,11 @@ class Services {
119
119
  };
120
120
 
121
121
  platform_db = async () => {
122
- return new DB(this.db_config, this);
122
+ if (this.db) return this.db;
123
+
124
+ this.db = new DB(this.db_config, this);
125
+
126
+ return this.db;
123
127
  };
124
128
 
125
129
  handle_webhook_prior = async (req) => {
@@ -1,3 +1,4 @@
1
+ import parseMultipart from "godprotocol/server/parse_multipart_data.js";
1
2
  import serveStaticFile from "godprotocol/server/serve_static_file.js";
2
3
 
3
4
  const getBody = (req) => {
@@ -131,8 +132,14 @@ const version_middleware = async (req, res, routers) => {
131
132
 
132
133
  body = Object.fromEntries(url.searchParams.entries());
133
134
  } else {
134
- error_stage = "Body Parser";
135
- body = await getBody(req);
135
+ const contentType = req.headers["content-type"] || "";
136
+
137
+ if (contentType.includes("multipart/form-data")) {
138
+ body = await parseMultipart(req, routers.gp);
139
+ } else {
140
+ error_stage = "Body Parser";
141
+ body = await getBody(req);
142
+ }
136
143
  }
137
144
 
138
145
  if (versionRouter.config?.is_old) {