godprotocol 1.2.37 → 1.2.51

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.
@@ -23,8 +23,13 @@ class Account extends Utils {
23
23
  let chain = await this.chain.chain(phy);
24
24
 
25
25
  if (compiler) {
26
+ let adr = `.codes/${phy}.air`;
26
27
  !from_reload &&
27
- (await this.manager.oracle.write(`.codes/${phy}.air`, sequence));
28
+ (await (
29
+ await this.manager.ds.folder(`${adr}`, {
30
+ account: this.physical_address,
31
+ })
32
+ ).write({ sequence, _id }));
28
33
 
29
34
  sequence = await this.compiler.to_sequence(sequence, address);
30
35
  sequence = sequence[0];
@@ -46,8 +51,13 @@ class Account extends Utils {
46
51
  config = await folder.readone(_id ? { _id } : null);
47
52
 
48
53
  if (!config) {
49
- let code = await this.manager.oracle.read(`.codes/${phy}.air`);
54
+ let code = await (
55
+ await this.manager.ds.folder(`.codes/${phy}`, {
56
+ account: this.physical_address,
57
+ })
58
+ ).readone(_id ? { _id } : null);
50
59
  if (code) {
60
+ code = code.sequence;
51
61
  code = await this.compiler.to_sequence(code, address);
52
62
  code = code[0];
53
63
 
@@ -166,6 +176,7 @@ class Account extends Utils {
166
176
  account: this.physical_address,
167
177
  });
168
178
 
179
+ passes.secrecy = true;
169
180
  let pass = await passes.readone(),
170
181
  passed = false;
171
182
 
package/Objects/Oracle.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import { post_request } from "../utils/services.js";
2
2
 
3
3
  class Oracle_client {
4
- constructor(server) {
4
+ constructor(server, options = {}) {
5
5
  this.server = server;
6
+ this.manager_key = options.manager_key;
6
7
 
7
8
  this.repo_cache = new Object();
8
9
  this.repos = [];
@@ -20,38 +21,40 @@ class Oracle_client {
20
21
  return repo_;
21
22
  };
22
23
 
23
- write_local = async (path, content) => {
24
+ write_local = async (path, content, options) => {
24
25
  if (this.local) {
25
- await this.local.write(path, content);
26
+ await this.local.write(path, content, options);
26
27
  }
27
28
  };
28
29
 
29
- read_local = async (path) => {
30
+ read_local = async (path, options) => {
30
31
  if (this.local) {
31
- let content = await this.local.read(path);
32
+ let content = await this.local.read(path, options);
32
33
  return content;
33
34
  }
34
35
  return null;
35
36
  };
36
37
 
37
- write = async (path, content) => {
38
+ write = async (path, content, options) => {
38
39
  await this.fetch({
39
40
  method: Array.isArray(content) ? "write_bulk" : "write",
40
- args: { path, content },
41
+ args: { path, content, options },
41
42
  });
42
43
  };
43
44
 
44
- read = async (path) => {
45
+ read = async (path, options = {}) => {
45
46
  let repo = this.repo_cache[path],
46
47
  content;
47
48
 
48
49
  if (repo) {
49
- content = await repo.read(path);
50
+ if (options.decrypt === true) options.decrypt = this.manager_key;
51
+
52
+ content = await repo.read(path, { decrypt: options.decrypt });
50
53
  }
51
54
  if (!content) {
52
55
  let response = await this.fetch({
53
56
  method: "read",
54
- args: { path },
57
+ args: { path, options },
55
58
  });
56
59
  content = response && response.content;
57
60
  if (content) {
@@ -131,7 +134,6 @@ class Oracle_client {
131
134
  },
132
135
  });
133
136
  if (!auth) return;
134
- console.log("Oracle authenticated:", auth);
135
137
 
136
138
  if (auth.token) {
137
139
  if (local) {
@@ -146,20 +148,20 @@ class Oracle_client {
146
148
  get_auth_token = async () => {
147
149
  let token = this.auth_token;
148
150
  if (!token) {
149
- token = await this.read_local(this.token_addr);
151
+ token = await this.read_local(this.token_addr, {
152
+ decrypt: this.manager_key,
153
+ });
150
154
  if (token && token.expired) token = null;
151
- console.log("read token:", token);
152
155
  if (token) {
153
156
  token = JSON.parse(token);
154
157
  this.auth_token = token.token;
155
158
  this.client = token.client;
156
159
  }
157
160
  }
158
- console.log("Oracle auth token:", this.auth_token);
159
161
  return this.auth_token;
160
162
  };
161
163
 
162
- token_addr = `.accounts/sign`;
164
+ token_addr = `.clients/sign`;
163
165
 
164
166
  set_auth_token = async (token) => {
165
167
  let obj = { client: this.client, token };
@@ -168,7 +170,9 @@ class Oracle_client {
168
170
 
169
171
  obj.expired = true;
170
172
  }
171
- await this.write_local(this.token_addr, JSON.stringify(obj));
173
+ await this.write_local(this.token_addr, JSON.stringify(obj), {
174
+ encrypt: this.manager_key,
175
+ });
172
176
  };
173
177
 
174
178
  cloth_repo = async (repo) => {
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "godprotocol",
3
- "version": "1.2.37",
3
+ "version": "1.2.51",
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",
7
7
  "scripts": {
8
- "start": "nodemon Index.js",
8
+ "start": "node Index.js",
9
9
  "dev": "node Index.js",
10
10
  "test": "echo \"No test specified\" && exit 0"
11
11
  },
@@ -25,7 +25,7 @@
25
25
  "ar",
26
26
  "vr"
27
27
  ],
28
- "author": "Savvy <contact@yourdomain.com>",
28
+ "author": "Savvy <savvy@godprotocol.org>",
29
29
  "license": "ISC",
30
30
  "bugs": {
31
31
  "url": "https://github.com/immanuel-savvy/GodProtocol/issues"
@@ -35,9 +35,6 @@
35
35
  "aircode4": "latest",
36
36
  "generalised-datastore": "latest"
37
37
  },
38
- "devDependencies": {
39
- "nodemon": "^3.1.7"
40
- },
41
38
  "engines": {
42
39
  "node": ">=18"
43
40
  },
package/utils/services.js CHANGED
@@ -1,5 +1,5 @@
1
- import http from 'http'
2
- import https from 'https'
1
+ import http from "http";
2
+ import https from "https";
3
3
 
4
4
  const post_request = (payload, cb) => {
5
5
  // let options = {
@@ -13,41 +13,35 @@ const post_request = (payload, cb) => {
13
13
  // },
14
14
  // };
15
15
 
16
- // console.log(payload)
17
16
  return new Promise((resolve, reject) => {
18
- let data = payload.data
19
-
17
+ let data = payload.data;
18
+
20
19
  let header = {
21
- ...payload.options,
22
- method: payload.options.method || "POST",
23
- headers: {
24
- ...payload.options.headers,
25
- "Content-Type": "application/json",
26
- },
27
- rejectUnauthorized: false,
28
- // minVersion: "TLSv1.2",
29
- }
30
- if(payload.data){
31
- header["Content-Length"] = Buffer.byteLength(data)
32
- }
33
-
34
- let mod = process.env.VERCEL ? https : http
35
- let req = mod.request(
36
- header,
37
- (res) => {
38
- let data = "";
39
-
40
- res.on("data", (chunk) => {
41
- data += chunk;
42
- });
43
-
44
- res.on("end", () => {
45
- // console.log('hey')
46
- resolve(data && JSON.parse(data));
47
- // console.log("Response:", data);
48
- });
49
- }
50
- );
20
+ ...payload.options,
21
+ method: payload.options.method || "POST",
22
+ headers: {
23
+ ...payload.options.headers,
24
+ "Content-Type": "application/json",
25
+ },
26
+ rejectUnauthorized: false,
27
+ // minVersion: "TLSv1.2",
28
+ };
29
+ if (payload.data) {
30
+ header["Content-Length"] = Buffer.byteLength(data);
31
+ }
32
+
33
+ let mod = process.env.LOCALHOST ? http : https;
34
+ let req = mod.request(header, (res) => {
35
+ let data = "";
36
+
37
+ res.on("data", (chunk) => {
38
+ data += chunk;
39
+ });
40
+
41
+ res.on("end", () => {
42
+ resolve(data && JSON.parse(data));
43
+ });
44
+ });
51
45
 
52
46
  req.on("error", (e) => {
53
47
  reject(e);