godprotocol 2.2.0 → 2.2.2
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/Godprotocol.js +2 -2
- package/Index.js +3 -1
- package/package.json +1 -1
- package/server/Routable/Header.js +23 -8
- package/server/Routable/Services.js +2 -1
package/Godprotocol.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Route_table from "./server/Routable/Route_table";
|
|
2
|
-
import version_middleware from "./server/version_control";
|
|
1
|
+
import Route_table from "./server/Routable/Route_table.js";
|
|
2
|
+
import version_middleware from "./server/version_control.js";
|
|
3
3
|
|
|
4
4
|
class GodProtocol {
|
|
5
5
|
constructor(config) {
|
package/Index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import GodProtocol from "./Godprotocol";
|
|
1
|
+
import GodProtocol from "./Godprotocol.js";
|
|
2
2
|
|
|
3
3
|
let gp = new GodProtocol({
|
|
4
4
|
platform_uri: "profile.savvyaisolution.com",
|
|
5
5
|
api_key: process.env.API_KEY,
|
|
6
|
+
db_config: {},
|
|
6
7
|
});
|
|
7
8
|
|
|
8
9
|
gp.add_router("v2", {});
|
|
9
10
|
|
|
10
11
|
app.use((req, res) => gp.on_request(req, res));
|
|
12
|
+
export default GodProtocol;
|
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Mongo } from "@godprotocol/repositories";
|
|
2
|
-
import {
|
|
3
|
-
import Services from "./Services.js";
|
|
2
|
+
import Services, { gp_services } from "./Services.js";
|
|
4
3
|
|
|
5
4
|
class DB {
|
|
6
5
|
constructor(config, router) {
|
|
@@ -115,8 +114,18 @@ class Headers extends Services {
|
|
|
115
114
|
headers["authorization"] = `Bearer ${authorization}`;
|
|
116
115
|
}
|
|
117
116
|
|
|
118
|
-
const res = await
|
|
117
|
+
const res = await fetch(`${gp_services.profile}/validate`, {
|
|
118
|
+
method: "post",
|
|
119
|
+
headers: {
|
|
120
|
+
"Content-Type": "application/json",
|
|
121
|
+
Accept: "application/json",
|
|
122
|
+
"x-api-version": "v2",
|
|
123
|
+
...headers,
|
|
124
|
+
},
|
|
125
|
+
body: JSON.stringify({}),
|
|
126
|
+
});
|
|
119
127
|
|
|
128
|
+
res = await res.json();
|
|
120
129
|
// 🔹 3. Save cache if valid
|
|
121
130
|
if (res.ok && res.data) {
|
|
122
131
|
await db.save_cache(query, res.data, "auth");
|
|
@@ -159,11 +168,17 @@ class Headers extends Services {
|
|
|
159
168
|
headers["authorization"] = `Bearer ${authorization}`;
|
|
160
169
|
}
|
|
161
170
|
|
|
162
|
-
const res = await
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
171
|
+
const res = await fetch(`${gp_services.profile}/validate_third_party`, {
|
|
172
|
+
method: "post",
|
|
173
|
+
headers: {
|
|
174
|
+
"Content-Type": "application/json",
|
|
175
|
+
Accept: "application/json",
|
|
176
|
+
"x-api-version": "v2",
|
|
177
|
+
...headers,
|
|
178
|
+
},
|
|
179
|
+
body: JSON.stringify({ platform_uri: xplatform }),
|
|
180
|
+
});
|
|
181
|
+
res = await res.json();
|
|
167
182
|
|
|
168
183
|
// 🔹 3. Save cache
|
|
169
184
|
if (res.ok && res.data) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { post_request } from "../../utils/services.js";
|
|
2
1
|
import { DB } from "./Header.js";
|
|
3
2
|
|
|
4
3
|
let gp_services = {
|
|
@@ -6,6 +5,8 @@ let gp_services = {
|
|
|
6
5
|
settings: "https://settings-api.savvyaisolution.com",
|
|
7
6
|
};
|
|
8
7
|
|
|
8
|
+
export { gp_services };
|
|
9
|
+
|
|
9
10
|
class Services {
|
|
10
11
|
constructor() {
|
|
11
12
|
this.services = new Object();
|