nextemos 6.2.2 → 6.3.1
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/dist/helpers/getConfigs.d.ts +0 -7
- package/dist/helpers/getConfigs.js +1 -11
- package/dist/helpers/index.d.ts +0 -3
- package/dist/helpers/index.js +1 -7
- package/dist/services/keycloak/index.js +11 -16
- package/dist/services/keycloak/keycloak.types.d.ts +4 -2
- package/package.json +2 -4
- package/dist/helpers/decodeHTML.d.ts +0 -2
- package/dist/helpers/decodeHTML.js +0 -11
- package/dist/helpers/toIntArray.d.ts +0 -12
- package/dist/helpers/toIntArray.js +0 -20
- package/dist/helpers/toQueryString.d.ts +0 -8
- package/dist/helpers/toQueryString.js +0 -21
|
@@ -6,13 +6,6 @@ export declare const defaultConfig: {
|
|
|
6
6
|
LOG_LEVEL: string;
|
|
7
7
|
CACHE: string;
|
|
8
8
|
};
|
|
9
|
-
KEYCLOAK: {
|
|
10
|
-
URL: string;
|
|
11
|
-
REALM: string;
|
|
12
|
-
CLIENT_ID: string;
|
|
13
|
-
CLIENT_SECRET: string;
|
|
14
|
-
GRANT_TYPE: string;
|
|
15
|
-
};
|
|
16
9
|
K8S_NAMESPACE: string;
|
|
17
10
|
K8S_SERVICE_NAMES: {
|
|
18
11
|
ADDRESS: string;
|
|
@@ -29,7 +29,7 @@ function deepMerge(target, ...sources) {
|
|
|
29
29
|
* Check if value is an object (but not null, array, or primitive)
|
|
30
30
|
*/
|
|
31
31
|
function isObject(item) {
|
|
32
|
-
return item && typeof item ===
|
|
32
|
+
return item && typeof item === "object" && !Array.isArray(item);
|
|
33
33
|
}
|
|
34
34
|
exports.defaultConfig = {
|
|
35
35
|
API_URL: "",
|
|
@@ -39,13 +39,6 @@ exports.defaultConfig = {
|
|
|
39
39
|
LOG_LEVEL: "info",
|
|
40
40
|
CACHE: "",
|
|
41
41
|
},
|
|
42
|
-
KEYCLOAK: {
|
|
43
|
-
URL: "https://identity.proj-e.com",
|
|
44
|
-
REALM: "test",
|
|
45
|
-
CLIENT_ID: "test_client",
|
|
46
|
-
CLIENT_SECRET: "",
|
|
47
|
-
GRANT_TYPE: "client_credentials",
|
|
48
|
-
},
|
|
49
42
|
K8S_NAMESPACE: "emosv2service",
|
|
50
43
|
K8S_SERVICE_NAMES: {
|
|
51
44
|
ADDRESS: "address",
|
|
@@ -80,7 +73,4 @@ catch (error) {
|
|
|
80
73
|
}
|
|
81
74
|
// Merge with default config to ensure all required fields exist
|
|
82
75
|
const NEXTEMOS_CONFIG = deepMerge({}, exports.defaultConfig, loadedConfig);
|
|
83
|
-
if (process.env.KEYCLOAK_CLIENT_SECRET) {
|
|
84
|
-
NEXTEMOS_CONFIG.KEYCLOAK.CLIENT_SECRET = process.env.KEYCLOAK_CLIENT_SECRET;
|
|
85
|
-
}
|
|
86
76
|
exports.default = NEXTEMOS_CONFIG;
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
1
|
export { default as fetchRequest } from './fetchRequest';
|
|
2
|
-
export { default as toIntArray } from './toIntArray';
|
|
3
|
-
export { default as toQueryString } from './toQueryString';
|
|
4
|
-
export { default as decodeHTML } from './decodeHTML';
|
|
5
2
|
export { default as NEXTEMOS_CONFIG } from './getConfigs';
|
package/dist/helpers/index.js
CHANGED
|
@@ -3,15 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.NEXTEMOS_CONFIG = exports.
|
|
6
|
+
exports.NEXTEMOS_CONFIG = exports.fetchRequest = void 0;
|
|
7
7
|
/// helpers
|
|
8
8
|
var fetchRequest_1 = require("./fetchRequest");
|
|
9
9
|
Object.defineProperty(exports, "fetchRequest", { enumerable: true, get: function () { return __importDefault(fetchRequest_1).default; } });
|
|
10
|
-
var toIntArray_1 = require("./toIntArray");
|
|
11
|
-
Object.defineProperty(exports, "toIntArray", { enumerable: true, get: function () { return __importDefault(toIntArray_1).default; } });
|
|
12
|
-
var toQueryString_1 = require("./toQueryString");
|
|
13
|
-
Object.defineProperty(exports, "toQueryString", { enumerable: true, get: function () { return __importDefault(toQueryString_1).default; } });
|
|
14
|
-
var decodeHTML_1 = require("./decodeHTML");
|
|
15
|
-
Object.defineProperty(exports, "decodeHTML", { enumerable: true, get: function () { return __importDefault(decodeHTML_1).default; } });
|
|
16
10
|
var getConfigs_1 = require("./getConfigs");
|
|
17
11
|
Object.defineProperty(exports, "NEXTEMOS_CONFIG", { enumerable: true, get: function () { return __importDefault(getConfigs_1).default; } });
|
|
@@ -8,14 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.KeycloakService = void 0;
|
|
16
13
|
const __1 = require("../..");
|
|
17
|
-
const getConfigs_1 = __importDefault(require("../../helpers/getConfigs"));
|
|
18
|
-
const { KEYCLOAK } = getConfigs_1.default;
|
|
19
14
|
const createUrlEncodedBody = (plainBodyObject) => {
|
|
20
15
|
const encodedBody = Object.entries(plainBodyObject)
|
|
21
16
|
.map(([key, value]) => {
|
|
@@ -26,24 +21,24 @@ const createUrlEncodedBody = (plainBodyObject) => {
|
|
|
26
21
|
};
|
|
27
22
|
// Environment servisi
|
|
28
23
|
exports.KeycloakService = {
|
|
29
|
-
ServiceUrl:
|
|
30
|
-
Token: function (
|
|
31
|
-
return __awaiter(this,
|
|
24
|
+
ServiceUrl: "https://identity.proj-e.com",
|
|
25
|
+
Token: function (_a, options_1) {
|
|
26
|
+
return __awaiter(this, arguments, void 0, function* ({ realm, client_id, client_secret, grant_type }, options) {
|
|
32
27
|
// request
|
|
33
28
|
const encodedBody = createUrlEncodedBody({
|
|
34
|
-
realm
|
|
35
|
-
client_id
|
|
36
|
-
client_secret
|
|
37
|
-
grant_type
|
|
29
|
+
realm,
|
|
30
|
+
client_id,
|
|
31
|
+
client_secret,
|
|
32
|
+
grant_type,
|
|
38
33
|
});
|
|
39
|
-
return yield (0, __1.fetchRequest)().post(`${this.ServiceUrl}/realms/${
|
|
34
|
+
return yield (0, __1.fetchRequest)().post(`${this.ServiceUrl}/realms/${realm}/protocol/openid-connect/token`, Object.assign(Object.assign({}, options), { headers: {
|
|
40
35
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
41
36
|
}, body: encodedBody }));
|
|
42
37
|
});
|
|
43
38
|
},
|
|
44
|
-
GetConfigurations: function () {
|
|
45
|
-
return __awaiter(this,
|
|
46
|
-
return yield (0, __1.fetchRequest)().get(`${this.ServiceUrl}/realms/${
|
|
39
|
+
GetConfigurations: function (_a) {
|
|
40
|
+
return __awaiter(this, arguments, void 0, function* ({ realm }) {
|
|
41
|
+
return yield (0, __1.fetchRequest)().get(`${this.ServiceUrl}/realms/${realm}`, {
|
|
47
42
|
headers: {
|
|
48
43
|
"Content-Type": "application/json",
|
|
49
44
|
},
|
|
@@ -8,6 +8,8 @@ export interface IKeycloakTokenRequest {
|
|
|
8
8
|
}
|
|
9
9
|
export interface IKeycloakService {
|
|
10
10
|
ServiceUrl: string;
|
|
11
|
-
Token: (options?: IRequestInit) => Promise<IApiResponse<IKeycloakTokenResponse>>;
|
|
12
|
-
GetConfigurations: (
|
|
11
|
+
Token: ({ realm, client_id, client_secret, grant_type }: IKeycloakTokenRequest, options?: IRequestInit) => Promise<IApiResponse<IKeycloakTokenResponse>>;
|
|
12
|
+
GetConfigurations: ({ realm, }: {
|
|
13
|
+
realm: string;
|
|
14
|
+
}) => Promise<IApiResponse<IKeycloakConfigurationsResponse>>;
|
|
13
15
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nextemos",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.3.1",
|
|
4
4
|
"description": "For helpers and hooks used in NextJS projects",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -32,7 +32,5 @@
|
|
|
32
32
|
"typescript",
|
|
33
33
|
"nextemos"
|
|
34
34
|
],
|
|
35
|
-
"dependencies": {
|
|
36
|
-
"html-entities": "^2.5.2"
|
|
37
|
-
}
|
|
35
|
+
"dependencies": {}
|
|
38
36
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const html_entities_1 = require("html-entities");
|
|
4
|
-
const decodeHTML = (html) => {
|
|
5
|
-
return isHTML(html) ? html : (0, html_entities_1.decode)(html);
|
|
6
|
-
};
|
|
7
|
-
const isHTML = (string) => {
|
|
8
|
-
const htmlPattern = /<\/?[a-z][\s\S]*>/i;
|
|
9
|
-
return htmlPattern.test(string);
|
|
10
|
-
};
|
|
11
|
-
exports.default = decodeHTML;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* toIntArray Function
|
|
3
|
-
*
|
|
4
|
-
* @description
|
|
5
|
-
* A function that converts a string of numbers separated by a specified separator into an array of integers.
|
|
6
|
-
*
|
|
7
|
-
* @param {string} str - The input string containing numbers separated by the specified separator.
|
|
8
|
-
* @param {string} [separator=','] - The separator used to split the input string. Default is ','.
|
|
9
|
-
* @returns {Array} An array of integers extracted from the input string.
|
|
10
|
-
*/
|
|
11
|
-
declare function toIntArray(str: string, separator?: string): number[];
|
|
12
|
-
export default toIntArray;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* toIntArray Function
|
|
5
|
-
*
|
|
6
|
-
* @description
|
|
7
|
-
* A function that converts a string of numbers separated by a specified separator into an array of integers.
|
|
8
|
-
*
|
|
9
|
-
* @param {string} str - The input string containing numbers separated by the specified separator.
|
|
10
|
-
* @param {string} [separator=','] - The separator used to split the input string. Default is ','.
|
|
11
|
-
* @returns {Array} An array of integers extracted from the input string.
|
|
12
|
-
*/
|
|
13
|
-
function toIntArray(str, separator = ',') {
|
|
14
|
-
// Split the input string using the specified separator
|
|
15
|
-
const numbers = str.split(separator);
|
|
16
|
-
// Convert the array of strings to an array of integers
|
|
17
|
-
const intArray = numbers.map((num) => parseInt(num, 10));
|
|
18
|
-
return intArray;
|
|
19
|
-
}
|
|
20
|
-
exports.default = toIntArray;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts a given object into a query string format.
|
|
3
|
-
*
|
|
4
|
-
* @param obj - The object to be converted into a query string.
|
|
5
|
-
* @returns {string} - The query string representation of the object.
|
|
6
|
-
*/
|
|
7
|
-
declare const toQueryString: (obj: Record<string, any>) => string;
|
|
8
|
-
export default toQueryString;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Converts a given object into a query string format.
|
|
5
|
-
*
|
|
6
|
-
* @param obj - The object to be converted into a query string.
|
|
7
|
-
* @returns {string} - The query string representation of the object.
|
|
8
|
-
*/
|
|
9
|
-
const toQueryString = (obj) => {
|
|
10
|
-
if (Object.keys(obj).length === 0)
|
|
11
|
-
return '';
|
|
12
|
-
const queryString = [];
|
|
13
|
-
for (const key in obj) {
|
|
14
|
-
if (obj.hasOwnProperty(key)) {
|
|
15
|
-
const value = encodeURIComponent(obj[key]);
|
|
16
|
-
queryString.push(`${encodeURIComponent(key)}=${value}`);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return queryString.join('&');
|
|
20
|
-
};
|
|
21
|
-
exports.default = toQueryString;
|