aesirx-analytics 2.3.6 → 2.4.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/README.md +2 -242
- package/dist/analytics.js +1 -23686
- package/dist/index.d.ts +5 -40
- package/dist/index.js +515 -432
- package/package.json +2 -16
- package/dist/Consent-A2R6PCLK.js +0 -803
- package/dist/ConsentCustom-LYMWYNRI.js +0 -1160
- package/dist/chunk-NKOHXSTE.js +0 -2510
- package/dist/chunk-UJC5773H.js +0 -11357
package/dist/Consent-A2R6PCLK.js
DELETED
@@ -1,803 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
BROWSER_WALLET,
|
3
|
-
Connect_default,
|
4
|
-
Ethereum_default,
|
5
|
-
LoadingStatus,
|
6
|
-
TermsComponent,
|
7
|
-
WALLET_CONNECT,
|
8
|
-
getWeb3ID,
|
9
|
-
useConsentStatus_default
|
10
|
-
} from "./chunk-UJC5773H.js";
|
11
|
-
import {
|
12
|
-
AnalyticsContext,
|
13
|
-
agreeConsents,
|
14
|
-
bg_default,
|
15
|
-
getConsents,
|
16
|
-
getMember,
|
17
|
-
getNonce,
|
18
|
-
getSignature,
|
19
|
-
getWalletNonce,
|
20
|
-
loadGtagScript,
|
21
|
-
loadGtmScript,
|
22
|
-
no_default,
|
23
|
-
privacy_default,
|
24
|
-
revokeConsents,
|
25
|
-
useTranslation,
|
26
|
-
verifySignature
|
27
|
-
} from "./chunk-NKOHXSTE.js";
|
28
|
-
|
29
|
-
// src/Components/Consent.tsx
|
30
|
-
import React, { Suspense, useContext, useEffect, useState } from "react";
|
31
|
-
import { Button, Form } from "react-bootstrap";
|
32
|
-
import { toast } from "react-toastify";
|
33
|
-
|
34
|
-
// src/Assets/yes.svg
|
35
|
-
var yes_default = 'data:image/svg+xml,<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">%0A<path d="M9 1C7.41775 1 5.87103 1.46919 4.55544 2.34824C3.23985 3.22729 2.21447 4.47672 1.60897 5.93853C1.00347 7.40034 0.84504 9.00887 1.15372 10.5607C1.4624 12.1126 2.22433 13.538 3.34315 14.6569C4.46197 15.7757 5.88743 16.5376 7.43928 16.8463C8.99113 17.155 10.5997 16.9965 12.0615 16.391C13.5233 15.7855 14.7727 14.7602 15.6518 13.4446C16.5308 12.129 17 10.5823 17 9C17 6.87827 16.1571 4.84344 14.6569 3.34315C13.1566 1.84285 11.1217 1 9 1V1ZM9 16C7.61553 16 6.26216 15.5895 5.11101 14.8203C3.95987 14.0511 3.06266 12.9579 2.53285 11.6788C2.00303 10.3997 1.86441 8.99223 2.13451 7.63437C2.4046 6.2765 3.07129 5.02922 4.05026 4.05025C5.02922 3.07128 6.2765 2.4046 7.63437 2.1345C8.99224 1.86441 10.3997 2.00303 11.6788 2.53284C12.9579 3.06266 14.0511 3.95986 14.8203 5.11101C15.5895 6.26215 16 7.61553 16 9C16 10.8565 15.2625 12.637 13.9498 13.9497C12.637 15.2625 10.8565 16 9 16Z" fill="white"/>%0A<path d="M13.9985 6.04969C13.9048 5.95657 13.7781 5.9043 13.646 5.9043C13.5139 5.9043 13.3872 5.95657 13.2935 6.04969L7.7435 11.5747L4.7435 8.57469C4.652 8.4759 4.52501 8.4175 4.39045 8.41234C4.25589 8.40719 4.1248 8.45569 4.026 8.54719C3.92721 8.63869 3.86881 8.76569 3.86365 8.90025C3.8585 9.03481 3.907 9.1659 3.9985 9.26469L7.7435 12.9997L13.9985 6.75969C14.0454 6.71321 14.0826 6.65791 14.108 6.59698C14.1333 6.53605 14.1464 6.4707 14.1464 6.40469C14.1464 6.33869 14.1333 6.27333 14.108 6.21241C14.0826 6.15148 14.0454 6.09618 13.9985 6.04969Z" fill="white"/>%0A</svg>%0A';
|
36
|
-
|
37
|
-
// src/Assets/no_white.svg
|
38
|
-
var no_white_default = 'data:image/svg+xml,<svg width="18" height="19" viewBox="0 0 18 19" fill="none" xmlns="http://www.w3.org/2000/svg">%0A<path d="M9 2C13.1421 2 16.5 5.35786 16.5 9.5C16.5 13.6421 13.1421 17 9 17C4.85786 17 1.5 13.6421 1.5 9.5C1.5 5.35786 4.85786 2 9 2ZM9 3.125C5.47918 3.125 2.625 5.97918 2.625 9.5C2.625 13.0208 5.47918 15.875 9 15.875C12.5208 15.875 15.375 13.0208 15.375 9.5C15.375 5.97918 12.5208 3.125 9 3.125ZM11.5847 6.79779L11.6477 6.85225C11.8474 7.05195 11.8656 7.36445 11.7022 7.58466L11.6477 7.64775L9.79575 9.5L11.6477 11.3523C11.8474 11.552 11.8656 11.8645 11.7022 12.0847L11.6477 12.1477C11.448 12.3474 11.1355 12.3656 10.9153 12.2022L10.8523 12.1477L9 10.2957L7.14775 12.1477C6.94805 12.3474 6.63555 12.3656 6.41534 12.2022L6.35225 12.1477C6.15255 11.948 6.1344 11.6355 6.29779 11.4153L6.35225 11.3523L8.20425 9.5L6.35225 7.64775C6.15255 7.44805 6.1344 7.13555 6.29779 6.91534L6.35225 6.85225C6.55195 6.65255 6.86445 6.6344 7.08466 6.79779L7.14775 6.85225L9 8.70425L10.8523 6.85225C11.052 6.65255 11.3645 6.6344 11.5847 6.79779Z" fill="%23fff"/>%0A</svg>%0A';
|
39
|
-
|
40
|
-
// src/Components/Consent.tsx
|
41
|
-
import ContentLoader from "react-content-loader";
|
42
|
-
import {
|
43
|
-
MAINNET,
|
44
|
-
WithWalletConnector,
|
45
|
-
useConnection,
|
46
|
-
useConnect,
|
47
|
-
stringMessage,
|
48
|
-
useGrpcClient,
|
49
|
-
TESTNET
|
50
|
-
} from "@concordium/react-components";
|
51
|
-
import { OsTypes, isDesktop, isMobile, osName } from "react-device-detect";
|
52
|
-
import { useAccount, useSignMessage } from "wagmi";
|
53
|
-
var SSOButton = React.lazy(
|
54
|
-
() => import("aesirx-sso").then((module) => ({ default: module.SSOButton }))
|
55
|
-
);
|
56
|
-
var ConsentComponent = ({
|
57
|
-
endpoint,
|
58
|
-
aesirXEndpoint,
|
59
|
-
networkEnv,
|
60
|
-
loginApp,
|
61
|
-
isLoggedApp,
|
62
|
-
gtagId,
|
63
|
-
gtmId,
|
64
|
-
layout
|
65
|
-
}) => {
|
66
|
-
return /* @__PURE__ */ React.createElement(WithWalletConnector, { network: networkEnv === "testnet" ? TESTNET : MAINNET }, (props) => /* @__PURE__ */ React.createElement("div", { className: "aesirxconsent" }, /* @__PURE__ */ React.createElement(Ethereum_default, null, /* @__PURE__ */ React.createElement(
|
67
|
-
ConsentComponentApp,
|
68
|
-
{
|
69
|
-
...props,
|
70
|
-
endpoint,
|
71
|
-
aesirXEndpoint,
|
72
|
-
loginApp,
|
73
|
-
isLoggedApp,
|
74
|
-
gtagId,
|
75
|
-
gtmId,
|
76
|
-
layout
|
77
|
-
}
|
78
|
-
))));
|
79
|
-
};
|
80
|
-
var ConsentComponentApp = (props) => {
|
81
|
-
const {
|
82
|
-
endpoint,
|
83
|
-
aesirXEndpoint,
|
84
|
-
loginApp,
|
85
|
-
isLoggedApp,
|
86
|
-
gtagId,
|
87
|
-
gtmId,
|
88
|
-
layout,
|
89
|
-
activeConnectorType,
|
90
|
-
activeConnector,
|
91
|
-
activeConnectorError,
|
92
|
-
connectedAccounts,
|
93
|
-
genesisHashes,
|
94
|
-
setActiveConnectorType,
|
95
|
-
network
|
96
|
-
} = props;
|
97
|
-
const { setConnection } = useConnection(connectedAccounts, genesisHashes);
|
98
|
-
const { isConnecting } = useConnect(activeConnector, setConnection);
|
99
|
-
const handleOnConnect = async (connectorType, network2 = "concordium") => {
|
100
|
-
if (network2 === "concordium") {
|
101
|
-
setActiveConnectorType(connectorType);
|
102
|
-
}
|
103
|
-
setLoading("done");
|
104
|
-
};
|
105
|
-
const [
|
106
|
-
uuid,
|
107
|
-
level,
|
108
|
-
connection,
|
109
|
-
account,
|
110
|
-
show,
|
111
|
-
setShow,
|
112
|
-
web3ID,
|
113
|
-
setWeb3ID,
|
114
|
-
handleLevel,
|
115
|
-
showRevoke,
|
116
|
-
handleRevoke
|
117
|
-
] = useConsentStatus_default(endpoint, layout, props);
|
118
|
-
const [consents, setConsents] = useState([1, 2]);
|
119
|
-
const [loading, setLoading] = useState("done");
|
120
|
-
const [loadingCheckAccount, setLoadingCheckAccount] = useState(false);
|
121
|
-
const [showExpandConsent, setShowExpandConsent] = useState(true);
|
122
|
-
const [showExpandRevoke, setShowExpandRevoke] = useState(false);
|
123
|
-
const [showBackdrop, setShowBackdrop] = useState(true);
|
124
|
-
const [consentTier4, setConsentTier4] = useState({});
|
125
|
-
const analyticsContext = useContext(AnalyticsContext);
|
126
|
-
const { t } = useTranslation();
|
127
|
-
const gRPCClient = useGrpcClient(network);
|
128
|
-
const { address, connector } = useAccount();
|
129
|
-
const { signMessage } = useSignMessage({
|
130
|
-
async onSuccess(data, variables) {
|
131
|
-
const signature = Buffer.from(
|
132
|
-
typeof data === "object" && data !== null ? JSON.stringify(data) : data,
|
133
|
-
"utf-8"
|
134
|
-
).toString("base64");
|
135
|
-
const jwt = sessionStorage.getItem("aesirx-analytics-jwt");
|
136
|
-
if (variables?.message.indexOf("Revoke consent") > -1) {
|
137
|
-
const levelRevoke = sessionStorage.getItem("aesirx-analytics-revoke");
|
138
|
-
const consentList = await getConsents(endpoint, uuid);
|
139
|
-
consentList.forEach(async (consent) => {
|
140
|
-
!consent?.expiration && await revokeConsents(
|
141
|
-
endpoint,
|
142
|
-
levelRevoke,
|
143
|
-
consent?.consent_uuid,
|
144
|
-
address,
|
145
|
-
signature,
|
146
|
-
web3ID,
|
147
|
-
jwt,
|
148
|
-
"metamask"
|
149
|
-
);
|
150
|
-
});
|
151
|
-
setLoading("done");
|
152
|
-
handleRevoke(false);
|
153
|
-
setShowExpandConsent(false);
|
154
|
-
setShow(true);
|
155
|
-
setShowBackdrop(false);
|
156
|
-
sessionStorage.removeItem("aesirx-analytics-allow");
|
157
|
-
} else if (variables?.message.indexOf("Login with nonce") > -1) {
|
158
|
-
const res = await verifySignature(aesirXEndpoint, "metamask", address, data);
|
159
|
-
sessionStorage.setItem("aesirx-analytics-jwt", res?.jwt);
|
160
|
-
setLoadingCheckAccount(false);
|
161
|
-
const nonce = await getNonce(
|
162
|
-
endpoint,
|
163
|
-
address,
|
164
|
-
"Decentralized Consent + Shield of Privacy:{nonce} {domain} {time}",
|
165
|
-
"metamask"
|
166
|
-
);
|
167
|
-
signMessage({ message: `${nonce}` });
|
168
|
-
} else {
|
169
|
-
setLoading("saving");
|
170
|
-
await agreeConsents(
|
171
|
-
endpoint,
|
172
|
-
level,
|
173
|
-
uuid,
|
174
|
-
consents,
|
175
|
-
address,
|
176
|
-
signature,
|
177
|
-
web3ID,
|
178
|
-
jwt,
|
179
|
-
"metamask",
|
180
|
-
gtagId,
|
181
|
-
gtmId,
|
182
|
-
layout
|
183
|
-
);
|
184
|
-
sessionStorage.setItem("aesirx-analytics-uuid", uuid);
|
185
|
-
sessionStorage.setItem("aesirx-analytics-allow", "1");
|
186
|
-
sessionStorage.setItem("aesirx-analytics-consent-type", "metamask");
|
187
|
-
setShow(false);
|
188
|
-
setLoading("done");
|
189
|
-
handleRevoke(true, level);
|
190
|
-
setShowBackdrop(false);
|
191
|
-
}
|
192
|
-
},
|
193
|
-
async onError(error) {
|
194
|
-
setLoading("done");
|
195
|
-
toast.error(error.message);
|
196
|
-
}
|
197
|
-
});
|
198
|
-
const handleChange = async ({ target: { value } }) => {
|
199
|
-
if (consents.indexOf(parseInt(value)) === -1) {
|
200
|
-
setConsents([...consents, ...[parseInt(value)]]);
|
201
|
-
} else {
|
202
|
-
setConsents(consents.filter((consent) => consent !== parseInt(value)));
|
203
|
-
}
|
204
|
-
};
|
205
|
-
const handleAgree = async () => {
|
206
|
-
try {
|
207
|
-
let flag = true;
|
208
|
-
let jwt = "";
|
209
|
-
if (level > 2) {
|
210
|
-
if (level === 4) {
|
211
|
-
try {
|
212
|
-
setLoadingCheckAccount(true);
|
213
|
-
const nonceLogin = await getWalletNonce(
|
214
|
-
aesirXEndpoint,
|
215
|
-
account ? "concordium" : "metamask",
|
216
|
-
account ?? address
|
217
|
-
);
|
218
|
-
if (nonceLogin) {
|
219
|
-
try {
|
220
|
-
if (account) {
|
221
|
-
const signature = await connection.signMessage(
|
222
|
-
account,
|
223
|
-
stringMessage(`${nonceLogin}`)
|
224
|
-
);
|
225
|
-
const convertedSignature = typeof signature === "object" && signature !== null ? signature : JSON.parse(signature);
|
226
|
-
if (signature) {
|
227
|
-
const data = await verifySignature(
|
228
|
-
aesirXEndpoint,
|
229
|
-
"concordium",
|
230
|
-
account,
|
231
|
-
convertedSignature
|
232
|
-
);
|
233
|
-
sessionStorage.setItem("aesirx-analytics-jwt", data?.jwt);
|
234
|
-
jwt = data?.jwt;
|
235
|
-
loginApp && !isLoggedApp && loginApp(data);
|
236
|
-
setLoadingCheckAccount(false);
|
237
|
-
}
|
238
|
-
} else {
|
239
|
-
signMessage({ message: `${nonceLogin}` });
|
240
|
-
}
|
241
|
-
} catch (error) {
|
242
|
-
setLoadingCheckAccount(false);
|
243
|
-
toast(error.message);
|
244
|
-
}
|
245
|
-
}
|
246
|
-
} catch (error) {
|
247
|
-
SSOClick(".loginSSO");
|
248
|
-
setLoadingCheckAccount(false);
|
249
|
-
return;
|
250
|
-
}
|
251
|
-
}
|
252
|
-
if (account) {
|
253
|
-
const signature = await getSignature(
|
254
|
-
endpoint,
|
255
|
-
account,
|
256
|
-
connection,
|
257
|
-
level === 3 ? "Decentralized Consent:{nonce} {domain} {time}" : "Decentralized Consent + Shield of Privacy:{nonce} {domain} {time}"
|
258
|
-
);
|
259
|
-
setLoading("saving");
|
260
|
-
await agreeConsents(
|
261
|
-
endpoint,
|
262
|
-
level,
|
263
|
-
uuid,
|
264
|
-
consents,
|
265
|
-
account,
|
266
|
-
signature,
|
267
|
-
web3ID,
|
268
|
-
jwt,
|
269
|
-
"concordium",
|
270
|
-
gtagId,
|
271
|
-
gtmId,
|
272
|
-
layout
|
273
|
-
);
|
274
|
-
sessionStorage.setItem("aesirx-analytics-consent-type", "concordium");
|
275
|
-
} else if (connector) {
|
276
|
-
if (level === 3) {
|
277
|
-
const nonce = await getNonce(
|
278
|
-
endpoint,
|
279
|
-
address,
|
280
|
-
level === 3 ? "Decentralized Consent:{nonce} {domain} {time}" : "Decentralized Consent + Shield of Privacy:{nonce} {domain} {time}",
|
281
|
-
"metamask"
|
282
|
-
);
|
283
|
-
signMessage({ message: `${nonce}` });
|
284
|
-
}
|
285
|
-
} else {
|
286
|
-
setLoading("connect");
|
287
|
-
flag = false;
|
288
|
-
}
|
289
|
-
} else {
|
290
|
-
setLoading("saving");
|
291
|
-
const consentList = await getConsents(endpoint, analyticsContext.visitor_uuid);
|
292
|
-
consents.forEach(async (consent) => {
|
293
|
-
const existConsent = consentList.find((item) => item?.consent === consent);
|
294
|
-
if (!existConsent) {
|
295
|
-
await agreeConsents(
|
296
|
-
endpoint,
|
297
|
-
1,
|
298
|
-
uuid,
|
299
|
-
consent,
|
300
|
-
null,
|
301
|
-
null,
|
302
|
-
null,
|
303
|
-
null,
|
304
|
-
"concordium",
|
305
|
-
gtagId,
|
306
|
-
gtmId,
|
307
|
-
layout
|
308
|
-
);
|
309
|
-
} else if (!!existConsent?.consent_uuid && existConsent?.expiration && new Date(existConsent.expiration) < /* @__PURE__ */ new Date()) {
|
310
|
-
await agreeConsents(
|
311
|
-
endpoint,
|
312
|
-
1,
|
313
|
-
uuid,
|
314
|
-
consent,
|
315
|
-
null,
|
316
|
-
null,
|
317
|
-
null,
|
318
|
-
null,
|
319
|
-
"concordium",
|
320
|
-
gtagId,
|
321
|
-
gtmId,
|
322
|
-
layout
|
323
|
-
);
|
324
|
-
}
|
325
|
-
});
|
326
|
-
}
|
327
|
-
if (flag && (account || level < 3)) {
|
328
|
-
sessionStorage.setItem("aesirx-analytics-uuid", uuid);
|
329
|
-
sessionStorage.setItem("aesirx-analytics-allow", "1");
|
330
|
-
setShow(false);
|
331
|
-
setLoading("done");
|
332
|
-
handleRevoke(true, level);
|
333
|
-
setShowBackdrop(false);
|
334
|
-
}
|
335
|
-
} catch (error) {
|
336
|
-
console.log(error);
|
337
|
-
handleNotAllow();
|
338
|
-
setLoading("done");
|
339
|
-
toast.error(error?.response?.data?.error ?? error.message);
|
340
|
-
}
|
341
|
-
};
|
342
|
-
useEffect(() => {
|
343
|
-
const init = async () => {
|
344
|
-
if (Object.keys(consentTier4)?.length && (account || address)) {
|
345
|
-
await consentTier4Init(consentTier4);
|
346
|
-
setConsentTier4({});
|
347
|
-
}
|
348
|
-
};
|
349
|
-
init();
|
350
|
-
}, [consentTier4, account, address]);
|
351
|
-
const consentTier4Init = async (response) => {
|
352
|
-
let hasWeb3ID = true;
|
353
|
-
if (response?.loginType === "concordium") {
|
354
|
-
const web3ID2 = await getWeb3ID(account, gRPCClient, network?.name);
|
355
|
-
if (web3ID2) {
|
356
|
-
setWeb3ID(web3ID2);
|
357
|
-
} else {
|
358
|
-
hasWeb3ID = false;
|
359
|
-
}
|
360
|
-
} else {
|
361
|
-
const memberData = await getMember(aesirXEndpoint, response?.access_token);
|
362
|
-
hasWeb3ID = memberData?.web3id ? true : false;
|
363
|
-
}
|
364
|
-
if (hasWeb3ID) {
|
365
|
-
if (response?.loginType === "concordium") {
|
366
|
-
sessionStorage.setItem("aesirx-analytics-consent-type", "concordium");
|
367
|
-
const signature = await getSignature(
|
368
|
-
endpoint,
|
369
|
-
account,
|
370
|
-
connection,
|
371
|
-
"Decentralized Consent + Shield of Privacy:{nonce} {domain} {time}"
|
372
|
-
);
|
373
|
-
await agreeConsents(
|
374
|
-
endpoint,
|
375
|
-
level,
|
376
|
-
uuid,
|
377
|
-
consents,
|
378
|
-
account,
|
379
|
-
signature,
|
380
|
-
null,
|
381
|
-
response?.jwt,
|
382
|
-
"concordium",
|
383
|
-
gtagId,
|
384
|
-
gtmId,
|
385
|
-
layout
|
386
|
-
);
|
387
|
-
setShow(false);
|
388
|
-
handleRevoke(true, level);
|
389
|
-
setLoading("done");
|
390
|
-
} else if (response?.loginType === "metamask") {
|
391
|
-
sessionStorage.setItem("aesirx-analytics-consent-type", "metamask");
|
392
|
-
const nonce = await getNonce(
|
393
|
-
endpoint,
|
394
|
-
address,
|
395
|
-
"Decentralized Consent + Shield of Privacy:{nonce} {domain} {time}",
|
396
|
-
"metamask"
|
397
|
-
);
|
398
|
-
signMessage({ message: `${nonce}` });
|
399
|
-
}
|
400
|
-
} else {
|
401
|
-
handleLevel(3);
|
402
|
-
toast("You haven't minted any WEB3 ID yet. Try to mint at https://dapp.shield.aesirx.io");
|
403
|
-
setLoading("done");
|
404
|
-
}
|
405
|
-
};
|
406
|
-
const onGetData = async (response) => {
|
407
|
-
try {
|
408
|
-
setLoading("saving");
|
409
|
-
const levelRevoke = sessionStorage.getItem("aesirx-analytics-revoke");
|
410
|
-
sessionStorage.setItem("aesirx-analytics-jwt", response?.jwt);
|
411
|
-
if (levelRevoke && levelRevoke !== "0") {
|
412
|
-
sessionStorage.setItem(
|
413
|
-
"aesirx-analytics-consent-type",
|
414
|
-
response?.loginType === "concordium" ? "concordium" : "metamask"
|
415
|
-
);
|
416
|
-
handleRevokeBtn();
|
417
|
-
} else {
|
418
|
-
if (level === 4) {
|
419
|
-
if (response?.loginType === "concordium" && isDesktop) {
|
420
|
-
setActiveConnectorType(BROWSER_WALLET);
|
421
|
-
}
|
422
|
-
setConsentTier4(response);
|
423
|
-
} else {
|
424
|
-
await agreeConsents(
|
425
|
-
endpoint,
|
426
|
-
level,
|
427
|
-
uuid,
|
428
|
-
consents,
|
429
|
-
null,
|
430
|
-
null,
|
431
|
-
null,
|
432
|
-
response?.jwt,
|
433
|
-
"concordium",
|
434
|
-
gtagId,
|
435
|
-
gtmId,
|
436
|
-
layout
|
437
|
-
);
|
438
|
-
setShow(false);
|
439
|
-
handleRevoke(true, level);
|
440
|
-
setLoading("done");
|
441
|
-
}
|
442
|
-
}
|
443
|
-
loginApp && !isLoggedApp && loginApp(response);
|
444
|
-
} catch (error) {
|
445
|
-
console.log(error);
|
446
|
-
setShow(false);
|
447
|
-
setLoading("done");
|
448
|
-
toast.error(error?.response?.data?.error ?? error.message);
|
449
|
-
}
|
450
|
-
};
|
451
|
-
const handleNotAllow = () => {
|
452
|
-
sessionStorage.setItem("aesirx-analytics-uuid", uuid);
|
453
|
-
sessionStorage.setItem("aesirx-analytics-rejected", "true");
|
454
|
-
setShowExpandConsent(false);
|
455
|
-
setShowBackdrop(false);
|
456
|
-
window.funcAfterReject && window.funcAfterReject();
|
457
|
-
};
|
458
|
-
const handleRevokeBtn = async () => {
|
459
|
-
const levelRevoke = sessionStorage.getItem("aesirx-analytics-revoke");
|
460
|
-
const consentType = sessionStorage.getItem("aesirx-analytics-consent-type");
|
461
|
-
const jwt = sessionStorage.getItem("aesirx-analytics-jwt");
|
462
|
-
try {
|
463
|
-
let flag = true;
|
464
|
-
if (levelRevoke !== "1") {
|
465
|
-
if (parseInt(levelRevoke) > 2) {
|
466
|
-
if (!jwt && (parseInt(levelRevoke) === 2 || parseInt(levelRevoke) === 4)) {
|
467
|
-
SSOClick(".revokeLogin");
|
468
|
-
return;
|
469
|
-
}
|
470
|
-
if (account && consentType !== "metamask") {
|
471
|
-
setLoading("sign");
|
472
|
-
const signature = await getSignature(
|
473
|
-
endpoint,
|
474
|
-
account,
|
475
|
-
connection,
|
476
|
-
"Revoke consent:{nonce} {domain} {time}"
|
477
|
-
);
|
478
|
-
setLoading("saving");
|
479
|
-
const consentList = await getConsents(endpoint, uuid);
|
480
|
-
consentList.forEach(async (consent) => {
|
481
|
-
!consent?.expiration && await revokeConsents(
|
482
|
-
endpoint,
|
483
|
-
levelRevoke,
|
484
|
-
consent?.consent_uuid,
|
485
|
-
account,
|
486
|
-
signature,
|
487
|
-
web3ID,
|
488
|
-
jwt
|
489
|
-
);
|
490
|
-
});
|
491
|
-
setLoading("done");
|
492
|
-
handleRevoke(false);
|
493
|
-
} else if (connector) {
|
494
|
-
setLoading("sign");
|
495
|
-
setLoading("saving");
|
496
|
-
const nonce = await getNonce(
|
497
|
-
endpoint,
|
498
|
-
address,
|
499
|
-
"Revoke consent:{nonce} {domain} {time}",
|
500
|
-
"metamask"
|
501
|
-
);
|
502
|
-
signMessage({ message: `${nonce}` });
|
503
|
-
} else {
|
504
|
-
setLoading("connect");
|
505
|
-
flag = false;
|
506
|
-
}
|
507
|
-
} else {
|
508
|
-
setLoading("saving");
|
509
|
-
const consentList = await getConsents(endpoint, uuid);
|
510
|
-
consentList.forEach(async (consent) => {
|
511
|
-
!consent?.expiration && await revokeConsents(
|
512
|
-
endpoint,
|
513
|
-
levelRevoke,
|
514
|
-
consent?.consent_uuid,
|
515
|
-
null,
|
516
|
-
null,
|
517
|
-
null,
|
518
|
-
jwt
|
519
|
-
);
|
520
|
-
});
|
521
|
-
setLoading("done");
|
522
|
-
handleRevoke(false);
|
523
|
-
}
|
524
|
-
if (flag && (account && consentType !== "metamask" || level < 3)) {
|
525
|
-
setShowExpandConsent(false);
|
526
|
-
setShow(true);
|
527
|
-
setShowBackdrop(false);
|
528
|
-
sessionStorage.removeItem("aesirx-analytics-allow");
|
529
|
-
}
|
530
|
-
} else {
|
531
|
-
handleRevoke(false);
|
532
|
-
setShowExpandConsent(false);
|
533
|
-
setShow(true);
|
534
|
-
setShowBackdrop(false);
|
535
|
-
sessionStorage.removeItem("aesirx-analytics-allow");
|
536
|
-
}
|
537
|
-
} catch (error) {
|
538
|
-
console.log(error);
|
539
|
-
setLoading("done");
|
540
|
-
toast.error(error?.response?.data?.error ?? error.message);
|
541
|
-
}
|
542
|
-
};
|
543
|
-
const SSOClick = (selector) => {
|
544
|
-
const element = document.querySelector(selector);
|
545
|
-
element.click();
|
546
|
-
};
|
547
|
-
const loadConsentDefault = async (gtagId2, gtmId2) => {
|
548
|
-
window.dataLayer = window.dataLayer || [];
|
549
|
-
function gtag(p0, p1, p2) {
|
550
|
-
dataLayer.push(arguments);
|
551
|
-
}
|
552
|
-
if (layout !== "simple-consent-mode" && sessionStorage.getItem("consentGranted") !== "true") {
|
553
|
-
gtag("consent", "default", {
|
554
|
-
ad_user_data: "denied",
|
555
|
-
ad_personalization: "denied",
|
556
|
-
ad_storage: "denied",
|
557
|
-
analytics_storage: "denied",
|
558
|
-
wait_for_update: 500
|
559
|
-
});
|
560
|
-
gtag("set", "url_passthrough", true);
|
561
|
-
gtag("set", "ads_data_redaction", true);
|
562
|
-
}
|
563
|
-
if ((layout !== "simple-consent-mode" || sessionStorage.getItem("consentGranted") === "true") && (gtmId2 && !document.querySelector(
|
564
|
-
`script[src="https://www.googletagmanager.com/gtm.js?id=${gtmId2}"]`
|
565
|
-
) || gtagId2 && !document.querySelector(
|
566
|
-
`script[src="https://www.googletagmanager.com/gtag/js?id=${gtagId2}"]`
|
567
|
-
))) {
|
568
|
-
gtagId2 && await loadGtagScript(gtagId2);
|
569
|
-
gtmId2 && await loadGtmScript(gtmId2);
|
570
|
-
if (gtagId2) {
|
571
|
-
gtag("js", /* @__PURE__ */ new Date());
|
572
|
-
gtag("config", `${gtagId2}`);
|
573
|
-
}
|
574
|
-
if (gtmId2) {
|
575
|
-
dataLayer.push({ "gtm.start": (/* @__PURE__ */ new Date()).getTime(), event: "gtm.js" });
|
576
|
-
}
|
577
|
-
}
|
578
|
-
if (sessionStorage.getItem("consentGranted") === "true") {
|
579
|
-
gtag("consent", "update", {
|
580
|
-
ad_user_data: "granted",
|
581
|
-
ad_personalization: "granted",
|
582
|
-
ad_storage: "granted",
|
583
|
-
analytics_storage: "granted"
|
584
|
-
});
|
585
|
-
}
|
586
|
-
};
|
587
|
-
useEffect(() => {
|
588
|
-
if (activeConnectorError) {
|
589
|
-
toast.error(activeConnectorError);
|
590
|
-
}
|
591
|
-
}, [activeConnectorError]);
|
592
|
-
useEffect(() => {
|
593
|
-
if (sessionStorage.getItem("aesirx-analytics-rejected") === "true") {
|
594
|
-
setShowBackdrop(false);
|
595
|
-
setShowExpandConsent(false);
|
596
|
-
}
|
597
|
-
}, []);
|
598
|
-
useEffect(() => {
|
599
|
-
(gtagId || gtmId) && loadConsentDefault(gtagId, gtmId);
|
600
|
-
}, [layout]);
|
601
|
-
console.log("level", uuid, level, web3ID, account, loading);
|
602
|
-
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", { className: `offcanvas-backdrop fade ${showBackdrop && show ? "show" : "d-none"}` }), /* @__PURE__ */ React.createElement(
|
603
|
-
"div",
|
604
|
-
{
|
605
|
-
tabIndex: -1,
|
606
|
-
className: `toast-container position-fixed m-md-3 ${showExpandRevoke ? "top-50 start-50 translate-middle" : "bottom-0 end-0"}`
|
607
|
-
},
|
608
|
-
/* @__PURE__ */ React.createElement(
|
609
|
-
"div",
|
610
|
-
{
|
611
|
-
className: `toast revoke-toast ${showRevoke || sessionStorage.getItem("aesirx-analytics-revoke") && sessionStorage.getItem("aesirx-analytics-revoke") !== "0" ? "show" : ""} ${showExpandRevoke ? "" : "minimize"}`
|
612
|
-
},
|
613
|
-
/* @__PURE__ */ React.createElement(LoadingStatus, { loading }),
|
614
|
-
/* @__PURE__ */ React.createElement("div", { className: "toast-body p-0 shadow mx-3 mx-md-0" }, /* @__PURE__ */ React.createElement("div", { className: "revoke-wrapper minimize-shield-wrapper position-relative" }, !showExpandRevoke && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
615
|
-
"img",
|
616
|
-
{
|
617
|
-
className: "cover-img position-absolute h-100 w-100 object-fit-cover",
|
618
|
-
src: bg_default,
|
619
|
-
alt: "Background Image"
|
620
|
-
}
|
621
|
-
), /* @__PURE__ */ React.createElement(
|
622
|
-
"div",
|
623
|
-
{
|
624
|
-
className: "minimize-shield",
|
625
|
-
onClick: () => {
|
626
|
-
if (osName !== OsTypes?.IOS && isMobile && !connection && sessionStorage.getItem("aesirx-analytics-revoke") && parseInt(sessionStorage.getItem("aesirx-analytics-revoke")) > 2) {
|
627
|
-
setActiveConnectorType(WALLET_CONNECT);
|
628
|
-
}
|
629
|
-
setShowExpandRevoke(true);
|
630
|
-
}
|
631
|
-
},
|
632
|
-
/* @__PURE__ */ React.createElement("img", { src: privacy_default, alt: "SoP Icon" }),
|
633
|
-
t("txt_shield_of_privacy")
|
634
|
-
)), showExpandRevoke && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
635
|
-
"div",
|
636
|
-
{
|
637
|
-
className: "minimize-revoke",
|
638
|
-
onClick: () => {
|
639
|
-
setShowExpandRevoke(false);
|
640
|
-
}
|
641
|
-
},
|
642
|
-
/* @__PURE__ */ React.createElement("img", { src: no_default, alt: "No Icon" })
|
643
|
-
), /* @__PURE__ */ React.createElement("div", { className: "p-3 bg-white text" }, t("txt_you_can_revoke"), " ", /* @__PURE__ */ React.createElement("br", null), t("txt_visit"), " ", /* @__PURE__ */ React.createElement(
|
644
|
-
"a",
|
645
|
-
{
|
646
|
-
href: "https://nft.shield.aesirx.io",
|
647
|
-
className: "text-success text-decoration-underline",
|
648
|
-
target: "_blank",
|
649
|
-
rel: "noreferrer"
|
650
|
-
},
|
651
|
-
t("txt_link")
|
652
|
-
), " ", t("txt_for_more_information")), /* @__PURE__ */ React.createElement("div", { className: "rounded-bottom position-relative overflow-hidden text-white" }, /* @__PURE__ */ React.createElement(
|
653
|
-
"img",
|
654
|
-
{
|
655
|
-
className: "cover-img position-absolute h-100 w-100 object-fit-cover",
|
656
|
-
src: bg_default,
|
657
|
-
alt: "Background Image"
|
658
|
-
}
|
659
|
-
), /* @__PURE__ */ React.createElement("div", { className: "position-relative p-3" }, /* @__PURE__ */ React.createElement("div", { className: "d-flex align-items-center justify-content-between flex-wrap" }, /* @__PURE__ */ React.createElement("div", { className: "me-2" }, /* @__PURE__ */ React.createElement("img", { src: privacy_default, alt: "SoP Icon" }), " ", t("txt_shield_of_privacy")), /* @__PURE__ */ React.createElement("div", { className: "d-flex align-items-center" }, /* @__PURE__ */ React.createElement(
|
660
|
-
"a",
|
661
|
-
{
|
662
|
-
className: "text-success text-decoration-underline manage-consent fs-14",
|
663
|
-
href: "https://dapp.shield.aesirx.io/revoke-consent",
|
664
|
-
target: "_blank",
|
665
|
-
rel: "noreferrer"
|
666
|
-
},
|
667
|
-
t("txt_manage_consent")
|
668
|
-
), loading === "done" ? /* @__PURE__ */ React.createElement(
|
669
|
-
Button,
|
670
|
-
{
|
671
|
-
variant: "success",
|
672
|
-
onClick: handleRevokeBtn,
|
673
|
-
className: "text-white d-flex align-items-center revoke-btn fs-14"
|
674
|
-
},
|
675
|
-
t("txt_revoke_consent")
|
676
|
-
) : /* @__PURE__ */ React.createElement(React.Fragment, null), (sessionStorage.getItem("aesirx-analytics-revoke") === "4" || sessionStorage.getItem("aesirx-analytics-revoke") === "2") && /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement("div", null, "Loading...") }, /* @__PURE__ */ React.createElement(
|
677
|
-
SSOButton,
|
678
|
-
{
|
679
|
-
className: "d-none revokeLogin",
|
680
|
-
text: /* @__PURE__ */ React.createElement(React.Fragment, null, "Login Revoke"),
|
681
|
-
ssoState: "noscopes",
|
682
|
-
onGetData
|
683
|
-
}
|
684
|
-
))))))))))
|
685
|
-
)
|
686
|
-
), /* @__PURE__ */ React.createElement(
|
687
|
-
"div",
|
688
|
-
{
|
689
|
-
tabIndex: -1,
|
690
|
-
className: `toast-container position-fixed m-md-3 ${showExpandConsent ? "top-50 start-50 translate-middle" : "bottom-0 end-0"}`
|
691
|
-
},
|
692
|
-
/* @__PURE__ */ React.createElement("div", { className: `toast ${show ? "show" : ""} ${showExpandConsent ? "" : "minimize"}` }, /* @__PURE__ */ React.createElement(LoadingStatus, { loading }), /* @__PURE__ */ React.createElement("div", { className: "toast-body p-0 shadow mx-3 mx-md-0" }, !showExpandConsent ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "minimize-shield-wrapper position-relative" }, /* @__PURE__ */ React.createElement(
|
693
|
-
"img",
|
694
|
-
{
|
695
|
-
className: "cover-img position-absolute h-100 w-100 object-fit-cover",
|
696
|
-
src: bg_default,
|
697
|
-
alt: "Background Image"
|
698
|
-
}
|
699
|
-
), /* @__PURE__ */ React.createElement(
|
700
|
-
"div",
|
701
|
-
{
|
702
|
-
className: "minimize-shield",
|
703
|
-
onClick: () => {
|
704
|
-
setShowExpandConsent(true);
|
705
|
-
sessionStorage.removeItem("aesirx-analytics-rejected");
|
706
|
-
}
|
707
|
-
},
|
708
|
-
/* @__PURE__ */ React.createElement("img", { src: privacy_default, alt: "SoP Icon" }),
|
709
|
-
t("txt_shield_of_privacy")
|
710
|
-
))) : /* @__PURE__ */ React.createElement(React.Fragment, null, level ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TermsComponent, { level, handleLevel, layout }, /* @__PURE__ */ React.createElement(Form, { className: "mb-0" }, /* @__PURE__ */ React.createElement(
|
711
|
-
Form.Check,
|
712
|
-
{
|
713
|
-
checked: consents.includes(1),
|
714
|
-
type: "switch",
|
715
|
-
label: "Personal data share consent.",
|
716
|
-
value: 1,
|
717
|
-
onChange: handleChange,
|
718
|
-
className: "d-none"
|
719
|
-
}
|
720
|
-
), /* @__PURE__ */ React.createElement(
|
721
|
-
Form.Check,
|
722
|
-
{
|
723
|
-
checked: consents.includes(2),
|
724
|
-
type: "switch",
|
725
|
-
label: "Personal data cross site share consent.",
|
726
|
-
value: 2,
|
727
|
-
onChange: handleChange,
|
728
|
-
className: "d-none"
|
729
|
-
}
|
730
|
-
), /* @__PURE__ */ React.createElement("div", { className: "d-flex justify-content-end" }, loading === "done" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
731
|
-
"div",
|
732
|
-
{
|
733
|
-
className: `ssoBtnWrapper me-1 bg-success ${level === 2 || level === 4 && !account && !address ? "" : "d-none"}`
|
734
|
-
},
|
735
|
-
/* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement("div", null, "Loading...") }, /* @__PURE__ */ React.createElement(
|
736
|
-
SSOButton,
|
737
|
-
{
|
738
|
-
className: "btn btn-success text-white d-flex align-items-center loginSSO",
|
739
|
-
text: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("img", { src: yes_default, className: "me-1", alt: "Yes Icon" }), t("txt_yes_i_consent")),
|
740
|
-
ssoState: "noscopes",
|
741
|
-
onGetData,
|
742
|
-
...level === 2 ? { noCreateAccount: true } : {}
|
743
|
-
}
|
744
|
-
))
|
745
|
-
), level === 2 || level === 4 && !account && !address ? /* @__PURE__ */ React.createElement(React.Fragment, null) : /* @__PURE__ */ React.createElement(
|
746
|
-
Button,
|
747
|
-
{
|
748
|
-
variant: "success",
|
749
|
-
onClick: handleAgree,
|
750
|
-
className: "me-1 text-white d-flex align-items-center fs-14"
|
751
|
-
},
|
752
|
-
loadingCheckAccount ? /* @__PURE__ */ React.createElement(
|
753
|
-
"span",
|
754
|
-
{
|
755
|
-
className: "spinner-border spinner-border-sm me-1",
|
756
|
-
role: "status",
|
757
|
-
"aria-hidden": "true"
|
758
|
-
}
|
759
|
-
) : /* @__PURE__ */ React.createElement("img", { src: yes_default, className: "me-1", alt: "Yes Icon" }),
|
760
|
-
t("txt_yes_i_consent")
|
761
|
-
), /* @__PURE__ */ React.createElement(
|
762
|
-
Button,
|
763
|
-
{
|
764
|
-
variant: "gray",
|
765
|
-
onClick: handleNotAllow,
|
766
|
-
className: "d-flex align-items-center fs-14"
|
767
|
-
},
|
768
|
-
/* @__PURE__ */ React.createElement("img", { src: no_white_default, className: "me-1", alt: "No Icon" }),
|
769
|
-
t("txt_reject_consent")
|
770
|
-
)) : /* @__PURE__ */ React.createElement(React.Fragment, null))))) : /* @__PURE__ */ React.createElement("div", { className: "p-4" }, /* @__PURE__ */ React.createElement(
|
771
|
-
ContentLoader,
|
772
|
-
{
|
773
|
-
speed: 2,
|
774
|
-
width: 340,
|
775
|
-
height: 84,
|
776
|
-
viewBox: "0 0 340 84",
|
777
|
-
backgroundColor: "#f3f3f3",
|
778
|
-
foregroundColor: "#ecebeb"
|
779
|
-
},
|
780
|
-
/* @__PURE__ */ React.createElement("rect", { x: "0", y: "0", rx: "3", ry: "3", width: "67", height: "11" }),
|
781
|
-
/* @__PURE__ */ React.createElement("rect", { x: "76", y: "0", rx: "3", ry: "3", width: "140", height: "11" }),
|
782
|
-
/* @__PURE__ */ React.createElement("rect", { x: "127", y: "48", rx: "3", ry: "3", width: "53", height: "11" }),
|
783
|
-
/* @__PURE__ */ React.createElement("rect", { x: "187", y: "48", rx: "3", ry: "3", width: "72", height: "11" }),
|
784
|
-
/* @__PURE__ */ React.createElement("rect", { x: "18", y: "48", rx: "3", ry: "3", width: "100", height: "11" }),
|
785
|
-
/* @__PURE__ */ React.createElement("rect", { x: "0", y: "71", rx: "3", ry: "3", width: "37", height: "11" }),
|
786
|
-
/* @__PURE__ */ React.createElement("rect", { x: "18", y: "23", rx: "3", ry: "3", width: "140", height: "11" }),
|
787
|
-
/* @__PURE__ */ React.createElement("rect", { x: "166", y: "23", rx: "3", ry: "3", width: "173", height: "11" })
|
788
|
-
)))))
|
789
|
-
), !account && loading === "connect" && /* @__PURE__ */ React.createElement(
|
790
|
-
Connect_default,
|
791
|
-
{
|
792
|
-
isConnecting,
|
793
|
-
handleOnConnect,
|
794
|
-
activeConnectorError,
|
795
|
-
activeConnectorType,
|
796
|
-
activeConnector
|
797
|
-
}
|
798
|
-
));
|
799
|
-
};
|
800
|
-
var Consent_default = ConsentComponent;
|
801
|
-
export {
|
802
|
-
Consent_default as default
|
803
|
-
};
|