@heliyos/heliyos-api-core 1.0.26 → 1.0.27
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/README.md +5 -8
- package/dist/@types/globals/AxiosServers.d.ts +3 -5
- package/dist/authentication.js +2 -2
- package/dist/authorization.js +1 -1
- package/dist/axios.js +10 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -104,17 +104,14 @@ Pre-configured Axios instances for internal services.
|
|
|
104
104
|
import { axios } from "@heliyos/heliyos-api-core";
|
|
105
105
|
|
|
106
106
|
// Available instances:
|
|
107
|
-
await axios.
|
|
108
|
-
await axios.
|
|
109
|
-
await axios.
|
|
110
|
-
await axios.notification_server.delete("/endpoint");
|
|
111
|
-
await axios.user_server.patch("/endpoint", data);
|
|
107
|
+
await axios.authServer.get("/endpoint");
|
|
108
|
+
await axios.platformServer.post("/endpoint", data);
|
|
109
|
+
await axios.agentServer.put("/endpoint", data);
|
|
112
110
|
|
|
113
111
|
// Required environment variables for each server:
|
|
114
112
|
// BASE_URL_AUTH_SERVER + SECRET_OF_AUTH_SERVER
|
|
115
|
-
//
|
|
116
|
-
//
|
|
117
|
-
// BASE_URL_NOTIFICATION_SERVER + SECRET_OF_NOTIFICATION_SERVER
|
|
113
|
+
// BASE_URL_PLATFORM_SERVER + SECRET_OF_PLATFORM_SERVER
|
|
114
|
+
// BASE_URL_AGENT_SERVER + SECRET_OF_AGENT_SERVER
|
|
118
115
|
// BASE_URL_USERS_SERVER + SECRET_OF_USERS_SERVER
|
|
119
116
|
```
|
|
120
117
|
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { AxiosInstance, AxiosStatic } from "axios";
|
|
2
2
|
export interface AxiosServers {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
notification_server: AxiosInstance;
|
|
7
|
-
user_server: AxiosInstance;
|
|
3
|
+
authServer: AxiosInstance;
|
|
4
|
+
agentServer: AxiosInstance;
|
|
5
|
+
platformServer: AxiosInstance;
|
|
8
6
|
axios: AxiosStatic;
|
|
9
7
|
}
|
package/dist/authentication.js
CHANGED
|
@@ -253,7 +253,7 @@ const setLoggedInUser = function (container, req) {
|
|
|
253
253
|
const callAuthApiServer = (token) => __awaiter(void 0, void 0, void 0, function* () {
|
|
254
254
|
var _a, _b;
|
|
255
255
|
try {
|
|
256
|
-
const authResult = yield _1.axios.
|
|
256
|
+
const authResult = yield _1.axios.authServer.post("/v1/auth/verify_token_v2", {
|
|
257
257
|
token: token,
|
|
258
258
|
});
|
|
259
259
|
if ((_b = (_a = authResult.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.isValid) {
|
|
@@ -282,7 +282,7 @@ const verifyApiKey = (apiKey) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
282
282
|
var _a, _b, _c, _d;
|
|
283
283
|
try {
|
|
284
284
|
// Call api key service to verify api key
|
|
285
|
-
const apiRes = yield _1.axios.
|
|
285
|
+
const apiRes = yield _1.axios.authServer.post(`/v2/auth/api_key/verify`, {
|
|
286
286
|
apiKey,
|
|
287
287
|
});
|
|
288
288
|
if ((_b = (_a = apiRes.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.isValid) {
|
package/dist/authorization.js
CHANGED
|
@@ -22,7 +22,7 @@ const axios_1 = require("./axios");
|
|
|
22
22
|
// eslint-disable-next-line import/prefer-default-export, @typescript-eslint/naming-convention
|
|
23
23
|
const authorizeUser = (organizationId, userId, resourceAction) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
24
|
try {
|
|
25
|
-
const authenticationResponse = yield axios_1.coreAxios.
|
|
25
|
+
const authenticationResponse = yield axios_1.coreAxios.authServer.post(`v1/auth/user/${userId}`, { resourceAction, organizationId });
|
|
26
26
|
return authenticationResponse.data.data;
|
|
27
27
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
|
|
28
28
|
}
|
package/dist/axios.js
CHANGED
|
@@ -52,29 +52,19 @@ const handleAxiosError = (err) => {
|
|
|
52
52
|
// Axios server configs
|
|
53
53
|
const servers = {
|
|
54
54
|
// Auth server
|
|
55
|
-
|
|
56
|
-
username: "",
|
|
55
|
+
authServer: axios_1.default.create(Object.assign(Object.assign({}, config), { baseURL: process.env.BASE_URL_AUTH_SERVER, auth: {
|
|
56
|
+
username: "auth",
|
|
57
57
|
password: process.env.SECRET_OF_AUTH_SERVER,
|
|
58
58
|
} })),
|
|
59
|
-
//
|
|
60
|
-
|
|
61
|
-
username: "",
|
|
62
|
-
password: process.env.
|
|
59
|
+
// Agent server
|
|
60
|
+
agentServer: axios_1.default.create(Object.assign(Object.assign({}, config), { baseURL: process.env.BASE_URL_AGENT_SERVER, auth: {
|
|
61
|
+
username: "agent",
|
|
62
|
+
password: process.env.SECRET_OF_AGENT_SERVER,
|
|
63
63
|
} })),
|
|
64
|
-
//
|
|
65
|
-
|
|
66
|
-
username: "",
|
|
67
|
-
password: process.env.
|
|
68
|
-
} })),
|
|
69
|
-
// Notifications server
|
|
70
|
-
notification_server: axios_1.default.create(Object.assign(Object.assign({}, config), { baseURL: process.env.BASE_URL_NOTIFICATION_SERVER, auth: {
|
|
71
|
-
username: "",
|
|
72
|
-
password: process.env.SECRET_OF_NOTIFICATION_SERVER,
|
|
73
|
-
} })),
|
|
74
|
-
// Users server
|
|
75
|
-
user_server: axios_1.default.create(Object.assign(Object.assign({}, config), { baseURL: process.env.BASE_URL_USERS_SERVER, auth: {
|
|
76
|
-
username: "",
|
|
77
|
-
password: process.env.SECRET_OF_USERS_SERVER,
|
|
64
|
+
// Platform server
|
|
65
|
+
platformServer: axios_1.default.create(Object.assign(Object.assign({}, config), { baseURL: process.env.BASE_URL_PLATFORM_SERVER, auth: {
|
|
66
|
+
username: "platform",
|
|
67
|
+
password: process.env.SECRET_OF_PLATFORM_SERVER,
|
|
78
68
|
} })),
|
|
79
69
|
// Export axios plain object to call some third party external calls
|
|
80
70
|
axios: axios_1.default,
|