nextemos 6.3.0 → 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.
@@ -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 === 'object' && !Array.isArray(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;
@@ -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: KEYCLOAK.URL,
30
- Token: function (options) {
31
- return __awaiter(this, void 0, void 0, function* () {
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: KEYCLOAK.REALM,
35
- client_id: KEYCLOAK.CLIENT_ID,
36
- client_secret: KEYCLOAK.CLIENT_SECRET,
37
- grant_type: KEYCLOAK.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/${KEYCLOAK.REALM}/protocol/openid-connect/token`, Object.assign(Object.assign({}, options), { headers: {
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, void 0, void 0, function* () {
46
- return yield (0, __1.fetchRequest)().get(`${this.ServiceUrl}/realms/${KEYCLOAK.REALM}`, {
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: () => Promise<IApiResponse<IKeycloakConfigurationsResponse>>;
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.0",
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",