@pronto-tools-and-more/network-process 3.17.0 → 4.0.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pronto-tools-and-more/network-process",
3
- "version": "3.17.0",
3
+ "version": "4.0.0",
4
4
  "description": "",
5
5
  "main": "src/networkProcessMain.js",
6
6
  "type": "module",
@@ -1,24 +1,22 @@
1
1
  import { VError } from "@lvce-editor/verror";
2
2
  import ky from "ky";
3
3
  import * as Assert from "../Assert/Assert.js";
4
- import * as GetXr from "../GetXr/GetXr.js";
5
4
 
6
- const getBodyJson = (userEmail, userPassword) => {
5
+ const getBodyFormData = (userEmail, userPassword) => {
7
6
  Assert.string(userEmail);
8
7
  Assert.string(userPassword);
9
- return {
10
- email: userEmail,
11
- password: userPassword,
12
- permanent: true,
13
- };
8
+ const formData = new URLSearchParams();
9
+ formData.set("client_id", "experience-builder");
10
+ formData.set("grant_type", "password");
11
+ formData.set("scope", "openid");
12
+ formData.set("username", userEmail);
13
+ formData.set("password", userPassword);
14
+ return formData;
14
15
  };
15
16
 
16
17
  const getHeaders = () => {
17
- const xr = GetXr.getXr();
18
18
  return {
19
- accept: "*/*",
20
- "content-type": "application/json",
21
- xr,
19
+ "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
22
20
  };
23
21
  };
24
22
 
@@ -30,14 +28,16 @@ const getHeaders = () => {
30
28
  export const login = async ({ loginUrl, userEmail, userPassword }) => {
31
29
  try {
32
30
  Assert.string(loginUrl);
33
- const body = getBodyJson(userEmail, userPassword);
31
+ const body = getBodyFormData(userEmail, userPassword);
34
32
  const headers = getHeaders();
35
33
  const response = await ky(loginUrl, {
36
- json: body,
34
+ body,
37
35
  method: "post",
38
36
  headers,
39
37
  });
40
- return response.json();
38
+ const result = await response.json();
39
+ console.log({ result });
40
+ return result;
41
41
  } catch (error) {
42
42
  // @ts-ignore
43
43
  if (error && error.name === "HTTPError") {