nextemos 4.4.2 → 4.4.3

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.
@@ -11,6 +11,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.KeycloakService = void 0;
13
13
  const __1 = require("../..");
14
+ const createUrlEncodedBody = (plainBodyObject) => {
15
+ const encodedBody = Object.entries(plainBodyObject)
16
+ .map(([key, value]) => {
17
+ return encodeURIComponent(key) + '=' + encodeURIComponent(value);
18
+ })
19
+ .join('&');
20
+ return encodedBody;
21
+ };
14
22
  // Environment servisi
15
23
  exports.KeycloakService = {
16
24
  ServiceUrl: "https://keycloak.proj-e.com",
@@ -25,5 +33,14 @@ exports.KeycloakService = {
25
33
  'Content-Type': 'application/x-www-form-urlencoded',
26
34
  }, body: urlencoded }));
27
35
  });
36
+ },
37
+ MobileToken: function (data, options) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ // request
40
+ const encodedBody = createUrlEncodedBody(Object.assign({}, data));
41
+ return yield (0, __1.fetchRequest)().post(`${this.ServiceUrl}/realms/{REALM_KEY}/protocol/openid-connect/token`.replace(/{REALM_KEY}/g, data.project), Object.assign(Object.assign({}, options), { headers: {
42
+ 'Content-Type': 'application/x-www-form-urlencoded',
43
+ }, body: encodedBody }));
44
+ });
28
45
  }
29
46
  };
@@ -10,4 +10,5 @@ export interface IKeycloakTokenRequest {
10
10
  export interface IKeycloakService {
11
11
  ServiceUrl: string;
12
12
  Token: (data: IKeycloakTokenRequest, options?: IRequestInit) => Promise<IApiResponse<IKeycloakTokenResponse>>;
13
+ MobileToken: (data: IKeycloakTokenRequest, options?: IRequestInit) => Promise<IApiResponse<IKeycloakTokenResponse>>;
13
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nextemos",
3
- "version": "4.4.2",
3
+ "version": "4.4.3",
4
4
  "description": "For helpers and hooks used in NextJS projects",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/index.d.ts",