@soyio/soyio-widget 2.4.0 → 2.4.2
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/README.md +2 -2
- package/dist/index.js +75 -71
- package/dist/index.umd.cjs +6 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -319,7 +319,7 @@ The `onEvent` follows the following format:
|
|
|
319
319
|
{
|
|
320
320
|
eventName: 'CONSENT_CHECKBOX_CHANGE',
|
|
321
321
|
isSelected: boolean
|
|
322
|
-
|
|
322
|
+
actionToken: string,
|
|
323
323
|
}
|
|
324
324
|
```
|
|
325
325
|
|
|
@@ -327,7 +327,7 @@ The `onEvent` follows the following format:
|
|
|
327
327
|
|
|
328
328
|
- **`consentTemplateId`**: Identifier of consent template. It must start with `'constpl_'`.
|
|
329
329
|
- **`isSelected`**: Boolean value indicating whether the consent checkbox is selected or not.
|
|
330
|
-
- **`
|
|
330
|
+
- **`actionToken`**: token containing necessary information for creation of the consent commit. [Learn more](https://docs.soyio.id/docs/api/resources/create-consent-request).
|
|
331
331
|
|
|
332
332
|
## TypeScript
|
|
333
333
|
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
var R = Object.defineProperty;
|
|
2
|
-
var C = (
|
|
3
|
-
var u = (
|
|
4
|
-
if (!
|
|
2
|
+
var C = (e, t, n) => t in e ? R(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var u = (e, t, n) => (C(e, typeof t != "symbol" ? t + "" : t, n), n), N = (e, t, n) => {
|
|
4
|
+
if (!t.has(e))
|
|
5
5
|
throw TypeError("Cannot " + n);
|
|
6
6
|
};
|
|
7
|
-
var w = (
|
|
8
|
-
if (
|
|
7
|
+
var w = (e, t, n) => {
|
|
8
|
+
if (t.has(e))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
|
-
|
|
10
|
+
t instanceof WeakSet ? t.add(e) : t.set(e, n);
|
|
11
11
|
};
|
|
12
|
-
var I = (
|
|
13
|
-
const v = "soyio-consent-iframe",
|
|
12
|
+
var I = (e, t, n) => (N(e, t, "access private method"), n);
|
|
13
|
+
const v = "soyio-consent-iframe", g = "https://app.soyio.id", y = "https://sandbox.soyio.id", U = [
|
|
14
14
|
"DISCLOSURE_REQUEST_SUCCESSFUL",
|
|
15
15
|
"IDENTITY_REGISTERED",
|
|
16
16
|
"IDENTITY_SIGNATURE",
|
|
@@ -19,114 +19,118 @@ const v = "soyio-consent-iframe", T = "https://app.soyio.id", _ = "https://sandb
|
|
|
19
19
|
"REJECTED_SIGNATURE"
|
|
20
20
|
], D = "WIDGET_CLOSED";
|
|
21
21
|
function H() {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
function
|
|
26
|
-
const
|
|
27
|
-
if (!
|
|
28
|
-
throw new Error(`Iframe div container with id '${
|
|
29
|
-
if (
|
|
30
|
-
throw new Error(`Iframe container with id '${
|
|
31
|
-
const n =
|
|
22
|
+
const e = document.getElementById(v);
|
|
23
|
+
e && (console.warn("ConsentBox iframe already exists. Removing existing before mounting new one."), e.remove());
|
|
24
|
+
}
|
|
25
|
+
function x(e) {
|
|
26
|
+
const t = document.querySelector(e);
|
|
27
|
+
if (!t)
|
|
28
|
+
throw new Error(`Iframe div container with id '${e}' not found`);
|
|
29
|
+
if (t.tagName.toLowerCase() !== "div")
|
|
30
|
+
throw new Error(`Iframe container with id '${e}' must be a <div> element`);
|
|
31
|
+
const n = t;
|
|
32
32
|
return n.style.position = "relative", n.style.cssText += `
|
|
33
33
|
padding: 0 !important;
|
|
34
34
|
margin: 0 !important;
|
|
35
|
-
display:
|
|
35
|
+
display: flex !important;
|
|
36
|
+
justify-content: center !important;
|
|
37
|
+
align-items: center !important;
|
|
36
38
|
border: none !important;
|
|
37
39
|
transition: height 0.35s !important;
|
|
38
40
|
opacity: 1 !important;
|
|
39
41
|
`, n;
|
|
40
42
|
}
|
|
41
|
-
function
|
|
42
|
-
const
|
|
43
|
-
return
|
|
43
|
+
function O(e) {
|
|
44
|
+
const t = document.createElement("iframe");
|
|
45
|
+
return t.id = v, t.src = e, t.style.cssText += `
|
|
44
46
|
width: 100% !important;
|
|
47
|
+
min-width: 25rem !important;
|
|
48
|
+
max-width: 36rem !important;
|
|
45
49
|
border: none !important;
|
|
46
|
-
height:
|
|
50
|
+
height: 120px !important;
|
|
47
51
|
overflow: hidden !important;
|
|
48
52
|
opacity: 1;
|
|
49
53
|
transition: height 0.35s,
|
|
50
54
|
opacity 0.4s 0.1s;
|
|
51
|
-
`,
|
|
55
|
+
`, t;
|
|
52
56
|
}
|
|
53
|
-
function
|
|
54
|
-
const
|
|
55
|
-
return `${
|
|
57
|
+
function L(e) {
|
|
58
|
+
const t = e.isSandbox ?? !1;
|
|
59
|
+
return `${e.developmentUrl || (t ? y : g)}/embed/consents/${e.consentTemplateId}`;
|
|
56
60
|
}
|
|
57
61
|
const A = "IFRAME_EVENT", $ = "IFRAME_HEIGHT_CHANGE";
|
|
58
62
|
let a = null, l = null;
|
|
59
|
-
function
|
|
63
|
+
function T() {
|
|
60
64
|
a == null || a.cancel(), a = null, l == null || l.cancel(), l = null;
|
|
61
65
|
}
|
|
62
|
-
async function G(
|
|
63
|
-
const { onEvent:
|
|
64
|
-
|
|
66
|
+
async function G(e) {
|
|
67
|
+
const { onEvent: t, onHeightChange: n } = e, o = await import("./index-yZw-yxuV.js").then((i) => i.i);
|
|
68
|
+
T(), a = o.on(A, async (i) => {
|
|
65
69
|
const s = i.data;
|
|
66
|
-
|
|
70
|
+
t(s);
|
|
67
71
|
}), l = o.on($, async (i) => {
|
|
68
72
|
const s = i.data;
|
|
69
73
|
n(s.height);
|
|
70
74
|
});
|
|
71
75
|
}
|
|
72
76
|
class z {
|
|
73
|
-
constructor(
|
|
77
|
+
constructor(t) {
|
|
74
78
|
u(this, "options");
|
|
75
79
|
u(this, "iframe", null);
|
|
76
|
-
this.options =
|
|
80
|
+
this.options = t, G({
|
|
77
81
|
onEvent: this.options.onEvent.bind(this),
|
|
78
82
|
onHeightChange: this.handleHeightChange.bind(this)
|
|
79
83
|
});
|
|
80
84
|
}
|
|
81
|
-
handleHeightChange(
|
|
82
|
-
this.iframe && (this.iframe.style.height = `${
|
|
85
|
+
handleHeightChange(t) {
|
|
86
|
+
this.iframe && (this.iframe.style.height = `${t}px`);
|
|
83
87
|
}
|
|
84
|
-
mount(
|
|
88
|
+
mount(t) {
|
|
85
89
|
H();
|
|
86
|
-
const n =
|
|
87
|
-
return this.iframe =
|
|
90
|
+
const n = x(t), o = L(this.options);
|
|
91
|
+
return this.iframe = O(o), n.appendChild(this.iframe), this;
|
|
88
92
|
}
|
|
89
93
|
unmount() {
|
|
90
|
-
|
|
94
|
+
T(), this.iframe && (this.iframe.remove(), this.iframe = null);
|
|
91
95
|
}
|
|
92
96
|
}
|
|
93
97
|
const J = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
94
98
|
__proto__: null
|
|
95
99
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
96
|
-
function M(
|
|
97
|
-
let
|
|
98
|
-
return "disclosureRequestId" in
|
|
100
|
+
function M(e) {
|
|
101
|
+
let t = "widget/";
|
|
102
|
+
return "disclosureRequestId" in e.configProps ? t += ["disclosures", e.configProps.disclosureRequestId].join("/") : t += e.request, t;
|
|
99
103
|
}
|
|
100
|
-
function W(
|
|
101
|
-
const
|
|
104
|
+
function W(e) {
|
|
105
|
+
const t = e.isSandbox ?? !1, n = e.developmentUrl || (t ? y : g), o = Object.entries(e.configProps).filter(([s, c]) => c || s === "disclosureRequestId").map(([s, c]) => `${s}=${encodeURIComponent(c)}`).join("&"), i = M(e);
|
|
102
106
|
return `${n}/${i}?sdk=web&${o}`;
|
|
103
107
|
}
|
|
104
108
|
const F = !!(typeof window < "u" && window.document && window.document.createElement);
|
|
105
|
-
let r = null,
|
|
106
|
-
function
|
|
107
|
-
r && !r.closed && r.focus(),
|
|
109
|
+
let r = null, f = null;
|
|
110
|
+
function E(e = null) {
|
|
111
|
+
r && !r.closed && r.focus(), e == null || e.preventDefault();
|
|
108
112
|
}
|
|
109
113
|
function h() {
|
|
110
|
-
document.body.style.filter = "", document.body.removeEventListener("click",
|
|
114
|
+
document.body.style.filter = "", document.body.removeEventListener("click", E);
|
|
111
115
|
}
|
|
112
116
|
function V() {
|
|
113
|
-
|
|
114
|
-
(!r || r.closed) && (
|
|
117
|
+
f = setInterval(() => {
|
|
118
|
+
(!r || r.closed) && (f && clearInterval(f), h());
|
|
115
119
|
}, 500);
|
|
116
120
|
}
|
|
117
|
-
function
|
|
118
|
-
const
|
|
119
|
-
document.body.style.filter = "blur(5px)", document.body.addEventListener("click",
|
|
120
|
-
|
|
121
|
+
function j(e) {
|
|
122
|
+
const t = W(e), n = 420, o = 720, i = window.screenLeft !== void 0 ? window.screenLeft : window.screenX, s = window.screenTop !== void 0 ? window.screenTop : window.screenY, c = window.innerWidth || document.documentElement.clientWidth || window.screen.width, P = window.innerHeight || document.documentElement.clientHeight || window.screen.height, p = c / window.screen.availWidth, S = (c - n) / 2 / p + i, b = (P - o) / 2 / p + s;
|
|
123
|
+
document.body.style.filter = "blur(5px)", document.body.addEventListener("click", E), r = window.open(
|
|
124
|
+
t,
|
|
121
125
|
"Soyio",
|
|
122
126
|
`scrollbars=yes,
|
|
123
127
|
width=${n},
|
|
124
128
|
height=${o},
|
|
125
|
-
top=${
|
|
126
|
-
left=${
|
|
127
|
-
),
|
|
129
|
+
top=${b},
|
|
130
|
+
left=${S}`
|
|
131
|
+
), E(), V();
|
|
128
132
|
}
|
|
129
|
-
function
|
|
133
|
+
function k() {
|
|
130
134
|
r && (r.close(), r = null), h();
|
|
131
135
|
}
|
|
132
136
|
const q = "WIDGET_EVENT";
|
|
@@ -134,27 +138,27 @@ let d = null;
|
|
|
134
138
|
function B() {
|
|
135
139
|
d && (d.cancel(), d = null);
|
|
136
140
|
}
|
|
137
|
-
async function X(
|
|
138
|
-
const { onEvent:
|
|
141
|
+
async function X(e) {
|
|
142
|
+
const { onEvent: t } = e, n = await import("./index-yZw-yxuV.js").then((o) => o.i);
|
|
139
143
|
d && B(), d = n.on(q, async (o) => {
|
|
140
|
-
|
|
144
|
+
t(o.data), U.includes(o.data.eventName) ? k() : o.data.eventName === D && h();
|
|
141
145
|
});
|
|
142
146
|
}
|
|
143
|
-
function Y(
|
|
144
|
-
X(
|
|
147
|
+
function Y(e) {
|
|
148
|
+
X(e);
|
|
145
149
|
}
|
|
146
|
-
var
|
|
150
|
+
var m, _;
|
|
147
151
|
class Q {
|
|
148
|
-
constructor(
|
|
149
|
-
w(this,
|
|
152
|
+
constructor(t) {
|
|
153
|
+
w(this, m);
|
|
150
154
|
u(this, "onEvent");
|
|
151
|
-
this.onEvent =
|
|
152
|
-
onEvent: I(this,
|
|
155
|
+
this.onEvent = t.onEvent, F && (j(t), Y({
|
|
156
|
+
onEvent: I(this, m, _).bind(this)
|
|
153
157
|
}));
|
|
154
158
|
}
|
|
155
159
|
}
|
|
156
|
-
|
|
157
|
-
this.onEvent(
|
|
160
|
+
m = new WeakSet(), _ = function(t) {
|
|
161
|
+
this.onEvent(t);
|
|
158
162
|
};
|
|
159
163
|
export {
|
|
160
164
|
z as ConsentBox,
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
(function(R,N){typeof exports=="object"&&typeof module<"u"?N(exports):typeof define=="function"&&define.amd?define(["exports"],N):(R=typeof globalThis<"u"?globalThis:R||self,N(R["soyio-widget"]={}))})(this,function(R){"use strict";var Pt=Object.defineProperty;var It=(R,N,M)=>N in R?Pt(R,N,{enumerable:!0,configurable:!0,writable:!0,value:M}):R[N]=M;var Pn=(R,N,M)=>(It(R,typeof N!="symbol"?N+"":N,M),M),Ot=(R,N,M)=>{if(!N.has(R))throw TypeError("Cannot "+M)};var Ie=(R,N,M)=>{if(N.has(R))throw TypeError("Cannot add the same private member more than once");N instanceof WeakSet?N.add(R):N.set(R,M)};var Oe=(R,N,M)=>(Ot(R,N,"access private method"),M);var mn,De;function N(v,W){for(var A=0;A<W.length;A++){const p=W[A];if(typeof p!="string"&&!Array.isArray(p)){for(const m in p)if(m!=="default"&&!(m in v)){const w=Object.getOwnPropertyDescriptor(p,m);w&&Object.defineProperty(v,m,w.get?w:{enumerable:!0,get:()=>p[m]})}}}return Object.freeze(Object.defineProperty(v,Symbol.toStringTag,{value:"Module"}))}const M="soyio-consent-iframe",Un="https://app.soyio.id",Bn="https://sandbox.soyio.id",Ae=["DISCLOSURE_REQUEST_SUCCESSFUL","IDENTITY_REGISTERED","IDENTITY_SIGNATURE","UNEXPECTED_ERROR","DENIED_CAMERA_PERMISSION","REJECTED_SIGNATURE"],Re="WIDGET_CLOSED",Ne=420,Te=720,Ce=500;function je(){const v=document.getElementById(M);v&&(console.warn("ConsentBox iframe already exists. Removing existing before mounting new one."),v.remove())}function ze(v){const W=document.querySelector(v);if(!W)throw new Error(`Iframe div container with id '${v}' not found`);if(W.tagName.toLowerCase()!=="div")throw new Error(`Iframe container with id '${v}' must be a <div> element`);const A=W;return A.style.position="relative",A.style.cssText+=`
|
|
2
2
|
padding: 0 !important;
|
|
3
3
|
margin: 0 !important;
|
|
4
|
-
display:
|
|
4
|
+
display: flex !important;
|
|
5
|
+
justify-content: center !important;
|
|
6
|
+
align-items: center !important;
|
|
5
7
|
border: none !important;
|
|
6
8
|
transition: height 0.35s !important;
|
|
7
9
|
opacity: 1 !important;
|
|
8
10
|
`,A}function Me(v){const W=document.createElement("iframe");return W.id=M,W.src=v,W.style.cssText+=`
|
|
9
11
|
width: 100% !important;
|
|
12
|
+
min-width: 25rem !important;
|
|
13
|
+
max-width: 36rem !important;
|
|
10
14
|
border: none !important;
|
|
11
|
-
height:
|
|
15
|
+
height: 120px !important;
|
|
12
16
|
overflow: hidden !important;
|
|
13
17
|
opacity: 1;
|
|
14
18
|
transition: height 0.35s,
|