authscape 1.0.702 → 1.0.706
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/index.js +33 -33
- package/package.json +1 -1
- package/src/components/AuthScapeApp.js +28 -24
- package/src/components/GDPRConsentDialog.js +2 -2
package/index.js
CHANGED
|
@@ -42,19 +42,25 @@ function AuthScapeApp(_ref) {
|
|
|
42
42
|
_ref$enforceLoggedIn = _ref.enforceLoggedIn,
|
|
43
43
|
enforceLoggedIn = _ref$enforceLoggedIn === void 0 ? false : _ref$enforceLoggedIn,
|
|
44
44
|
_ref$enableAuth = _ref.enableAuth,
|
|
45
|
-
enableAuth = _ref$enableAuth === void 0 ? true : _ref$enableAuth
|
|
45
|
+
enableAuth = _ref$enableAuth === void 0 ? true : _ref$enableAuth,
|
|
46
|
+
_ref$enableConsentDia = _ref.enableConsentDialog,
|
|
47
|
+
enableConsentDialog = _ref$enableConsentDia === void 0 ? false : _ref$enableConsentDia;
|
|
46
48
|
var _useState = (0, _react.useState)(false),
|
|
47
49
|
_useState2 = _slicedToArray(_useState, 2),
|
|
48
50
|
frontEndLoadedState = _useState2[0],
|
|
49
51
|
setFrontEndLoadedState = _useState2[1];
|
|
50
52
|
var _useState3 = (0, _react.useState)(false),
|
|
51
53
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
var _useState5 = (0, _react.useState)(
|
|
54
|
+
concentState = _useState4[0],
|
|
55
|
+
setConcentState = _useState4[1];
|
|
56
|
+
var _useState5 = (0, _react.useState)(false),
|
|
55
57
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
isLoadingShow = _useState6[0],
|
|
59
|
+
setIsLoadingShow = _useState6[1];
|
|
60
|
+
var _useState7 = (0, _react.useState)(null),
|
|
61
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
62
|
+
signedInUserState = _useState8[0],
|
|
63
|
+
setSignedInUserState = _useState8[1];
|
|
58
64
|
var loadingAuth = (0, _react.useRef)(false);
|
|
59
65
|
var frontEndLoaded = (0, _react.useRef)(false);
|
|
60
66
|
var signedInUser = (0, _react.useRef)(null);
|
|
@@ -64,20 +70,13 @@ function AuthScapeApp(_ref) {
|
|
|
64
70
|
var queryRef = searchParams.get('ref');
|
|
65
71
|
var queryCode = searchParams.get('code');
|
|
66
72
|
var pathname = (0, _navigation.usePathname)();
|
|
67
|
-
(0, _react.useEffect)(function () {
|
|
68
|
-
var stored = localStorage.getItem("gdpr-consent");
|
|
69
|
-
if (stored) {
|
|
70
|
-
var prefs = JSON.parse(stored);
|
|
71
|
-
console.log("User previously consented:", prefs);
|
|
72
|
-
// optional: send to your backend
|
|
73
|
-
}
|
|
74
|
-
}, []);
|
|
75
73
|
var handleConsentAccepted = function handleConsentAccepted(prefs) {
|
|
76
74
|
console.log("Consent accepted:", prefs);
|
|
77
|
-
|
|
75
|
+
setConcentState(prefs);
|
|
78
76
|
};
|
|
79
77
|
var handleConsentRejected = function handleConsentRejected() {
|
|
80
78
|
console.log("Consent rejected");
|
|
79
|
+
setConcentState(null);
|
|
81
80
|
// disable analytics scripts, etc.
|
|
82
81
|
};
|
|
83
82
|
var signInValidator = /*#__PURE__*/function () {
|
|
@@ -274,7 +273,15 @@ function AuthScapeApp(_ref) {
|
|
|
274
273
|
}
|
|
275
274
|
};
|
|
276
275
|
(0, _react.useEffect)(function () {
|
|
277
|
-
|
|
276
|
+
var enableAnalytics = false;
|
|
277
|
+
var stored = localStorage.getItem("gdpr-consent");
|
|
278
|
+
if (stored) {
|
|
279
|
+
var prefs = JSON.parse(stored);
|
|
280
|
+
if (prefs.analytics) {
|
|
281
|
+
enableAnalytics = true;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
if (frontEndLoadedState && !enableConsentDialog || frontEndLoadedState && enableConsentDialog && enableAnalytics) {
|
|
278
285
|
if (pageProps.googleAnalytics4Code != null) {
|
|
279
286
|
initGA(pageProps.googleAnalytics4Code);
|
|
280
287
|
} else if (process.env.googleAnalytics4 != "") {
|
|
@@ -315,7 +322,7 @@ function AuthScapeApp(_ref) {
|
|
|
315
322
|
document.body.appendChild(script);
|
|
316
323
|
}
|
|
317
324
|
}
|
|
318
|
-
}, [frontEndLoadedState]);
|
|
325
|
+
}, [frontEndLoadedState, concentState]);
|
|
319
326
|
var validateUserSignedIn = /*#__PURE__*/function () {
|
|
320
327
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
321
328
|
var usr;
|
|
@@ -463,22 +470,15 @@ function AuthScapeApp(_ref) {
|
|
|
463
470
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_head["default"], null, /*#__PURE__*/_react["default"].createElement("meta", {
|
|
464
471
|
name: "viewport",
|
|
465
472
|
content: "width=device-width, initial-scale=0.86, maximum-scale=5.0, minimum-scale=0.86"
|
|
466
|
-
})), /*#__PURE__*/_react["default"].createElement(GDPRConsentDialog, {
|
|
473
|
+
})), enableConsentDialog && /*#__PURE__*/_react["default"].createElement(GDPRConsentDialog, {
|
|
467
474
|
onAccept: handleConsentAccepted,
|
|
468
475
|
onReject: handleConsentRejected,
|
|
469
476
|
enableAnalytics: true,
|
|
470
|
-
enableMarketing:
|
|
471
|
-
additionalPrivacyFeatures
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
checked: true
|
|
476
|
-
}, {
|
|
477
|
-
id: "frog",
|
|
478
|
-
title: "Able to see Frogs",
|
|
479
|
-
description: "Frogs will appear on your screen",
|
|
480
|
-
checked: true
|
|
481
|
-
}]
|
|
477
|
+
enableMarketing: false
|
|
478
|
+
// additionalPrivacyFeatures={[
|
|
479
|
+
// {id: "danceParty", title: "Dance Party", description: "Hello world this is about the feature", checked: true },
|
|
480
|
+
// {id: "frog", title: "Able to see Frogs", description: "Frogs will appear on your screen", checked: true }
|
|
481
|
+
// ]}
|
|
482
482
|
}), /*#__PURE__*/_react["default"].createElement(_styles.ThemeProvider, {
|
|
483
483
|
theme: muiTheme
|
|
484
484
|
}, frontEndLoadedState != null && frontEndLoadedState && pathname != "/signin-oidc" && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, layout != null && layout({
|
|
@@ -2366,7 +2366,7 @@ var FileUploader = exports.FileUploader = function FileUploader(_ref) {
|
|
|
2366
2366
|
Object.defineProperty(exports, "__esModule", {
|
|
2367
2367
|
value: true
|
|
2368
2368
|
});
|
|
2369
|
-
exports
|
|
2369
|
+
exports.GDPRConsentDialog = void 0;
|
|
2370
2370
|
var _react = _interopRequireWildcard(require("react"));
|
|
2371
2371
|
var _material = require("@mui/material");
|
|
2372
2372
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
@@ -2383,7 +2383,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
2383
2383
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2384
2384
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
2385
2385
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
2386
|
-
function GDPRConsentDialog(_ref) {
|
|
2386
|
+
var GDPRConsentDialog = exports.GDPRConsentDialog = function GDPRConsentDialog(_ref) {
|
|
2387
2387
|
var onAccept = _ref.onAccept,
|
|
2388
2388
|
onReject = _ref.onReject,
|
|
2389
2389
|
_ref$enableAnalytics = _ref.enableAnalytics,
|
|
@@ -2568,7 +2568,7 @@ function GDPRConsentDialog(_ref) {
|
|
|
2568
2568
|
return setCustomize(false);
|
|
2569
2569
|
}
|
|
2570
2570
|
}, "Cancel")))));
|
|
2571
|
-
}
|
|
2571
|
+
};
|
|
2572
2572
|
"use strict";
|
|
2573
2573
|
|
|
2574
2574
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
package/package.json
CHANGED
|
@@ -11,9 +11,10 @@ import { create } from 'zustand'
|
|
|
11
11
|
import { clarity } from 'react-microsoft-clarity';
|
|
12
12
|
import { authService } from 'authscape';
|
|
13
13
|
|
|
14
|
-
export function AuthScapeApp ({Component, layout, loadingLayout, pageProps, muiTheme = {}, store={}, enforceLoggedIn = false, enableAuth = true}) {
|
|
14
|
+
export function AuthScapeApp ({Component, layout, loadingLayout, pageProps, muiTheme = {}, store={}, enforceLoggedIn = false, enableAuth = true, enableConsentDialog = false}) {
|
|
15
15
|
|
|
16
16
|
const [frontEndLoadedState, setFrontEndLoadedState] = useState(false);
|
|
17
|
+
const [concentState, setConcentState] = useState(false);
|
|
17
18
|
|
|
18
19
|
const [isLoadingShow, setIsLoadingShow] = useState(false);
|
|
19
20
|
|
|
@@ -32,23 +33,14 @@ export function AuthScapeApp ({Component, layout, loadingLayout, pageProps, muiT
|
|
|
32
33
|
|
|
33
34
|
const pathname = usePathname();
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
const stored = localStorage.getItem("gdpr-consent");
|
|
38
|
-
if (stored) {
|
|
39
|
-
const prefs = JSON.parse(stored);
|
|
40
|
-
console.log("User previously consented:", prefs);
|
|
41
|
-
// optional: send to your backend
|
|
42
|
-
}
|
|
43
|
-
}, []);
|
|
44
|
-
|
|
45
36
|
const handleConsentAccepted = (prefs) => {
|
|
46
37
|
console.log("Consent accepted:", prefs);
|
|
47
|
-
|
|
38
|
+
setConcentState(prefs);
|
|
48
39
|
};
|
|
49
40
|
|
|
50
41
|
const handleConsentRejected = () => {
|
|
51
42
|
console.log("Consent rejected");
|
|
43
|
+
setConcentState(null);
|
|
52
44
|
// disable analytics scripts, etc.
|
|
53
45
|
};
|
|
54
46
|
|
|
@@ -234,7 +226,17 @@ export function AuthScapeApp ({Component, layout, loadingLayout, pageProps, muiT
|
|
|
234
226
|
|
|
235
227
|
useEffect(() => {
|
|
236
228
|
|
|
237
|
-
|
|
229
|
+
let enableAnalytics = false;
|
|
230
|
+
const stored = localStorage.getItem("gdpr-consent");
|
|
231
|
+
if (stored) {
|
|
232
|
+
const prefs = JSON.parse(stored);
|
|
233
|
+
if (prefs.analytics)
|
|
234
|
+
{
|
|
235
|
+
enableAnalytics = true;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if ((frontEndLoadedState && !enableConsentDialog) || (frontEndLoadedState && enableConsentDialog && enableAnalytics))
|
|
238
240
|
{
|
|
239
241
|
if (pageProps.googleAnalytics4Code != null)
|
|
240
242
|
{
|
|
@@ -290,7 +292,7 @@ export function AuthScapeApp ({Component, layout, loadingLayout, pageProps, muiT
|
|
|
290
292
|
}
|
|
291
293
|
}
|
|
292
294
|
|
|
293
|
-
}, [frontEndLoadedState]);
|
|
295
|
+
}, [frontEndLoadedState, concentState]);
|
|
294
296
|
|
|
295
297
|
const validateUserSignedIn = async () => {
|
|
296
298
|
|
|
@@ -492,16 +494,18 @@ export function AuthScapeApp ({Component, layout, loadingLayout, pageProps, muiT
|
|
|
492
494
|
|
|
493
495
|
</Head>
|
|
494
496
|
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
{
|
|
502
|
-
{id: "
|
|
503
|
-
|
|
504
|
-
|
|
497
|
+
{enableConsentDialog &&
|
|
498
|
+
<GDPRConsentDialog
|
|
499
|
+
onAccept={handleConsentAccepted}
|
|
500
|
+
onReject={handleConsentRejected}
|
|
501
|
+
enableAnalytics={true}
|
|
502
|
+
enableMarketing={false}
|
|
503
|
+
// additionalPrivacyFeatures={[
|
|
504
|
+
// {id: "danceParty", title: "Dance Party", description: "Hello world this is about the feature", checked: true },
|
|
505
|
+
// {id: "frog", title: "Able to see Frogs", description: "Frogs will appear on your screen", checked: true }
|
|
506
|
+
// ]}
|
|
507
|
+
/>
|
|
508
|
+
}
|
|
505
509
|
|
|
506
510
|
<ThemeProvider theme={muiTheme}>
|
|
507
511
|
{frontEndLoadedState != null && frontEndLoadedState && pathname != "/signin-oidc" &&
|
|
@@ -9,13 +9,13 @@ import {
|
|
|
9
9
|
Collapse,
|
|
10
10
|
} from "@mui/material";
|
|
11
11
|
|
|
12
|
-
export
|
|
12
|
+
export const GDPRConsentDialog = ({
|
|
13
13
|
onAccept,
|
|
14
14
|
onReject,
|
|
15
15
|
enableAnalytics = true,
|
|
16
16
|
enableMarketing = true,
|
|
17
17
|
additionalPrivacyFeatures = []
|
|
18
|
-
}) {
|
|
18
|
+
}) => {
|
|
19
19
|
const initialPreferences = {
|
|
20
20
|
necessary: true,
|
|
21
21
|
analytics: enableAnalytics,
|