authscape 1.0.162 → 1.0.180
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 +211 -21
- package/package.json +3 -1
- package/src/components/AuthScapeApp.js +96 -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 +5 -5
- package/src/services/authorizationComponent.js +11 -4
- package/src/services/signInValidator.js +2 -2
package/index.js
CHANGED
|
@@ -1,5 +1,104 @@
|
|
|
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
|
+
var _reactToastify = require("react-toastify");
|
|
12
|
+
var _router = require("next/router");
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
|
+
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); }
|
|
15
|
+
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; }
|
|
16
|
+
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); }
|
|
17
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
18
|
+
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."); }
|
|
19
|
+
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); }
|
|
20
|
+
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; }
|
|
21
|
+
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; } }
|
|
22
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
23
|
+
function AuthScapeApp(_ref) {
|
|
24
|
+
var Component = _ref.Component,
|
|
25
|
+
pageProps = _ref.pageProps,
|
|
26
|
+
_ref$muiTheme = _ref.muiTheme,
|
|
27
|
+
muiTheme = _ref$muiTheme === void 0 ? null : _ref$muiTheme,
|
|
28
|
+
_ref$onAuthentication = _ref.onAuthenticationLoaded,
|
|
29
|
+
onAuthenticationLoaded = _ref$onAuthentication === void 0 ? null : _ref$onAuthentication;
|
|
30
|
+
var _useState = (0, _react.useState)(false),
|
|
31
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
32
|
+
isLoading = _useState2[0],
|
|
33
|
+
setIsLoading = _useState2[1];
|
|
34
|
+
var _useState3 = (0, _react.useState)(false),
|
|
35
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
36
|
+
loadedUser = _useState4[0],
|
|
37
|
+
setLoadedUser = _useState4[1];
|
|
38
|
+
var _useState5 = (0, _react.useState)(null),
|
|
39
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
40
|
+
currentUser = _useState6[0],
|
|
41
|
+
setCurrentUser = _useState6[1];
|
|
42
|
+
var _useState7 = (0, _react.useState)(false),
|
|
43
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
44
|
+
loadingLogin = _useState8[0],
|
|
45
|
+
setLoadingLogin = _useState8[1];
|
|
46
|
+
var router = (0, _router.useRouter)();
|
|
47
|
+
// const [openLoginModal, setOpenLoginModal] = useState(false);
|
|
48
|
+
|
|
49
|
+
(0, _react.useEffect)(function () {
|
|
50
|
+
if (loadedUser) {
|
|
51
|
+
if (process.env.authscape.googleAnalytics4 != null) {
|
|
52
|
+
init(process.env.authscape.googleAnalytics4);
|
|
53
|
+
}
|
|
54
|
+
if (router.query.r != null) {
|
|
55
|
+
localStorage.setItem("ref", router.query.r);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}, [loadedUser]);
|
|
59
|
+
(0, _react.useEffect)(function () {
|
|
60
|
+
if (!router.isReady) return;
|
|
61
|
+
if (router.query.code != null) {
|
|
62
|
+
setLoadingLogin(true);
|
|
63
|
+
signInValidator(router.query.code);
|
|
64
|
+
} else if (router.query.signupPass != null) {
|
|
65
|
+
setLoadingLogin(true);
|
|
66
|
+
authService().login();
|
|
67
|
+
}
|
|
68
|
+
}, [router.isReady]);
|
|
69
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(ThemeProvider, {
|
|
70
|
+
theme: muiTheme
|
|
71
|
+
}, loadingLogin && /*#__PURE__*/_react["default"].createElement(Box, null, "Please wait. Loading..."), !loadingLogin && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(AuthorizationComponent, {
|
|
72
|
+
setCurrentUser: setCurrentUser,
|
|
73
|
+
isEnabled: process.env.authscape.enableAuth,
|
|
74
|
+
userLoaded: function userLoaded() {
|
|
75
|
+
setLoadedUser(true);
|
|
76
|
+
if (onAuthenticationLoaded != null) {
|
|
77
|
+
onAuthenticationLoaded(currentUser);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}, /*#__PURE__*/_react["default"].createElement(Component, _extends({}, pageProps, {
|
|
81
|
+
currentUser: currentUser,
|
|
82
|
+
toast: _reactToastify.toast,
|
|
83
|
+
setIsLoading: setIsLoading,
|
|
84
|
+
loadedUser: loadedUser,
|
|
85
|
+
logEvent: logEvent
|
|
86
|
+
}))), /*#__PURE__*/_react["default"].createElement(_Backdrop["default"], {
|
|
87
|
+
sx: {
|
|
88
|
+
color: '#fff',
|
|
89
|
+
zIndex: 99999
|
|
90
|
+
},
|
|
91
|
+
open: isLoading
|
|
92
|
+
}, /*#__PURE__*/_react["default"].createElement(_CircularProgress["default"], {
|
|
93
|
+
color: "inherit"
|
|
94
|
+
})), /*#__PURE__*/_react["default"].createElement(_reactToastify.ToastContainer, null))), process.env.authscape.microsoftClarityTrackingCode != null && /*#__PURE__*/_react["default"].createElement("script", {
|
|
95
|
+
dangerouslySetInnerHTML: {
|
|
96
|
+
__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 + "\");"
|
|
97
|
+
}
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
"use strict";
|
|
101
|
+
|
|
3
102
|
Object.defineProperty(exports, "__esModule", {
|
|
4
103
|
value: true
|
|
5
104
|
});
|
|
@@ -1274,7 +1373,7 @@ var CheckoutForm = function CheckoutForm(_ref) {
|
|
|
1274
1373
|
elements: elements,
|
|
1275
1374
|
redirect: "if_required"
|
|
1276
1375
|
// confirmParams: {
|
|
1277
|
-
// return_url: process.env.
|
|
1376
|
+
// return_url: process.env.authscape.websiteBaseUri + '/confirmSetup?redirectUrl=' + encodeURIComponent(window.location.search),
|
|
1278
1377
|
// },
|
|
1279
1378
|
});
|
|
1280
1379
|
case 7:
|
|
@@ -1331,7 +1430,7 @@ var CheckoutForm = function CheckoutForm(_ref) {
|
|
|
1331
1430
|
elements: elements,
|
|
1332
1431
|
redirect: "if_required",
|
|
1333
1432
|
confirmParams: {
|
|
1334
|
-
return_url: process.env.
|
|
1433
|
+
return_url: process.env.authscape.websiteBaseUri + '/confirmPayment?redirectUrl=' + encodeURIComponent(window.location.search)
|
|
1335
1434
|
}
|
|
1336
1435
|
});
|
|
1337
1436
|
case 37:
|
|
@@ -1679,6 +1778,87 @@ var StripePayment = function StripePayment() {
|
|
|
1679
1778
|
exports.StripePayment = StripePayment;
|
|
1680
1779
|
"use strict";
|
|
1681
1780
|
|
|
1781
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1782
|
+
value: true
|
|
1783
|
+
});
|
|
1784
|
+
exports.init = init;
|
|
1785
|
+
exports.logEvent = logEvent;
|
|
1786
|
+
exports.logPageView = logPageView;
|
|
1787
|
+
exports.logPageViews = logPageViews;
|
|
1788
|
+
exports.logPurchase = logPurchase;
|
|
1789
|
+
var _router = _interopRequireDefault(require("next/router"));
|
|
1790
|
+
var _ga4React = _interopRequireDefault(require("ga-4-react"));
|
|
1791
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
1792
|
+
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); }
|
|
1793
|
+
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; }
|
|
1794
|
+
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); } }
|
|
1795
|
+
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); }); }; }
|
|
1796
|
+
var ga4react;
|
|
1797
|
+
function init(_x) {
|
|
1798
|
+
return _init.apply(this, arguments);
|
|
1799
|
+
}
|
|
1800
|
+
function _init() {
|
|
1801
|
+
_init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(G) {
|
|
1802
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1803
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1804
|
+
case 0:
|
|
1805
|
+
if (!(!_ga4React["default"].isInitialized() && G && process.browser)) {
|
|
1806
|
+
_context.next = 11;
|
|
1807
|
+
break;
|
|
1808
|
+
}
|
|
1809
|
+
ga4react = new _ga4React["default"](G, {
|
|
1810
|
+
debug_mode: !process.env.production
|
|
1811
|
+
});
|
|
1812
|
+
_context.prev = 2;
|
|
1813
|
+
_context.next = 5;
|
|
1814
|
+
return ga4react.initialize();
|
|
1815
|
+
case 5:
|
|
1816
|
+
logPageViews();
|
|
1817
|
+
_context.next = 11;
|
|
1818
|
+
break;
|
|
1819
|
+
case 8:
|
|
1820
|
+
_context.prev = 8;
|
|
1821
|
+
_context.t0 = _context["catch"](2);
|
|
1822
|
+
console.error(_context.t0);
|
|
1823
|
+
case 11:
|
|
1824
|
+
case "end":
|
|
1825
|
+
return _context.stop();
|
|
1826
|
+
}
|
|
1827
|
+
}, _callee, null, [[2, 8]]);
|
|
1828
|
+
}));
|
|
1829
|
+
return _init.apply(this, arguments);
|
|
1830
|
+
}
|
|
1831
|
+
function logPageView() {
|
|
1832
|
+
if (ga4react != null) {
|
|
1833
|
+
ga4react.pageview(window.location.pathname);
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
function logPageViews() {
|
|
1837
|
+
if (ga4react != null) {
|
|
1838
|
+
logPageView();
|
|
1839
|
+
_router["default"].events.on('routeChangeComplete', function () {
|
|
1840
|
+
logPageView();
|
|
1841
|
+
});
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
function logEvent(category, action, label) {
|
|
1845
|
+
if (ga4react != null) {
|
|
1846
|
+
ga4react.event(action, label, category);
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
function logPurchase(transactionId, amount, tax, items) {
|
|
1850
|
+
if (ga4react != null) {
|
|
1851
|
+
ga4react.gtag("event", "purchase", {
|
|
1852
|
+
transaction_id: transactionId,
|
|
1853
|
+
value: amount,
|
|
1854
|
+
tax: tax,
|
|
1855
|
+
currency: "USD",
|
|
1856
|
+
items: items
|
|
1857
|
+
});
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
"use strict";
|
|
1861
|
+
|
|
1682
1862
|
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
1863
|
Object.defineProperty(exports, "__esModule", {
|
|
1684
1864
|
value: true
|
|
@@ -1746,7 +1926,7 @@ var RefreshToken = /*#__PURE__*/function () {
|
|
|
1746
1926
|
accessToken = (0, _nookies.parseCookies)().access_token || '';
|
|
1747
1927
|
refreshToken = (0, _nookies.parseCookies)().refresh_token || '';
|
|
1748
1928
|
_context2.next = 4;
|
|
1749
|
-
return instance.post(process.env.
|
|
1929
|
+
return instance.post(process.env.authscape.authorityUri + "/connect/token", _queryString["default"].stringify({
|
|
1750
1930
|
grant_type: 'refresh_token',
|
|
1751
1931
|
client_id: process.env.client_id,
|
|
1752
1932
|
client_secret: process.env.client_secret,
|
|
@@ -1768,7 +1948,7 @@ var RefreshToken = /*#__PURE__*/function () {
|
|
|
1768
1948
|
return (0, _nookies.setCookie)(null, "access_token", response.data.access_token, {
|
|
1769
1949
|
maxAge: 2147483647,
|
|
1770
1950
|
path: '/',
|
|
1771
|
-
domain: process.env.cookieDomain,
|
|
1951
|
+
domain: process.env.authscape.cookieDomain,
|
|
1772
1952
|
secure: true
|
|
1773
1953
|
});
|
|
1774
1954
|
case 9:
|
|
@@ -1776,7 +1956,7 @@ var RefreshToken = /*#__PURE__*/function () {
|
|
|
1776
1956
|
return (0, _nookies.setCookie)(null, "expires_in", response.data.expires_in, {
|
|
1777
1957
|
maxAge: 2147483647,
|
|
1778
1958
|
path: '/',
|
|
1779
|
-
domain: process.env.cookieDomain,
|
|
1959
|
+
domain: process.env.authscape.cookieDomain,
|
|
1780
1960
|
secure: true
|
|
1781
1961
|
});
|
|
1782
1962
|
case 11:
|
|
@@ -1784,7 +1964,7 @@ var RefreshToken = /*#__PURE__*/function () {
|
|
|
1784
1964
|
return (0, _nookies.setCookie)(null, "refresh_token", response.data.refresh_token, {
|
|
1785
1965
|
maxAge: 2147483647,
|
|
1786
1966
|
path: '/',
|
|
1787
|
-
domain: process.env.cookieDomain,
|
|
1967
|
+
domain: process.env.authscape.cookieDomain,
|
|
1788
1968
|
secure: true
|
|
1789
1969
|
});
|
|
1790
1970
|
case 13:
|
|
@@ -1799,11 +1979,11 @@ var RefreshToken = /*#__PURE__*/function () {
|
|
|
1799
1979
|
}();
|
|
1800
1980
|
var apiService = function apiService() {
|
|
1801
1981
|
var ctx = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
1802
|
-
var env = process.env.
|
|
1982
|
+
var env = process.env.authscape.stage;
|
|
1803
1983
|
if (env == "development") {
|
|
1804
1984
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|
1805
1985
|
}
|
|
1806
|
-
var baseUri = process.env.
|
|
1986
|
+
var baseUri = process.env.authscape.apiUri + "/api";
|
|
1807
1987
|
var instance = _axios["default"].create({
|
|
1808
1988
|
baseURL: baseUri,
|
|
1809
1989
|
//timeout: 10000,
|
|
@@ -1847,17 +2027,17 @@ var apiService = function apiService() {
|
|
|
1847
2027
|
(0, _nookies.destroyCookie)(null, "access_token", {
|
|
1848
2028
|
maxAge: 2147483647,
|
|
1849
2029
|
path: '/',
|
|
1850
|
-
domain: process.env.cookieDomain
|
|
2030
|
+
domain: process.env.authscape.cookieDomain
|
|
1851
2031
|
});
|
|
1852
2032
|
(0, _nookies.destroyCookie)(null, "refresh_token", {
|
|
1853
2033
|
maxAge: 2147483647,
|
|
1854
2034
|
path: '/',
|
|
1855
|
-
domain: process.env.cookieDomain
|
|
2035
|
+
domain: process.env.authscape.cookieDomain
|
|
1856
2036
|
});
|
|
1857
2037
|
(0, _nookies.destroyCookie)(null, "expires_in", {
|
|
1858
2038
|
maxAge: 2147483647,
|
|
1859
2039
|
path: '/',
|
|
1860
|
-
domain: process.env.cookieDomain
|
|
2040
|
+
domain: process.env.authscape.cookieDomain
|
|
1861
2041
|
});
|
|
1862
2042
|
}
|
|
1863
2043
|
return _context3.abrupt("return", Promise.reject(error));
|
|
@@ -2120,6 +2300,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
2120
2300
|
|
|
2121
2301
|
function AuthorizationComponent(_ref) {
|
|
2122
2302
|
var children = _ref.children,
|
|
2303
|
+
isEnabled = _ref.isEnabled,
|
|
2123
2304
|
setCurrentUser = _ref.setCurrentUser,
|
|
2124
2305
|
userLoaded = _ref.userLoaded,
|
|
2125
2306
|
isLoading = _ref.isLoading;
|
|
@@ -2134,17 +2315,26 @@ function AuthorizationComponent(_ref) {
|
|
|
2134
2315
|
while (1) switch (_context.prev = _context.next) {
|
|
2135
2316
|
case 0:
|
|
2136
2317
|
setLoaded(true);
|
|
2137
|
-
|
|
2318
|
+
if (!isEnabled) {
|
|
2319
|
+
_context.next = 8;
|
|
2320
|
+
break;
|
|
2321
|
+
}
|
|
2322
|
+
_context.next = 4;
|
|
2138
2323
|
return apiService().GetCurrentUser();
|
|
2139
|
-
case
|
|
2324
|
+
case 4:
|
|
2140
2325
|
usr = _context.sent;
|
|
2141
2326
|
if (usr != null) {
|
|
2142
2327
|
setCurrentUser(usr);
|
|
2143
2328
|
} else {
|
|
2144
2329
|
setCurrentUser(null);
|
|
2145
2330
|
}
|
|
2331
|
+
_context.next = 9;
|
|
2332
|
+
break;
|
|
2333
|
+
case 8:
|
|
2334
|
+
setCurrentUser(null);
|
|
2335
|
+
case 9:
|
|
2146
2336
|
userLoaded();
|
|
2147
|
-
case
|
|
2337
|
+
case 10:
|
|
2148
2338
|
case "end":
|
|
2149
2339
|
return _context.stop();
|
|
2150
2340
|
}
|
|
@@ -2249,7 +2439,7 @@ var authService = function authService() {
|
|
|
2249
2439
|
challenge = _context2.sent;
|
|
2250
2440
|
window.localStorage.setItem("verifier", verifier);
|
|
2251
2441
|
redirectUri = window.location.origin + "/signin-oidc";
|
|
2252
|
-
loginUri = process.env.
|
|
2442
|
+
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
2443
|
if (deviceId) {
|
|
2254
2444
|
loginUri += "&deviceId=" + deviceId; // will be for chrome extention and mobile apps later
|
|
2255
2445
|
}
|
|
@@ -2268,7 +2458,7 @@ var authService = function authService() {
|
|
|
2268
2458
|
}(),
|
|
2269
2459
|
signUp: function signUp() {
|
|
2270
2460
|
var redirectUrl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
2271
|
-
var AuthUri = process.env.
|
|
2461
|
+
var AuthUri = process.env.authscape.authorityUri;
|
|
2272
2462
|
var url = "";
|
|
2273
2463
|
if (redirectUrl == null) {
|
|
2274
2464
|
url = AuthUri + "/Identity/Account/Register?returnUrl=" + window.location.href;
|
|
@@ -2284,7 +2474,7 @@ var authService = function authService() {
|
|
|
2284
2474
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
2285
2475
|
while (1) switch (_context3.prev = _context3.next) {
|
|
2286
2476
|
case 0:
|
|
2287
|
-
window.location.href = process.env.
|
|
2477
|
+
window.location.href = process.env.authscape.authorityUri + "/Identity/Account/Manage";
|
|
2288
2478
|
case 1:
|
|
2289
2479
|
case "end":
|
|
2290
2480
|
return _context3.stop();
|
|
@@ -2306,8 +2496,8 @@ var authService = function authService() {
|
|
|
2306
2496
|
while (1) switch (_context4.prev = _context4.next) {
|
|
2307
2497
|
case 0:
|
|
2308
2498
|
redirectUri = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : null;
|
|
2309
|
-
AuthUri = process.env.
|
|
2310
|
-
cookieDomain = process.env.cookieDomain;
|
|
2499
|
+
AuthUri = process.env.authscape.authorityUri;
|
|
2500
|
+
cookieDomain = process.env.authscape.cookieDomain;
|
|
2311
2501
|
(0, _nookies.destroyCookie)({}, "access_token", {
|
|
2312
2502
|
maxAge: 2147483647,
|
|
2313
2503
|
path: '/',
|
|
@@ -2384,13 +2574,13 @@ var signInValidator = /*#__PURE__*/function () {
|
|
|
2384
2574
|
code_verifier: codeVerifier
|
|
2385
2575
|
});
|
|
2386
2576
|
_context.next = 6;
|
|
2387
|
-
return _axios["default"].post(process.env.
|
|
2577
|
+
return _axios["default"].post(process.env.authscape.authorityUri + '/connect/token', queryString, {
|
|
2388
2578
|
headers: headers
|
|
2389
2579
|
});
|
|
2390
2580
|
case 6:
|
|
2391
2581
|
response = _context.sent;
|
|
2392
2582
|
window.localStorage.removeItem("verifier");
|
|
2393
|
-
domain = process.env.cookieDomain;
|
|
2583
|
+
domain = process.env.authscape.cookieDomain;
|
|
2394
2584
|
_context.next = 11;
|
|
2395
2585
|
return (0, _nookies.setCookie)(null, "access_token", response.data.access_token, {
|
|
2396
2586
|
maxAge: 2147483647,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "authscape",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.180",
|
|
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,96 @@
|
|
|
1
|
+
import React, { useEffect, useState, useRef } from 'react';
|
|
2
|
+
import CircularProgress from '@mui/material/CircularProgress';
|
|
3
|
+
import Backdrop from '@mui/material/Backdrop';
|
|
4
|
+
import { ToastContainer, toast } from 'react-toastify';
|
|
5
|
+
import { useRouter } from 'next/router';
|
|
6
|
+
|
|
7
|
+
export function AuthScapeApp({Component, pageProps, muiTheme = null, onAuthenticationLoaded = null}) {
|
|
8
|
+
|
|
9
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
10
|
+
const [loadedUser, setLoadedUser] = useState(false);
|
|
11
|
+
const [currentUser, setCurrentUser] = useState(null);
|
|
12
|
+
const [loadingLogin, setLoadingLogin] = useState(false);
|
|
13
|
+
const router = useRouter();
|
|
14
|
+
// const [openLoginModal, setOpenLoginModal] = useState(false);
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (loadedUser)
|
|
18
|
+
{
|
|
19
|
+
if (process.env.authscape.googleAnalytics4 != null)
|
|
20
|
+
{
|
|
21
|
+
init(process.env.authscape.googleAnalytics4);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (router.query.r != null)
|
|
25
|
+
{
|
|
26
|
+
localStorage.setItem("ref", router.query.r);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}, [loadedUser]);
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if(!router.isReady) return;
|
|
33
|
+
|
|
34
|
+
if (router.query.code != null)
|
|
35
|
+
{
|
|
36
|
+
setLoadingLogin(true);
|
|
37
|
+
signInValidator(router.query.code);
|
|
38
|
+
}
|
|
39
|
+
else if (router.query.signupPass != null)
|
|
40
|
+
{
|
|
41
|
+
setLoadingLogin(true);
|
|
42
|
+
authService().login();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}, [router.isReady]);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<>
|
|
49
|
+
<ThemeProvider theme={muiTheme}>
|
|
50
|
+
|
|
51
|
+
{loadingLogin &&
|
|
52
|
+
<Box>
|
|
53
|
+
Please wait. Loading...
|
|
54
|
+
</Box>
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
{!loadingLogin &&
|
|
58
|
+
<>
|
|
59
|
+
<AuthorizationComponent setCurrentUser={setCurrentUser} isEnabled={process.env.authscape.enableAuth} userLoaded={() => {
|
|
60
|
+
setLoadedUser(true);
|
|
61
|
+
|
|
62
|
+
if (onAuthenticationLoaded != null)
|
|
63
|
+
{
|
|
64
|
+
onAuthenticationLoaded(currentUser);
|
|
65
|
+
}
|
|
66
|
+
}}>
|
|
67
|
+
<Component {...pageProps} currentUser={currentUser} toast={toast} setIsLoading={setIsLoading} loadedUser={loadedUser} logEvent={logEvent} />
|
|
68
|
+
</AuthorizationComponent>
|
|
69
|
+
|
|
70
|
+
<Backdrop sx={{ color: '#fff', zIndex: 99999 }} open={isLoading}>
|
|
71
|
+
<CircularProgress color="inherit" />
|
|
72
|
+
</Backdrop>
|
|
73
|
+
|
|
74
|
+
<ToastContainer />
|
|
75
|
+
</>
|
|
76
|
+
}
|
|
77
|
+
</ThemeProvider>
|
|
78
|
+
|
|
79
|
+
{process.env.authscape.microsoftClarityTrackingCode != null &&
|
|
80
|
+
<script
|
|
81
|
+
dangerouslySetInnerHTML={{
|
|
82
|
+
__html: `
|
|
83
|
+
(function(c,l,a,r,i,t,y){
|
|
84
|
+
c[a] = c[a] || function () { (c[a].q = c[a].q || []).push(arguments) };
|
|
85
|
+
t=l.createElement(r);
|
|
86
|
+
t.async=1;
|
|
87
|
+
t.src="https://www.clarity.ms/tag/"+i;
|
|
88
|
+
y=l.getElementsByTagName(r)[0];
|
|
89
|
+
y.parentNode.insertBefore(t,y);
|
|
90
|
+
})(window, document, "clarity", "script", "` + process.env.authscape.microsoftClarityTrackingCode + `");`,
|
|
91
|
+
}}
|
|
92
|
+
/>
|
|
93
|
+
}
|
|
94
|
+
</>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
@@ -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,7 +60,7 @@ 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)
|
|
@@ -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
|
{
|