zubbl-sdk 1.1.3 → 1.1.4

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.
@@ -5,17 +5,23 @@ var axios = require('axios');
5
5
  let config = {
6
6
  apiKey: null,
7
7
  tenantId: null,
8
- appId: null
8
+ appId: null,
9
+ baseUrl: "https://api.zubbl.com/api" // ✅ Default to Worker-routed path
9
10
  };
10
11
 
11
12
  /**
12
13
  * Initialize SDK with API credentials.
13
14
  */
14
- function init({ apiKey, tenantId, appId }) {
15
+ function init({ apiKey, tenantId, appId, baseUrl }) {
15
16
  if (!apiKey || !tenantId || !appId) {
16
17
  throw new Error("apiKey, tenantId, and appId are required");
17
18
  }
18
- config = { apiKey, tenantId, appId };
19
+ config = {
20
+ apiKey,
21
+ tenantId,
22
+ appId,
23
+ baseUrl: baseUrl || "https://api.zubbl.com/api" // ✅ Override if provided
24
+ };
19
25
  }
20
26
 
21
27
  /**
@@ -37,7 +43,7 @@ async function identifyUser({ email, name }) {
37
43
  };
38
44
 
39
45
  const response = await axios.post(
40
- "https://api.zubbl.com/sdk/identify",
46
+ `${config.baseUrl}/sdk/identify`, // ✅ Now dynamic
41
47
  { email, name },
42
48
  { headers }
43
49
  );
@@ -45,7 +51,6 @@ async function identifyUser({ email, name }) {
45
51
  console.log("[ZUBBL SDK] identifyUser response:", response.data);
46
52
  return response.data;
47
53
  } catch (err) {
48
- // Forward server message for easier debugging
49
54
  if (err.response && err.response.data) {
50
55
  console.error("[ZUBBL SDK] identifyUser error:", err.response.data);
51
56
  throw err.response.data;
@@ -72,7 +77,7 @@ async function getTiles({ external_user_id }) {
72
77
  };
73
78
 
74
79
  const response = await axios.get(
75
- `https://api.zubbl.com/sdk/external-users/${external_user_id}/tiles`,
80
+ `${config.baseUrl}/sdk/external-users/${external_user_id}/tiles`, // ✅ Now dynamic
76
81
  { headers }
77
82
  );
78
83
 
@@ -3,17 +3,23 @@ import axios from 'axios';
3
3
  let config = {
4
4
  apiKey: null,
5
5
  tenantId: null,
6
- appId: null
6
+ appId: null,
7
+ baseUrl: "https://api.zubbl.com/api" // ✅ Default to Worker-routed path
7
8
  };
8
9
 
9
10
  /**
10
11
  * Initialize SDK with API credentials.
11
12
  */
12
- function init({ apiKey, tenantId, appId }) {
13
+ function init({ apiKey, tenantId, appId, baseUrl }) {
13
14
  if (!apiKey || !tenantId || !appId) {
14
15
  throw new Error("apiKey, tenantId, and appId are required");
15
16
  }
16
- config = { apiKey, tenantId, appId };
17
+ config = {
18
+ apiKey,
19
+ tenantId,
20
+ appId,
21
+ baseUrl: baseUrl || "https://api.zubbl.com/api" // ✅ Override if provided
22
+ };
17
23
  }
18
24
 
19
25
  /**
@@ -35,7 +41,7 @@ async function identifyUser({ email, name }) {
35
41
  };
36
42
 
37
43
  const response = await axios.post(
38
- "https://api.zubbl.com/sdk/identify",
44
+ `${config.baseUrl}/sdk/identify`, // ✅ Now dynamic
39
45
  { email, name },
40
46
  { headers }
41
47
  );
@@ -43,7 +49,6 @@ async function identifyUser({ email, name }) {
43
49
  console.log("[ZUBBL SDK] identifyUser response:", response.data);
44
50
  return response.data;
45
51
  } catch (err) {
46
- // Forward server message for easier debugging
47
52
  if (err.response && err.response.data) {
48
53
  console.error("[ZUBBL SDK] identifyUser error:", err.response.data);
49
54
  throw err.response.data;
@@ -70,7 +75,7 @@ async function getTiles({ external_user_id }) {
70
75
  };
71
76
 
72
77
  const response = await axios.get(
73
- `https://api.zubbl.com/sdk/external-users/${external_user_id}/tiles`,
78
+ `${config.baseUrl}/sdk/external-users/${external_user_id}/tiles`, // ✅ Now dynamic
74
79
  { headers }
75
80
  );
76
81
 
@@ -7,17 +7,23 @@
7
7
  let config = {
8
8
  apiKey: null,
9
9
  tenantId: null,
10
- appId: null
10
+ appId: null,
11
+ baseUrl: "https://api.zubbl.com/api" // ✅ Default to Worker-routed path
11
12
  };
12
13
 
13
14
  /**
14
15
  * Initialize SDK with API credentials.
15
16
  */
16
- function init({ apiKey, tenantId, appId }) {
17
+ function init({ apiKey, tenantId, appId, baseUrl }) {
17
18
  if (!apiKey || !tenantId || !appId) {
18
19
  throw new Error("apiKey, tenantId, and appId are required");
19
20
  }
20
- config = { apiKey, tenantId, appId };
21
+ config = {
22
+ apiKey,
23
+ tenantId,
24
+ appId,
25
+ baseUrl: baseUrl || "https://api.zubbl.com/api" // ✅ Override if provided
26
+ };
21
27
  }
22
28
 
23
29
  /**
@@ -39,7 +45,7 @@
39
45
  };
40
46
 
41
47
  const response = await axios.post(
42
- "https://api.zubbl.com/sdk/identify",
48
+ `${config.baseUrl}/sdk/identify`, // ✅ Now dynamic
43
49
  { email, name },
44
50
  { headers }
45
51
  );
@@ -47,7 +53,6 @@
47
53
  console.log("[ZUBBL SDK] identifyUser response:", response.data);
48
54
  return response.data;
49
55
  } catch (err) {
50
- // Forward server message for easier debugging
51
56
  if (err.response && err.response.data) {
52
57
  console.error("[ZUBBL SDK] identifyUser error:", err.response.data);
53
58
  throw err.response.data;
@@ -74,7 +79,7 @@
74
79
  };
75
80
 
76
81
  const response = await axios.get(
77
- `https://api.zubbl.com/sdk/external-users/${external_user_id}/tiles`,
82
+ `${config.baseUrl}/sdk/external-users/${external_user_id}/tiles`, // ✅ Now dynamic
78
83
  { headers }
79
84
  );
80
85
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zubbl-sdk",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "Zubbl SDK for secure policy enforcement (browser, Node, universal)",
5
5
  "main": "dist/zubbl-sdk.cjs.js",
6
6
  "module": "dist/zubbl-sdk.esm.js",