authscape 1.0.291 → 1.0.294
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 -24
- package/package.json +1 -1
- package/src/components/AuthScapeApp.js +40 -40
- package/src/services/setupOEMProps.js +7 -0
package/index.js
CHANGED
|
@@ -12,6 +12,7 @@ var _reactToastify = require("react-toastify");
|
|
|
12
12
|
var _router = require("next/router");
|
|
13
13
|
var _styles = require("@mui/material/styles");
|
|
14
14
|
var _material = require("@mui/material");
|
|
15
|
+
var _head = _interopRequireDefault(require("next/head"));
|
|
15
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
16
17
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -22,6 +23,8 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
22
23
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
23
24
|
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
24
25
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
26
|
+
// import { apiService, setupOEMProps, OEMStyleSheet, AuthorizationComponent, authService, logEvent, init, signInValidator } from 'authscape';
|
|
27
|
+
|
|
25
28
|
function AuthScapeApp(_ref) {
|
|
26
29
|
var Component = _ref.Component,
|
|
27
30
|
pageProps = _ref.pageProps,
|
|
@@ -35,7 +38,7 @@ function AuthScapeApp(_ref) {
|
|
|
35
38
|
onAuthenticationLoaded = _ref$onAuthentication === void 0 ? null : _ref$onAuthentication,
|
|
36
39
|
_ref$children = _ref.children,
|
|
37
40
|
children = _ref$children === void 0 ? null : _ref$children;
|
|
38
|
-
var _useState = (0, _react.useState)(
|
|
41
|
+
var _useState = (0, _react.useState)(false),
|
|
39
42
|
_useState2 = _slicedToArray(_useState, 2),
|
|
40
43
|
isLoading = _useState2[0],
|
|
41
44
|
setIsLoading = _useState2[1];
|
|
@@ -54,37 +57,34 @@ function AuthScapeApp(_ref) {
|
|
|
54
57
|
var router = (0, _router.useRouter)();
|
|
55
58
|
(0, _react.useEffect)(function () {}, [loadedUser]);
|
|
56
59
|
(0, _react.useEffect)(function () {
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
// analytics
|
|
60
|
-
if (loadedUser) {
|
|
60
|
+
if (loadedUser && router.isReady) {
|
|
61
61
|
if (process.env.googleAnalytics4 != null) {
|
|
62
62
|
init(process.env.googleAnalytics4);
|
|
63
63
|
}
|
|
64
64
|
if (router.query.r != null) {
|
|
65
65
|
localStorage.setItem("ref", router.query.r);
|
|
66
66
|
}
|
|
67
|
-
}
|
|
68
67
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
} else
|
|
74
|
-
|
|
68
|
+
// sign in validation
|
|
69
|
+
if (router.query.code != null) {
|
|
70
|
+
setLoadingLogin(true);
|
|
71
|
+
signInValidator(router.query.code);
|
|
72
|
+
} else {
|
|
73
|
+
if (enforceLoggedIn) {
|
|
74
|
+
if (currentUser == null) {
|
|
75
|
+
authService().login();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
|
-
|
|
78
|
-
// sign in validation
|
|
79
|
-
if (router.query.code != null) {
|
|
80
|
-
setLoadingLogin(true);
|
|
81
|
-
signInValidator(router.query.code);
|
|
82
|
-
} else if (router.query.signupPass != null) {
|
|
83
|
-
setLoadingLogin(true);
|
|
84
|
-
authService().login();
|
|
85
|
-
}
|
|
86
80
|
}, [loadedUser, router.isReady]);
|
|
87
|
-
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(
|
|
81
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_head["default"], null, /*#__PURE__*/_react["default"].createElement("meta", {
|
|
82
|
+
name: "viewport",
|
|
83
|
+
content: "width=device-width, initial-scale=1"
|
|
84
|
+
}), pageProps != null && pageProps.host != null && /*#__PURE__*/_react["default"].createElement("link", {
|
|
85
|
+
href: process.env.apiUri + "/api/WhiteLabel/GetDataFromRecord?domain=" + pageProps.host,
|
|
86
|
+
rel: "stylesheet"
|
|
87
|
+
})), /*#__PURE__*/_react["default"].createElement(_styles.ThemeProvider, {
|
|
88
88
|
theme: muiTheme
|
|
89
89
|
}, loadingLogin && /*#__PURE__*/_react["default"].createElement(_material.Box, null, "Please wait. Loading..."), !loadingLogin && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(AuthorizationComponent, {
|
|
90
90
|
setCurrentUser: setCurrentUser,
|
|
@@ -4277,7 +4277,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
|
4277
4277
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
4278
4278
|
var setupOEMProps = /*#__PURE__*/function () {
|
|
4279
4279
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
4280
|
-
var Component, ctx, pageProps, host;
|
|
4280
|
+
var Component, ctx, pageProps, host, response;
|
|
4281
4281
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
4282
4282
|
while (1) switch (_context.prev = _context.next) {
|
|
4283
4283
|
case 0:
|
|
@@ -4298,8 +4298,17 @@ var setupOEMProps = /*#__PURE__*/function () {
|
|
|
4298
4298
|
} else {
|
|
4299
4299
|
pageProps.host = "https://" + ctx.req.headers.host;
|
|
4300
4300
|
}
|
|
4301
|
+
|
|
4302
|
+
// get the companyId
|
|
4303
|
+
_context.next = 10;
|
|
4304
|
+
return apiService().get(process.env.apiUri + "/api/WhiteLabel/GetCompanyIdFromDomain?domain=" + pageProps.host);
|
|
4305
|
+
case 10:
|
|
4306
|
+
response = _context.sent;
|
|
4307
|
+
if (response != null && response.status == 200) {
|
|
4308
|
+
pageProps.oemCompanyId = response.data;
|
|
4309
|
+
}
|
|
4301
4310
|
return _context.abrupt("return", pageProps);
|
|
4302
|
-
case
|
|
4311
|
+
case 13:
|
|
4303
4312
|
case "end":
|
|
4304
4313
|
return _context.stop();
|
|
4305
4314
|
}
|
package/package.json
CHANGED
|
@@ -5,10 +5,13 @@ import { ToastContainer, toast } from 'react-toastify';
|
|
|
5
5
|
import { useRouter } from 'next/router';
|
|
6
6
|
import { ThemeProvider } from '@mui/material/styles';
|
|
7
7
|
import { Box } from '@mui/material';
|
|
8
|
+
import Head from "next/head";
|
|
9
|
+
// import { apiService, setupOEMProps, OEMStyleSheet, AuthorizationComponent, authService, logEvent, init, signInValidator } from 'authscape';
|
|
10
|
+
|
|
8
11
|
|
|
9
12
|
export function AuthScapeApp({Component, pageProps, muiTheme = {}, enforceLoggedIn = false, enableAuth = true, onAuthenticationLoaded = null, children = null}) {
|
|
10
13
|
|
|
11
|
-
const [isLoading, setIsLoading] = useState(
|
|
14
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
12
15
|
const [loadedUser, setLoadedUser] = useState(false);
|
|
13
16
|
const [currentUser, setCurrentUser] = useState(null);
|
|
14
17
|
const [loadingLogin, setLoadingLogin] = useState(false);
|
|
@@ -21,54 +24,51 @@ export function AuthScapeApp({Component, pageProps, muiTheme = {}, enforceLogged
|
|
|
21
24
|
|
|
22
25
|
useEffect(() => {
|
|
23
26
|
|
|
24
|
-
if(
|
|
25
|
-
|
|
26
|
-
// analytics
|
|
27
|
-
if (loadedUser)
|
|
28
|
-
{
|
|
29
|
-
if (process.env.googleAnalytics4 != null)
|
|
30
|
-
{
|
|
31
|
-
init(process.env.googleAnalytics4);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (router.query.r != null)
|
|
35
|
-
{
|
|
36
|
-
localStorage.setItem("ref", router.query.r);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// ensure login is hit
|
|
42
|
-
if (loadedUser && router.isReady && enforceLoggedIn)
|
|
27
|
+
if (loadedUser && router.isReady)
|
|
43
28
|
{
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
29
|
+
if (process.env.googleAnalytics4 != null)
|
|
30
|
+
{
|
|
31
|
+
init(process.env.googleAnalytics4);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (router.query.r != null)
|
|
35
|
+
{
|
|
36
|
+
localStorage.setItem("ref", router.query.r);
|
|
37
|
+
}
|
|
53
38
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
39
|
+
// sign in validation
|
|
40
|
+
if (router.query.code != null)
|
|
41
|
+
{
|
|
42
|
+
setLoadingLogin(true);
|
|
43
|
+
signInValidator(router.query.code);
|
|
44
|
+
}
|
|
45
|
+
else
|
|
46
|
+
{
|
|
47
|
+
if (enforceLoggedIn)
|
|
48
|
+
{
|
|
49
|
+
if (currentUser == null)
|
|
50
|
+
{
|
|
51
|
+
authService().login();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
64
55
|
}
|
|
65
|
-
|
|
66
56
|
|
|
67
57
|
}, [loadedUser, router.isReady])
|
|
68
58
|
|
|
69
59
|
|
|
70
60
|
return (
|
|
71
61
|
<>
|
|
62
|
+
<Head>
|
|
63
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
64
|
+
{(pageProps != null && pageProps.host != null) &&
|
|
65
|
+
<link
|
|
66
|
+
href={process.env.apiUri + "/api/WhiteLabel/GetDataFromRecord?domain=" + pageProps.host}
|
|
67
|
+
rel="stylesheet"
|
|
68
|
+
/>
|
|
69
|
+
}
|
|
70
|
+
</Head>
|
|
71
|
+
|
|
72
72
|
<ThemeProvider theme={muiTheme}>
|
|
73
73
|
|
|
74
74
|
{loadingLogin &&
|
|
@@ -18,6 +18,13 @@ export const setupOEMProps = async ({Component, ctx}) => {
|
|
|
18
18
|
pageProps.host = "https://" + ctx.req.headers.host;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
// get the companyId
|
|
22
|
+
let response = await apiService().get(process.env.apiUri + "/api/WhiteLabel/GetCompanyIdFromDomain?domain=" + pageProps.host);
|
|
23
|
+
if (response != null && response.status == 200)
|
|
24
|
+
{
|
|
25
|
+
pageProps.oemCompanyId = response.data;
|
|
26
|
+
}
|
|
27
|
+
|
|
21
28
|
return pageProps;
|
|
22
29
|
}
|
|
23
30
|
|