multicloud_rule_manager 1.1.66 → 1.1.67

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.
@@ -14,7 +14,7 @@ export default {
14
14
  // --- PRIMA CHIAMATA: token ---
15
15
  console.log("🔹 Inizio richiesta token...");
16
16
  const loginResp = await fetch(`https://login-eon-no-prod.bit2win.cloud/auth/realms/${cred.realm}/protocol/openid-connect/token`, {
17
- method: "POST",
17
+ method: "POST",
18
18
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
19
19
  body: new URLSearchParams({
20
20
  client_id: cred.clientId,
@@ -25,6 +25,7 @@ export default {
25
25
  })
26
26
  });
27
27
 
28
+
28
29
  const loginData = await loginResp.json(); // leggi direttamente JSON
29
30
  const access_token = loginData.access_token;
30
31
 
@@ -32,18 +33,23 @@ export default {
32
33
  throw new Error("Token non ricevuto nel campo 'access_token'");
33
34
  }
34
35
 
35
- const headers = {
36
- Authorization: `Bearer ${access_token}`,
37
- Accept: "application/json"
38
- };
39
36
 
37
+
38
+
40
39
  // =========================
41
40
  // 📦 PRODUCTS
42
41
  // =========================
43
42
  console.log(" Chiamo products");
44
43
  const productsResp = await fetch(
45
44
  `https://${cred.realm}.bit2win.cloud/api/data/v1/products/`,
46
- { headers }
45
+ {
46
+ method: "GET",
47
+ headers: {
48
+ "Authorization": `Bearer ${access_token}`,
49
+ "Accept": "application/json"
50
+ },
51
+ redirect: "manual"
52
+ }
47
53
  );
48
54
 
49
55
  const products = await productsResp.json();
@@ -63,7 +69,14 @@ export default {
63
69
  console.log(" Chiamo products structure");
64
70
  const structResp = await fetch(
65
71
  `https://${cred.realm}.bit2win.cloud/api/data/v1/products_structure/`,
66
- { headers }
72
+ {
73
+ method: "GET",
74
+ headers: {
75
+ "Authorization": `Bearer ${access_token}`,
76
+ "Accept": "application/json"
77
+ },
78
+ redirect: "manual"
79
+ }
67
80
  );
68
81
 
69
82
  const structure = await structResp.json();
@@ -94,8 +107,15 @@ export default {
94
107
  const getFamilies = async (productId) => {
95
108
  const resp = await fetch(
96
109
  `https://${cred.realm}.bit2win.cloud/api/catalog/v1/products/${productId}/families`,
97
- { headers }
98
- );
110
+ {
111
+ method: "GET",
112
+ headers: {
113
+ "Authorization": `Bearer ${access_token}`,
114
+ "Accept": "application/json"
115
+ },
116
+ redirect: "manual"
117
+ }
118
+ );
99
119
 
100
120
  const data = await resp.json();
101
121
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "multicloud_rule_manager",
3
- "version": "1.1.66",
3
+ "version": "1.1.67",
4
4
  "description": "CLI interna per retrieve/upload con token",
5
5
  "main": "index.js",
6
6
  "type": "module",