authscape 1.0.161 → 1.0.170
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 +214 -23
- package/package.json +3 -1
- package/src/components/AuthScapeApp.js +97 -0
- package/src/components/StripePayment.js +2 -2
- package/src/services/analytics.js +56 -0
- package/src/services/apiService.js +9 -9
- package/src/services/authService.js +7 -7
- package/src/services/authorizationComponent.js +11 -4
- package/src/services/signInValidator.js +2 -2
package/index.js
CHANGED
|
@@ -1,5 +1,105 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.AuthScapeApp = AuthScapeApp;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _CircularProgress = _interopRequireDefault(require("@mui/material/CircularProgress"));
|
|
10
|
+
var _Backdrop = _interopRequireDefault(require("@mui/material/Backdrop"));
|
|
11
|
+
require("react-toastify/dist/ReactToastify.css");
|
|
12
|
+
var _reactToastify = require("react-toastify");
|
|
13
|
+
var _router = require("next/router");
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
+
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); }
|
|
16
|
+
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; }
|
|
17
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
18
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
19
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
20
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
21
|
+
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; }
|
|
22
|
+
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; } }
|
|
23
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
24
|
+
function AuthScapeApp(_ref) {
|
|
25
|
+
var Component = _ref.Component,
|
|
26
|
+
pageProps = _ref.pageProps,
|
|
27
|
+
_ref$muiTheme = _ref.muiTheme,
|
|
28
|
+
muiTheme = _ref$muiTheme === void 0 ? null : _ref$muiTheme,
|
|
29
|
+
_ref$onAuthentication = _ref.onAuthenticationLoaded,
|
|
30
|
+
onAuthenticationLoaded = _ref$onAuthentication === void 0 ? null : _ref$onAuthentication;
|
|
31
|
+
var _useState = (0, _react.useState)(false),
|
|
32
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
33
|
+
isLoading = _useState2[0],
|
|
34
|
+
setIsLoading = _useState2[1];
|
|
35
|
+
var _useState3 = (0, _react.useState)(false),
|
|
36
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
37
|
+
loadedUser = _useState4[0],
|
|
38
|
+
setLoadedUser = _useState4[1];
|
|
39
|
+
var _useState5 = (0, _react.useState)(null),
|
|
40
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
41
|
+
currentUser = _useState6[0],
|
|
42
|
+
setCurrentUser = _useState6[1];
|
|
43
|
+
var _useState7 = (0, _react.useState)(false),
|
|
44
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
45
|
+
loadingLogin = _useState8[0],
|
|
46
|
+
setLoadingLogin = _useState8[1];
|
|
47
|
+
var router = (0, _router.useRouter)();
|
|
48
|
+
// const [openLoginModal, setOpenLoginModal] = useState(false);
|
|
49
|
+
|
|
50
|
+
(0, _react.useEffect)(function () {
|
|
51
|
+
if (loadedUser) {
|
|
52
|
+
if (process.env.authscape.googleAnalytics4 != null) {
|
|
53
|
+
init(process.env.authscape.googleAnalytics4);
|
|
54
|
+
}
|
|
55
|
+
if (router.query.r != null) {
|
|
56
|
+
localStorage.setItem("ref", router.query.r);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}, [loadedUser]);
|
|
60
|
+
(0, _react.useEffect)(function () {
|
|
61
|
+
if (!router.isReady) return;
|
|
62
|
+
if (router.query.code != null) {
|
|
63
|
+
setLoadingLogin(true);
|
|
64
|
+
signInValidator(router.query.code);
|
|
65
|
+
} else if (router.query.signupPass != null) {
|
|
66
|
+
setLoadingLogin(true);
|
|
67
|
+
authService().login();
|
|
68
|
+
}
|
|
69
|
+
}, [router.isReady]);
|
|
70
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(ThemeProvider, {
|
|
71
|
+
theme: muiTheme
|
|
72
|
+
}, loadingLogin && /*#__PURE__*/_react["default"].createElement(Box, null, "Please wait. Loading..."), !loadingLogin && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(AuthorizationComponent, {
|
|
73
|
+
setCurrentUser: setCurrentUser,
|
|
74
|
+
isEnabled: process.env.authscape.enableAuth,
|
|
75
|
+
userLoaded: function userLoaded() {
|
|
76
|
+
setLoadedUser(true);
|
|
77
|
+
if (onAuthenticationLoaded != null) {
|
|
78
|
+
onAuthenticationLoaded(currentUser);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}, /*#__PURE__*/_react["default"].createElement(Component, _extends({}, pageProps, {
|
|
82
|
+
currentUser: currentUser,
|
|
83
|
+
toast: _reactToastify.toast,
|
|
84
|
+
setIsLoading: setIsLoading,
|
|
85
|
+
loadedUser: loadedUser,
|
|
86
|
+
logEvent: logEvent
|
|
87
|
+
}))), /*#__PURE__*/_react["default"].createElement(_Backdrop["default"], {
|
|
88
|
+
sx: {
|
|
89
|
+
color: '#fff',
|
|
90
|
+
zIndex: 99999
|
|
91
|
+
},
|
|
92
|
+
open: isLoading
|
|
93
|
+
}, /*#__PURE__*/_react["default"].createElement(_CircularProgress["default"], {
|
|
94
|
+
color: "inherit"
|
|
95
|
+
})), /*#__PURE__*/_react["default"].createElement(_reactToastify.ToastContainer, null))), process.env.authscape.microsoftClarityTrackingCode != null && /*#__PURE__*/_react["default"].createElement("script", {
|
|
96
|
+
dangerouslySetInnerHTML: {
|
|
97
|
+
__html: "\n (function(c,l,a,r,i,t,y){\n c[a] = c[a] || function () { (c[a].q = c[a].q || []).push(arguments) };\n t=l.createElement(r);\n t.async=1;\n t.src=\"https://www.clarity.ms/tag/\"+i;\n y=l.getElementsByTagName(r)[0];\n y.parentNode.insertBefore(t,y);\n })(window, document, \"clarity\", \"script\", \"" + process.env.authscape.microsoftClarityTrackingCode + "\");"
|
|
98
|
+
}
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
"use strict";
|
|
102
|
+
|
|
3
103
|
Object.defineProperty(exports, "__esModule", {
|
|
4
104
|
value: true
|
|
5
105
|
});
|
|
@@ -1274,7 +1374,7 @@ var CheckoutForm = function CheckoutForm(_ref) {
|
|
|
1274
1374
|
elements: elements,
|
|
1275
1375
|
redirect: "if_required"
|
|
1276
1376
|
// confirmParams: {
|
|
1277
|
-
// return_url: process.env.
|
|
1377
|
+
// return_url: process.env.authscape.websiteBaseUri + '/confirmSetup?redirectUrl=' + encodeURIComponent(window.location.search),
|
|
1278
1378
|
// },
|
|
1279
1379
|
});
|
|
1280
1380
|
case 7:
|
|
@@ -1331,7 +1431,7 @@ var CheckoutForm = function CheckoutForm(_ref) {
|
|
|
1331
1431
|
elements: elements,
|
|
1332
1432
|
redirect: "if_required",
|
|
1333
1433
|
confirmParams: {
|
|
1334
|
-
return_url: process.env.
|
|
1434
|
+
return_url: process.env.authscape.websiteBaseUri + '/confirmPayment?redirectUrl=' + encodeURIComponent(window.location.search)
|
|
1335
1435
|
}
|
|
1336
1436
|
});
|
|
1337
1437
|
case 37:
|
|
@@ -1679,6 +1779,87 @@ var StripePayment = function StripePayment() {
|
|
|
1679
1779
|
exports.StripePayment = StripePayment;
|
|
1680
1780
|
"use strict";
|
|
1681
1781
|
|
|
1782
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1783
|
+
value: true
|
|
1784
|
+
});
|
|
1785
|
+
exports.init = init;
|
|
1786
|
+
exports.logEvent = logEvent;
|
|
1787
|
+
exports.logPageView = logPageView;
|
|
1788
|
+
exports.logPageViews = logPageViews;
|
|
1789
|
+
exports.logPurchase = logPurchase;
|
|
1790
|
+
var _router = _interopRequireDefault(require("next/router"));
|
|
1791
|
+
var _ga4React = _interopRequireDefault(require("ga-4-react"));
|
|
1792
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
1793
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
1794
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
1795
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
1796
|
+
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); }); }; }
|
|
1797
|
+
var ga4react;
|
|
1798
|
+
function init(_x) {
|
|
1799
|
+
return _init.apply(this, arguments);
|
|
1800
|
+
}
|
|
1801
|
+
function _init() {
|
|
1802
|
+
_init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(G) {
|
|
1803
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1804
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1805
|
+
case 0:
|
|
1806
|
+
if (!(!_ga4React["default"].isInitialized() && G && process.browser)) {
|
|
1807
|
+
_context.next = 11;
|
|
1808
|
+
break;
|
|
1809
|
+
}
|
|
1810
|
+
ga4react = new _ga4React["default"](G, {
|
|
1811
|
+
debug_mode: !process.env.production
|
|
1812
|
+
});
|
|
1813
|
+
_context.prev = 2;
|
|
1814
|
+
_context.next = 5;
|
|
1815
|
+
return ga4react.initialize();
|
|
1816
|
+
case 5:
|
|
1817
|
+
logPageViews();
|
|
1818
|
+
_context.next = 11;
|
|
1819
|
+
break;
|
|
1820
|
+
case 8:
|
|
1821
|
+
_context.prev = 8;
|
|
1822
|
+
_context.t0 = _context["catch"](2);
|
|
1823
|
+
console.error(_context.t0);
|
|
1824
|
+
case 11:
|
|
1825
|
+
case "end":
|
|
1826
|
+
return _context.stop();
|
|
1827
|
+
}
|
|
1828
|
+
}, _callee, null, [[2, 8]]);
|
|
1829
|
+
}));
|
|
1830
|
+
return _init.apply(this, arguments);
|
|
1831
|
+
}
|
|
1832
|
+
function logPageView() {
|
|
1833
|
+
if (ga4react != null) {
|
|
1834
|
+
ga4react.pageview(window.location.pathname);
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
function logPageViews() {
|
|
1838
|
+
if (ga4react != null) {
|
|
1839
|
+
logPageView();
|
|
1840
|
+
_router["default"].events.on('routeChangeComplete', function () {
|
|
1841
|
+
logPageView();
|
|
1842
|
+
});
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
function logEvent(category, action, label) {
|
|
1846
|
+
if (ga4react != null) {
|
|
1847
|
+
ga4react.event(action, label, category);
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
function logPurchase(transactionId, amount, tax, items) {
|
|
1851
|
+
if (ga4react != null) {
|
|
1852
|
+
ga4react.gtag("event", "purchase", {
|
|
1853
|
+
transaction_id: transactionId,
|
|
1854
|
+
value: amount,
|
|
1855
|
+
tax: tax,
|
|
1856
|
+
currency: "USD",
|
|
1857
|
+
items: items
|
|
1858
|
+
});
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
"use strict";
|
|
1862
|
+
|
|
1682
1863
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
1683
1864
|
Object.defineProperty(exports, "__esModule", {
|
|
1684
1865
|
value: true
|
|
@@ -1746,7 +1927,7 @@ var RefreshToken = /*#__PURE__*/function () {
|
|
|
1746
1927
|
accessToken = (0, _nookies.parseCookies)().access_token || '';
|
|
1747
1928
|
refreshToken = (0, _nookies.parseCookies)().refresh_token || '';
|
|
1748
1929
|
_context2.next = 4;
|
|
1749
|
-
return instance.post(process.env.
|
|
1930
|
+
return instance.post(process.env.authscape.authorityUri + "/connect/token", _queryString["default"].stringify({
|
|
1750
1931
|
grant_type: 'refresh_token',
|
|
1751
1932
|
client_id: process.env.client_id,
|
|
1752
1933
|
client_secret: process.env.client_secret,
|
|
@@ -1768,7 +1949,7 @@ var RefreshToken = /*#__PURE__*/function () {
|
|
|
1768
1949
|
return (0, _nookies.setCookie)(null, "access_token", response.data.access_token, {
|
|
1769
1950
|
maxAge: 2147483647,
|
|
1770
1951
|
path: '/',
|
|
1771
|
-
domain: process.env.cookieDomain,
|
|
1952
|
+
domain: process.env.authscape.cookieDomain,
|
|
1772
1953
|
secure: true
|
|
1773
1954
|
});
|
|
1774
1955
|
case 9:
|
|
@@ -1776,7 +1957,7 @@ var RefreshToken = /*#__PURE__*/function () {
|
|
|
1776
1957
|
return (0, _nookies.setCookie)(null, "expires_in", response.data.expires_in, {
|
|
1777
1958
|
maxAge: 2147483647,
|
|
1778
1959
|
path: '/',
|
|
1779
|
-
domain: process.env.cookieDomain,
|
|
1960
|
+
domain: process.env.authscape.cookieDomain,
|
|
1780
1961
|
secure: true
|
|
1781
1962
|
});
|
|
1782
1963
|
case 11:
|
|
@@ -1784,7 +1965,7 @@ var RefreshToken = /*#__PURE__*/function () {
|
|
|
1784
1965
|
return (0, _nookies.setCookie)(null, "refresh_token", response.data.refresh_token, {
|
|
1785
1966
|
maxAge: 2147483647,
|
|
1786
1967
|
path: '/',
|
|
1787
|
-
domain: process.env.cookieDomain,
|
|
1968
|
+
domain: process.env.authscape.cookieDomain,
|
|
1788
1969
|
secure: true
|
|
1789
1970
|
});
|
|
1790
1971
|
case 13:
|
|
@@ -1799,11 +1980,11 @@ var RefreshToken = /*#__PURE__*/function () {
|
|
|
1799
1980
|
}();
|
|
1800
1981
|
var apiService = function apiService() {
|
|
1801
1982
|
var ctx = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
1802
|
-
var env = process.env.
|
|
1983
|
+
var env = process.env.authscape.stage;
|
|
1803
1984
|
if (env == "development") {
|
|
1804
1985
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|
1805
1986
|
}
|
|
1806
|
-
var baseUri = process.env.
|
|
1987
|
+
var baseUri = process.env.authscape.apiUri + "/api";
|
|
1807
1988
|
var instance = _axios["default"].create({
|
|
1808
1989
|
baseURL: baseUri,
|
|
1809
1990
|
//timeout: 10000,
|
|
@@ -1847,17 +2028,17 @@ var apiService = function apiService() {
|
|
|
1847
2028
|
(0, _nookies.destroyCookie)(null, "access_token", {
|
|
1848
2029
|
maxAge: 2147483647,
|
|
1849
2030
|
path: '/',
|
|
1850
|
-
domain: process.env.cookieDomain
|
|
2031
|
+
domain: process.env.authscape.cookieDomain
|
|
1851
2032
|
});
|
|
1852
2033
|
(0, _nookies.destroyCookie)(null, "refresh_token", {
|
|
1853
2034
|
maxAge: 2147483647,
|
|
1854
2035
|
path: '/',
|
|
1855
|
-
domain: process.env.cookieDomain
|
|
2036
|
+
domain: process.env.authscape.cookieDomain
|
|
1856
2037
|
});
|
|
1857
2038
|
(0, _nookies.destroyCookie)(null, "expires_in", {
|
|
1858
2039
|
maxAge: 2147483647,
|
|
1859
2040
|
path: '/',
|
|
1860
|
-
domain: process.env.cookieDomain
|
|
2041
|
+
domain: process.env.authscape.cookieDomain
|
|
1861
2042
|
});
|
|
1862
2043
|
}
|
|
1863
2044
|
return _context3.abrupt("return", Promise.reject(error));
|
|
@@ -2120,6 +2301,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
2120
2301
|
|
|
2121
2302
|
function AuthorizationComponent(_ref) {
|
|
2122
2303
|
var children = _ref.children,
|
|
2304
|
+
isEnabled = _ref.isEnabled,
|
|
2123
2305
|
setCurrentUser = _ref.setCurrentUser,
|
|
2124
2306
|
userLoaded = _ref.userLoaded,
|
|
2125
2307
|
isLoading = _ref.isLoading;
|
|
@@ -2134,17 +2316,26 @@ function AuthorizationComponent(_ref) {
|
|
|
2134
2316
|
while (1) switch (_context.prev = _context.next) {
|
|
2135
2317
|
case 0:
|
|
2136
2318
|
setLoaded(true);
|
|
2137
|
-
|
|
2319
|
+
if (!isEnabled) {
|
|
2320
|
+
_context.next = 8;
|
|
2321
|
+
break;
|
|
2322
|
+
}
|
|
2323
|
+
_context.next = 4;
|
|
2138
2324
|
return apiService().GetCurrentUser();
|
|
2139
|
-
case
|
|
2325
|
+
case 4:
|
|
2140
2326
|
usr = _context.sent;
|
|
2141
2327
|
if (usr != null) {
|
|
2142
2328
|
setCurrentUser(usr);
|
|
2143
2329
|
} else {
|
|
2144
2330
|
setCurrentUser(null);
|
|
2145
2331
|
}
|
|
2332
|
+
_context.next = 9;
|
|
2333
|
+
break;
|
|
2334
|
+
case 8:
|
|
2335
|
+
setCurrentUser(null);
|
|
2336
|
+
case 9:
|
|
2146
2337
|
userLoaded();
|
|
2147
|
-
case
|
|
2338
|
+
case 10:
|
|
2148
2339
|
case "end":
|
|
2149
2340
|
return _context.stop();
|
|
2150
2341
|
}
|
|
@@ -2249,7 +2440,7 @@ var authService = function authService() {
|
|
|
2249
2440
|
challenge = _context2.sent;
|
|
2250
2441
|
window.localStorage.setItem("verifier", verifier);
|
|
2251
2442
|
redirectUri = window.location.origin + "/signin-oidc";
|
|
2252
|
-
loginUri = process.env.
|
|
2443
|
+
loginUri = process.env.authscape.authorityUri + "/connect/authorize?response_type=code&state=" + state + "&client_id=" + process.env.client_id + "&scope=email%20openid%20offline_access%20profile%20api1&redirect_uri=" + redirectUri + "&code_challenge=" + challenge + "&code_challenge_method=S256";
|
|
2253
2444
|
if (deviceId) {
|
|
2254
2445
|
loginUri += "&deviceId=" + deviceId; // will be for chrome extention and mobile apps later
|
|
2255
2446
|
}
|
|
@@ -2268,13 +2459,13 @@ var authService = function authService() {
|
|
|
2268
2459
|
}(),
|
|
2269
2460
|
signUp: function signUp() {
|
|
2270
2461
|
var redirectUrl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
2271
|
-
var AuthUri = process.env.
|
|
2462
|
+
var AuthUri = process.env.authscape.authorityUri;
|
|
2272
2463
|
var url = "";
|
|
2273
2464
|
if (redirectUrl == null) {
|
|
2274
|
-
url = AuthUri + "/Account/Register?returnUrl=" + window.location.href;
|
|
2465
|
+
url = AuthUri + "/Identity/Account/Register?returnUrl=" + window.location.href;
|
|
2275
2466
|
localStorage.setItem("redirectUri", window.location.href);
|
|
2276
2467
|
} else {
|
|
2277
|
-
url = AuthUri + "/Account/Register?returnUrl=" + redirectUrl;
|
|
2468
|
+
url = AuthUri + "/Identity/Account/Register?returnUrl=" + redirectUrl;
|
|
2278
2469
|
localStorage.setItem("redirectUri", redirectUrl);
|
|
2279
2470
|
}
|
|
2280
2471
|
window.location.href = url;
|
|
@@ -2284,7 +2475,7 @@ var authService = function authService() {
|
|
|
2284
2475
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
2285
2476
|
while (1) switch (_context3.prev = _context3.next) {
|
|
2286
2477
|
case 0:
|
|
2287
|
-
window.location.href = process.env.
|
|
2478
|
+
window.location.href = process.env.authscape.authorityUri + "/Identity/Account/Manage";
|
|
2288
2479
|
case 1:
|
|
2289
2480
|
case "end":
|
|
2290
2481
|
return _context3.stop();
|
|
@@ -2306,8 +2497,8 @@ var authService = function authService() {
|
|
|
2306
2497
|
while (1) switch (_context4.prev = _context4.next) {
|
|
2307
2498
|
case 0:
|
|
2308
2499
|
redirectUri = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : null;
|
|
2309
|
-
AuthUri = process.env.
|
|
2310
|
-
cookieDomain = process.env.cookieDomain;
|
|
2500
|
+
AuthUri = process.env.authscape.authorityUri;
|
|
2501
|
+
cookieDomain = process.env.authscape.cookieDomain;
|
|
2311
2502
|
(0, _nookies.destroyCookie)({}, "access_token", {
|
|
2312
2503
|
maxAge: 2147483647,
|
|
2313
2504
|
path: '/',
|
|
@@ -2384,13 +2575,13 @@ var signInValidator = /*#__PURE__*/function () {
|
|
|
2384
2575
|
code_verifier: codeVerifier
|
|
2385
2576
|
});
|
|
2386
2577
|
_context.next = 6;
|
|
2387
|
-
return _axios["default"].post(process.env.
|
|
2578
|
+
return _axios["default"].post(process.env.authscape.authorityUri + '/connect/token', queryString, {
|
|
2388
2579
|
headers: headers
|
|
2389
2580
|
});
|
|
2390
2581
|
case 6:
|
|
2391
2582
|
response = _context.sent;
|
|
2392
2583
|
window.localStorage.removeItem("verifier");
|
|
2393
|
-
domain = process.env.cookieDomain;
|
|
2584
|
+
domain = process.env.authscape.cookieDomain;
|
|
2394
2585
|
_context.next = 11;
|
|
2395
2586
|
return (0, _nookies.setCookie)(null, "access_token", response.data.access_token, {
|
|
2396
2587
|
maxAge: 2147483647,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "authscape",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.170",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"@stripe/stripe-js": "^1.32.0",
|
|
33
33
|
"axios": "^0.27.2",
|
|
34
34
|
"eslint-config-next": "^13.3.2",
|
|
35
|
+
"ga-4-react": "^0.1.281",
|
|
35
36
|
"html2canvas": "^1.4.1",
|
|
36
37
|
"js-file-download": "^0.4.12",
|
|
37
38
|
"jspdf": "^2.5.1",
|
|
@@ -41,6 +42,7 @@
|
|
|
41
42
|
"react-cool-onclickoutside": "^1.7.0",
|
|
42
43
|
"react-data-table-component": "^7.5.2",
|
|
43
44
|
"react-hook-form": "^7.44.2",
|
|
45
|
+
"react-toastify": "^9.1.3",
|
|
44
46
|
"use-places-autocomplete": "^4.0.0"
|
|
45
47
|
}
|
|
46
48
|
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React, { useEffect, useState, useRef } from 'react';
|
|
2
|
+
import CircularProgress from '@mui/material/CircularProgress';
|
|
3
|
+
import Backdrop from '@mui/material/Backdrop';
|
|
4
|
+
import 'react-toastify/dist/ReactToastify.css';
|
|
5
|
+
import { ToastContainer, toast } from 'react-toastify';
|
|
6
|
+
import { useRouter } from 'next/router';
|
|
7
|
+
|
|
8
|
+
export function AuthScapeApp({Component, pageProps, muiTheme = null, onAuthenticationLoaded = null}) {
|
|
9
|
+
|
|
10
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
11
|
+
const [loadedUser, setLoadedUser] = useState(false);
|
|
12
|
+
const [currentUser, setCurrentUser] = useState(null);
|
|
13
|
+
const [loadingLogin, setLoadingLogin] = useState(false);
|
|
14
|
+
const router = useRouter();
|
|
15
|
+
// const [openLoginModal, setOpenLoginModal] = useState(false);
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (loadedUser)
|
|
19
|
+
{
|
|
20
|
+
if (process.env.authscape.googleAnalytics4 != null)
|
|
21
|
+
{
|
|
22
|
+
init(process.env.authscape.googleAnalytics4);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (router.query.r != null)
|
|
26
|
+
{
|
|
27
|
+
localStorage.setItem("ref", router.query.r);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}, [loadedUser]);
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if(!router.isReady) return;
|
|
34
|
+
|
|
35
|
+
if (router.query.code != null)
|
|
36
|
+
{
|
|
37
|
+
setLoadingLogin(true);
|
|
38
|
+
signInValidator(router.query.code);
|
|
39
|
+
}
|
|
40
|
+
else if (router.query.signupPass != null)
|
|
41
|
+
{
|
|
42
|
+
setLoadingLogin(true);
|
|
43
|
+
authService().login();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
}, [router.isReady]);
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<>
|
|
50
|
+
<ThemeProvider theme={muiTheme}>
|
|
51
|
+
|
|
52
|
+
{loadingLogin &&
|
|
53
|
+
<Box>
|
|
54
|
+
Please wait. Loading...
|
|
55
|
+
</Box>
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
{!loadingLogin &&
|
|
59
|
+
<>
|
|
60
|
+
<AuthorizationComponent setCurrentUser={setCurrentUser} isEnabled={process.env.authscape.enableAuth} userLoaded={() => {
|
|
61
|
+
setLoadedUser(true);
|
|
62
|
+
|
|
63
|
+
if (onAuthenticationLoaded != null)
|
|
64
|
+
{
|
|
65
|
+
onAuthenticationLoaded(currentUser);
|
|
66
|
+
}
|
|
67
|
+
}}>
|
|
68
|
+
<Component {...pageProps} currentUser={currentUser} toast={toast} setIsLoading={setIsLoading} loadedUser={loadedUser} logEvent={logEvent} />
|
|
69
|
+
</AuthorizationComponent>
|
|
70
|
+
|
|
71
|
+
<Backdrop sx={{ color: '#fff', zIndex: 99999 }} open={isLoading}>
|
|
72
|
+
<CircularProgress color="inherit" />
|
|
73
|
+
</Backdrop>
|
|
74
|
+
|
|
75
|
+
<ToastContainer />
|
|
76
|
+
</>
|
|
77
|
+
}
|
|
78
|
+
</ThemeProvider>
|
|
79
|
+
|
|
80
|
+
{process.env.authscape.microsoftClarityTrackingCode != null &&
|
|
81
|
+
<script
|
|
82
|
+
dangerouslySetInnerHTML={{
|
|
83
|
+
__html: `
|
|
84
|
+
(function(c,l,a,r,i,t,y){
|
|
85
|
+
c[a] = c[a] || function () { (c[a].q = c[a].q || []).push(arguments) };
|
|
86
|
+
t=l.createElement(r);
|
|
87
|
+
t.async=1;
|
|
88
|
+
t.src="https://www.clarity.ms/tag/"+i;
|
|
89
|
+
y=l.getElementsByTagName(r)[0];
|
|
90
|
+
y.parentNode.insertBefore(t,y);
|
|
91
|
+
})(window, document, "clarity", "script", "` + process.env.authscape.microsoftClarityTrackingCode + `");`,
|
|
92
|
+
}}
|
|
93
|
+
/>
|
|
94
|
+
}
|
|
95
|
+
</>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
@@ -48,7 +48,7 @@ const CheckoutForm = ({payButtonText, clientSecret, onResponse, amount}) => {
|
|
|
48
48
|
elements,
|
|
49
49
|
redirect:"if_required",
|
|
50
50
|
// confirmParams: {
|
|
51
|
-
// return_url: process.env.
|
|
51
|
+
// return_url: process.env.authscape.websiteBaseUri + '/confirmSetup?redirectUrl=' + encodeURIComponent(window.location.search),
|
|
52
52
|
// },
|
|
53
53
|
});
|
|
54
54
|
|
|
@@ -103,7 +103,7 @@ const CheckoutForm = ({payButtonText, clientSecret, onResponse, amount}) => {
|
|
|
103
103
|
elements,
|
|
104
104
|
redirect:"if_required",
|
|
105
105
|
confirmParams: {
|
|
106
|
-
return_url: process.env.
|
|
106
|
+
return_url: process.env.authscape.websiteBaseUri + '/confirmPayment?redirectUrl=' + encodeURIComponent(window.location.search),
|
|
107
107
|
},
|
|
108
108
|
});
|
|
109
109
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import Router from 'next/router';
|
|
2
|
+
import GA4React from 'ga-4-react';
|
|
3
|
+
|
|
4
|
+
let ga4react;
|
|
5
|
+
|
|
6
|
+
export async function init(G) {
|
|
7
|
+
if (!GA4React.isInitialized() && G && process.browser) {
|
|
8
|
+
ga4react = new GA4React(G, { debug_mode: !process.env.production });
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
await ga4react.initialize();
|
|
12
|
+
|
|
13
|
+
logPageViews();
|
|
14
|
+
} catch (error) {
|
|
15
|
+
console.error(error);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function logPageView() {
|
|
21
|
+
if (ga4react != null)
|
|
22
|
+
{
|
|
23
|
+
ga4react.pageview(window.location.pathname);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function logPageViews() {
|
|
28
|
+
if (ga4react != null)
|
|
29
|
+
{
|
|
30
|
+
logPageView();
|
|
31
|
+
|
|
32
|
+
Router.events.on('routeChangeComplete', () => {
|
|
33
|
+
logPageView();
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function logEvent(category, action, label) {
|
|
39
|
+
if (ga4react != null)
|
|
40
|
+
{
|
|
41
|
+
ga4react.event(action, label, category);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function logPurchase(transactionId, amount, tax, items) {
|
|
46
|
+
if (ga4react != null)
|
|
47
|
+
{
|
|
48
|
+
ga4react.gtag("event", "purchase", {
|
|
49
|
+
transaction_id: transactionId,
|
|
50
|
+
value: amount,
|
|
51
|
+
tax: tax,
|
|
52
|
+
currency: "USD",
|
|
53
|
+
items: items
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -40,7 +40,7 @@ const RefreshToken = async (originalRequest, instance) => {
|
|
|
40
40
|
let accessToken = parseCookies().access_token || '';
|
|
41
41
|
let refreshToken = parseCookies().refresh_token || '';
|
|
42
42
|
|
|
43
|
-
let response = await instance.post(process.env.
|
|
43
|
+
let response = await instance.post(process.env.authscape.authorityUri + "/connect/token",
|
|
44
44
|
querystring.stringify({
|
|
45
45
|
grant_type: 'refresh_token',
|
|
46
46
|
client_id: process.env.client_id,
|
|
@@ -61,7 +61,7 @@ const RefreshToken = async (originalRequest, instance) => {
|
|
|
61
61
|
{
|
|
62
62
|
maxAge: 2147483647,
|
|
63
63
|
path: '/',
|
|
64
|
-
domain: process.env.cookieDomain,
|
|
64
|
+
domain: process.env.authscape.cookieDomain,
|
|
65
65
|
secure: true
|
|
66
66
|
});
|
|
67
67
|
|
|
@@ -69,7 +69,7 @@ const RefreshToken = async (originalRequest, instance) => {
|
|
|
69
69
|
{
|
|
70
70
|
maxAge: 2147483647,
|
|
71
71
|
path: '/',
|
|
72
|
-
domain: process.env.cookieDomain,
|
|
72
|
+
domain: process.env.authscape.cookieDomain,
|
|
73
73
|
secure: true
|
|
74
74
|
});
|
|
75
75
|
|
|
@@ -77,7 +77,7 @@ const RefreshToken = async (originalRequest, instance) => {
|
|
|
77
77
|
{
|
|
78
78
|
maxAge: 2147483647,
|
|
79
79
|
path: '/',
|
|
80
|
-
domain: process.env.cookieDomain,
|
|
80
|
+
domain: process.env.authscape.cookieDomain,
|
|
81
81
|
secure: true
|
|
82
82
|
});
|
|
83
83
|
}
|
|
@@ -85,13 +85,13 @@ const RefreshToken = async (originalRequest, instance) => {
|
|
|
85
85
|
|
|
86
86
|
export const apiService = (ctx = null) => {
|
|
87
87
|
|
|
88
|
-
let env = process.env.
|
|
88
|
+
let env = process.env.authscape.stage;
|
|
89
89
|
if (env == "development")
|
|
90
90
|
{
|
|
91
91
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
let baseUri = process.env.
|
|
94
|
+
let baseUri = process.env.authscape.apiUri + "/api";
|
|
95
95
|
|
|
96
96
|
const instance = axios.create({
|
|
97
97
|
baseURL: baseUri,
|
|
@@ -126,19 +126,19 @@ export const apiService = (ctx = null) => {
|
|
|
126
126
|
destroyCookie(null, "access_token", {
|
|
127
127
|
maxAge: 2147483647,
|
|
128
128
|
path: '/',
|
|
129
|
-
domain: process.env.cookieDomain
|
|
129
|
+
domain: process.env.authscape.cookieDomain
|
|
130
130
|
});
|
|
131
131
|
|
|
132
132
|
destroyCookie(null, "refresh_token", {
|
|
133
133
|
maxAge: 2147483647,
|
|
134
134
|
path: '/',
|
|
135
|
-
domain: process.env.cookieDomain
|
|
135
|
+
domain: process.env.authscape.cookieDomain
|
|
136
136
|
});
|
|
137
137
|
|
|
138
138
|
destroyCookie(null, "expires_in", {
|
|
139
139
|
maxAge: 2147483647,
|
|
140
140
|
path: '/',
|
|
141
|
-
domain: process.env.cookieDomain
|
|
141
|
+
domain: process.env.authscape.cookieDomain
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
144
|
|
|
@@ -49,7 +49,7 @@ export const authService = () => {
|
|
|
49
49
|
window.localStorage.setItem("verifier", verifier);
|
|
50
50
|
|
|
51
51
|
let redirectUri = window.location.origin + "/signin-oidc";
|
|
52
|
-
let loginUri = process.env.
|
|
52
|
+
let loginUri = process.env.authscape.authorityUri + "/connect/authorize?response_type=code&state=" + state + "&client_id=" + process.env.client_id + "&scope=email%20openid%20offline_access%20profile%20api1&redirect_uri=" + redirectUri + "&code_challenge=" + challenge + "&code_challenge_method=S256";
|
|
53
53
|
|
|
54
54
|
if (deviceId)
|
|
55
55
|
{
|
|
@@ -60,17 +60,17 @@ export const authService = () => {
|
|
|
60
60
|
},
|
|
61
61
|
signUp: (redirectUrl = null) => {
|
|
62
62
|
|
|
63
|
-
let AuthUri = process.env.
|
|
63
|
+
let AuthUri = process.env.authscape.authorityUri;
|
|
64
64
|
|
|
65
65
|
let url = "";
|
|
66
66
|
if (redirectUrl == null)
|
|
67
67
|
{
|
|
68
|
-
url = AuthUri + "/Account/Register?returnUrl=" + window.location.href;
|
|
68
|
+
url = AuthUri + "/Identity/Account/Register?returnUrl=" + window.location.href;
|
|
69
69
|
localStorage.setItem("redirectUri", window.location.href);
|
|
70
70
|
}
|
|
71
71
|
else
|
|
72
72
|
{
|
|
73
|
-
url = AuthUri + "/Account/Register?returnUrl=" + redirectUrl;
|
|
73
|
+
url = AuthUri + "/Identity/Account/Register?returnUrl=" + redirectUrl;
|
|
74
74
|
localStorage.setItem("redirectUri", redirectUrl);
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -78,13 +78,13 @@ export const authService = () => {
|
|
|
78
78
|
},
|
|
79
79
|
manageAccount: async () => {
|
|
80
80
|
|
|
81
|
-
window.location.href = process.env.
|
|
81
|
+
window.location.href = process.env.authscape.authorityUri + "/Identity/Account/Manage";
|
|
82
82
|
|
|
83
83
|
},
|
|
84
84
|
logout: async (redirectUri = null) => {
|
|
85
85
|
|
|
86
|
-
let AuthUri = process.env.
|
|
87
|
-
let cookieDomain = process.env.cookieDomain;
|
|
86
|
+
let AuthUri = process.env.authscape.authorityUri;
|
|
87
|
+
let cookieDomain = process.env.authscape.cookieDomain;
|
|
88
88
|
|
|
89
89
|
destroyCookie({}, "access_token", {
|
|
90
90
|
maxAge: 2147483647,
|
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
import React, { useEffect, useState, useRef } from 'react';
|
|
2
2
|
//import apiService from './apiService';
|
|
3
3
|
|
|
4
|
-
export function AuthorizationComponent({children, setCurrentUser, userLoaded, isLoading}) {
|
|
4
|
+
export function AuthorizationComponent({children, isEnabled, setCurrentUser, userLoaded, isLoading}) {
|
|
5
5
|
|
|
6
6
|
const [loaded, setLoaded] = useState(false);
|
|
7
7
|
const validateUserSignedIn = async () => {
|
|
8
8
|
|
|
9
9
|
setLoaded(true);
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
if (usr != null)
|
|
11
|
+
if (isEnabled)
|
|
13
12
|
{
|
|
14
|
-
|
|
13
|
+
let usr = await apiService().GetCurrentUser();
|
|
14
|
+
if (usr != null)
|
|
15
|
+
{
|
|
16
|
+
setCurrentUser(usr);
|
|
17
|
+
}
|
|
18
|
+
else
|
|
19
|
+
{
|
|
20
|
+
setCurrentUser(null);
|
|
21
|
+
}
|
|
15
22
|
}
|
|
16
23
|
else
|
|
17
24
|
{
|
|
@@ -19,13 +19,13 @@ export const signInValidator = async (queryCode) => {
|
|
|
19
19
|
code_verifier: codeVerifier
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
let response = await axios.post(process.env.
|
|
22
|
+
let response = await axios.post(process.env.authscape.authorityUri + '/connect/token', queryString, {
|
|
23
23
|
headers: headers
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
window.localStorage.removeItem("verifier");
|
|
27
27
|
|
|
28
|
-
let domain = process.env.cookieDomain;
|
|
28
|
+
let domain = process.env.authscape.cookieDomain;
|
|
29
29
|
|
|
30
30
|
await setCookie(null, "access_token", response.data.access_token,
|
|
31
31
|
{
|