zubbl-sdk 1.0.2 → 1.0.5
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/dist/zubbl-sdk.cjs.js +28 -45
- package/dist/zubbl-sdk.esm.js +26 -45
- package/dist/zubbl-sdk.umd.js +32 -49
- package/package.json +2 -2
package/dist/zubbl-sdk.cjs.js
CHANGED
|
@@ -2,73 +2,56 @@
|
|
|
2
2
|
|
|
3
3
|
var axios = require('axios');
|
|
4
4
|
|
|
5
|
+
// src/index.js
|
|
6
|
+
|
|
5
7
|
let config = {
|
|
6
|
-
apiKey:
|
|
7
|
-
tenantId:
|
|
8
|
-
appId:
|
|
8
|
+
apiKey: null,
|
|
9
|
+
tenantId: null,
|
|
10
|
+
appId: null
|
|
9
11
|
};
|
|
10
12
|
|
|
11
13
|
function init({ apiKey, tenantId, appId }) {
|
|
14
|
+
if (!apiKey || !tenantId || !appId) {
|
|
15
|
+
throw new Error("apiKey, tenantId, and appId are required");
|
|
16
|
+
}
|
|
12
17
|
config = { apiKey, tenantId, appId };
|
|
13
18
|
}
|
|
14
19
|
|
|
15
20
|
async function identifyUser({ email, name }) {
|
|
21
|
+
if (!config.apiKey || !config.tenantId || !config.appId) {
|
|
22
|
+
throw new Error("Zubbl SDK not initialized");
|
|
23
|
+
}
|
|
16
24
|
if (!email) throw new Error("email is required");
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
name,
|
|
20
|
-
}, {
|
|
25
|
+
|
|
26
|
+
const response = await axios.post("https://api.zubbl.com/user/identify", { email, name }, {
|
|
21
27
|
headers: {
|
|
22
28
|
"x-api-key": config.apiKey,
|
|
23
29
|
"x-tenant-id": config.tenantId,
|
|
24
|
-
"x-app-id": config.appId
|
|
25
|
-
}
|
|
30
|
+
"x-app-id": config.appId
|
|
31
|
+
}
|
|
26
32
|
});
|
|
27
|
-
|
|
33
|
+
|
|
34
|
+
return response.data;
|
|
28
35
|
}
|
|
29
36
|
|
|
30
37
|
async function getTiles({ external_user_id }) {
|
|
38
|
+
if (!config.apiKey || !config.tenantId || !config.appId) {
|
|
39
|
+
throw new Error("Zubbl SDK not initialized");
|
|
40
|
+
}
|
|
31
41
|
if (!external_user_id) throw new Error("external_user_id is required");
|
|
32
|
-
|
|
42
|
+
|
|
43
|
+
const response = await axios.get("https://api.zubbl.com/user/tiles", {
|
|
33
44
|
headers: {
|
|
34
45
|
"x-api-key": config.apiKey,
|
|
35
46
|
"x-tenant-id": config.tenantId,
|
|
36
|
-
"x-app-id": config.appId
|
|
37
|
-
"x-user-id": external_user_id,
|
|
47
|
+
"x-app-id": config.appId
|
|
38
48
|
},
|
|
39
|
-
|
|
40
|
-
return res.data;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function attachRoutes(app) {
|
|
44
|
-
app.post("/identify", async (req, res) => {
|
|
45
|
-
try {
|
|
46
|
-
const { email, name } = req.body;
|
|
47
|
-
if (!email) return res.status(400).json({ error: "email required" });
|
|
48
|
-
const user = await identifyUser({ email, name });
|
|
49
|
-
res.json(user);
|
|
50
|
-
} catch (e) {
|
|
51
|
-
res.status(500).json({ error: e.message });
|
|
52
|
-
}
|
|
49
|
+
params: { external_user_id }
|
|
53
50
|
});
|
|
54
51
|
|
|
55
|
-
|
|
56
|
-
try {
|
|
57
|
-
const { external_user_id } = req.body;
|
|
58
|
-
if (!external_user_id) return res.status(400).json({ error: "external_user_id required" });
|
|
59
|
-
const tiles = await getTiles({ external_user_id });
|
|
60
|
-
res.json(tiles);
|
|
61
|
-
} catch (e) {
|
|
62
|
-
res.status(500).json({ error: e.message });
|
|
63
|
-
}
|
|
64
|
-
});
|
|
52
|
+
return response.data;
|
|
65
53
|
}
|
|
66
54
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
getTiles,
|
|
71
|
-
attachRoutes,
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
module.exports = index;
|
|
55
|
+
exports.getTiles = getTiles;
|
|
56
|
+
exports.identifyUser = identifyUser;
|
|
57
|
+
exports.init = init;
|
package/dist/zubbl-sdk.esm.js
CHANGED
|
@@ -1,72 +1,53 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
|
|
3
|
+
// src/index.js
|
|
4
|
+
|
|
3
5
|
let config = {
|
|
4
|
-
apiKey:
|
|
5
|
-
tenantId:
|
|
6
|
-
appId:
|
|
6
|
+
apiKey: null,
|
|
7
|
+
tenantId: null,
|
|
8
|
+
appId: null
|
|
7
9
|
};
|
|
8
10
|
|
|
9
11
|
function init({ apiKey, tenantId, appId }) {
|
|
12
|
+
if (!apiKey || !tenantId || !appId) {
|
|
13
|
+
throw new Error("apiKey, tenantId, and appId are required");
|
|
14
|
+
}
|
|
10
15
|
config = { apiKey, tenantId, appId };
|
|
11
16
|
}
|
|
12
17
|
|
|
13
18
|
async function identifyUser({ email, name }) {
|
|
19
|
+
if (!config.apiKey || !config.tenantId || !config.appId) {
|
|
20
|
+
throw new Error("Zubbl SDK not initialized");
|
|
21
|
+
}
|
|
14
22
|
if (!email) throw new Error("email is required");
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
name,
|
|
18
|
-
}, {
|
|
23
|
+
|
|
24
|
+
const response = await axios.post("https://api.zubbl.com/user/identify", { email, name }, {
|
|
19
25
|
headers: {
|
|
20
26
|
"x-api-key": config.apiKey,
|
|
21
27
|
"x-tenant-id": config.tenantId,
|
|
22
|
-
"x-app-id": config.appId
|
|
23
|
-
}
|
|
28
|
+
"x-app-id": config.appId
|
|
29
|
+
}
|
|
24
30
|
});
|
|
25
|
-
|
|
31
|
+
|
|
32
|
+
return response.data;
|
|
26
33
|
}
|
|
27
34
|
|
|
28
35
|
async function getTiles({ external_user_id }) {
|
|
36
|
+
if (!config.apiKey || !config.tenantId || !config.appId) {
|
|
37
|
+
throw new Error("Zubbl SDK not initialized");
|
|
38
|
+
}
|
|
29
39
|
if (!external_user_id) throw new Error("external_user_id is required");
|
|
30
|
-
|
|
40
|
+
|
|
41
|
+
const response = await axios.get("https://api.zubbl.com/user/tiles", {
|
|
31
42
|
headers: {
|
|
32
43
|
"x-api-key": config.apiKey,
|
|
33
44
|
"x-tenant-id": config.tenantId,
|
|
34
|
-
"x-app-id": config.appId
|
|
35
|
-
"x-user-id": external_user_id,
|
|
45
|
+
"x-app-id": config.appId
|
|
36
46
|
},
|
|
37
|
-
|
|
38
|
-
return res.data;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function attachRoutes(app) {
|
|
42
|
-
app.post("/identify", async (req, res) => {
|
|
43
|
-
try {
|
|
44
|
-
const { email, name } = req.body;
|
|
45
|
-
if (!email) return res.status(400).json({ error: "email required" });
|
|
46
|
-
const user = await identifyUser({ email, name });
|
|
47
|
-
res.json(user);
|
|
48
|
-
} catch (e) {
|
|
49
|
-
res.status(500).json({ error: e.message });
|
|
50
|
-
}
|
|
47
|
+
params: { external_user_id }
|
|
51
48
|
});
|
|
52
49
|
|
|
53
|
-
|
|
54
|
-
try {
|
|
55
|
-
const { external_user_id } = req.body;
|
|
56
|
-
if (!external_user_id) return res.status(400).json({ error: "external_user_id required" });
|
|
57
|
-
const tiles = await getTiles({ external_user_id });
|
|
58
|
-
res.json(tiles);
|
|
59
|
-
} catch (e) {
|
|
60
|
-
res.status(500).json({ error: e.message });
|
|
61
|
-
}
|
|
62
|
-
});
|
|
50
|
+
return response.data;
|
|
63
51
|
}
|
|
64
52
|
|
|
65
|
-
|
|
66
|
-
init,
|
|
67
|
-
identifyUser,
|
|
68
|
-
getTiles,
|
|
69
|
-
attachRoutes,
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export { index as default };
|
|
53
|
+
export { getTiles, identifyUser, init };
|
package/dist/zubbl-sdk.umd.js
CHANGED
|
@@ -1,78 +1,61 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ?
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['axios'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.ZubblSdk =
|
|
5
|
-
})(this, (function (axios) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('axios')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'axios'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ZubblSdk = {}, global.axios));
|
|
5
|
+
})(this, (function (exports, axios) { 'use strict';
|
|
6
|
+
|
|
7
|
+
// src/index.js
|
|
6
8
|
|
|
7
9
|
let config = {
|
|
8
|
-
apiKey:
|
|
9
|
-
tenantId:
|
|
10
|
-
appId:
|
|
10
|
+
apiKey: null,
|
|
11
|
+
tenantId: null,
|
|
12
|
+
appId: null
|
|
11
13
|
};
|
|
12
14
|
|
|
13
15
|
function init({ apiKey, tenantId, appId }) {
|
|
16
|
+
if (!apiKey || !tenantId || !appId) {
|
|
17
|
+
throw new Error("apiKey, tenantId, and appId are required");
|
|
18
|
+
}
|
|
14
19
|
config = { apiKey, tenantId, appId };
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
async function identifyUser({ email, name }) {
|
|
23
|
+
if (!config.apiKey || !config.tenantId || !config.appId) {
|
|
24
|
+
throw new Error("Zubbl SDK not initialized");
|
|
25
|
+
}
|
|
18
26
|
if (!email) throw new Error("email is required");
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
name,
|
|
22
|
-
}, {
|
|
27
|
+
|
|
28
|
+
const response = await axios.post("https://api.zubbl.com/user/identify", { email, name }, {
|
|
23
29
|
headers: {
|
|
24
30
|
"x-api-key": config.apiKey,
|
|
25
31
|
"x-tenant-id": config.tenantId,
|
|
26
|
-
"x-app-id": config.appId
|
|
27
|
-
}
|
|
32
|
+
"x-app-id": config.appId
|
|
33
|
+
}
|
|
28
34
|
});
|
|
29
|
-
|
|
35
|
+
|
|
36
|
+
return response.data;
|
|
30
37
|
}
|
|
31
38
|
|
|
32
39
|
async function getTiles({ external_user_id }) {
|
|
40
|
+
if (!config.apiKey || !config.tenantId || !config.appId) {
|
|
41
|
+
throw new Error("Zubbl SDK not initialized");
|
|
42
|
+
}
|
|
33
43
|
if (!external_user_id) throw new Error("external_user_id is required");
|
|
34
|
-
|
|
44
|
+
|
|
45
|
+
const response = await axios.get("https://api.zubbl.com/user/tiles", {
|
|
35
46
|
headers: {
|
|
36
47
|
"x-api-key": config.apiKey,
|
|
37
48
|
"x-tenant-id": config.tenantId,
|
|
38
|
-
"x-app-id": config.appId
|
|
39
|
-
"x-user-id": external_user_id,
|
|
49
|
+
"x-app-id": config.appId
|
|
40
50
|
},
|
|
41
|
-
|
|
42
|
-
return res.data;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function attachRoutes(app) {
|
|
46
|
-
app.post("/identify", async (req, res) => {
|
|
47
|
-
try {
|
|
48
|
-
const { email, name } = req.body;
|
|
49
|
-
if (!email) return res.status(400).json({ error: "email required" });
|
|
50
|
-
const user = await identifyUser({ email, name });
|
|
51
|
-
res.json(user);
|
|
52
|
-
} catch (e) {
|
|
53
|
-
res.status(500).json({ error: e.message });
|
|
54
|
-
}
|
|
51
|
+
params: { external_user_id }
|
|
55
52
|
});
|
|
56
53
|
|
|
57
|
-
|
|
58
|
-
try {
|
|
59
|
-
const { external_user_id } = req.body;
|
|
60
|
-
if (!external_user_id) return res.status(400).json({ error: "external_user_id required" });
|
|
61
|
-
const tiles = await getTiles({ external_user_id });
|
|
62
|
-
res.json(tiles);
|
|
63
|
-
} catch (e) {
|
|
64
|
-
res.status(500).json({ error: e.message });
|
|
65
|
-
}
|
|
66
|
-
});
|
|
54
|
+
return response.data;
|
|
67
55
|
}
|
|
68
56
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
getTiles,
|
|
73
|
-
attachRoutes,
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
return index;
|
|
57
|
+
exports.getTiles = getTiles;
|
|
58
|
+
exports.identifyUser = identifyUser;
|
|
59
|
+
exports.init = init;
|
|
77
60
|
|
|
78
61
|
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zubbl-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
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",
|
|
@@ -31,6 +31,6 @@
|
|
|
31
31
|
"rollup": "^4.2.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"
|
|
34
|
+
"axios": "^1.6.7"
|
|
35
35
|
}
|
|
36
36
|
}
|