authscape 1.0.656 → 1.0.660
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 +95 -76
- package/package.json +1 -1
- package/src/components/AuthScapeApp.js +7 -7
- package/src/services/apiService.js +6 -6
- package/src/services/signInValidator.js +7 -7
- package/src/services/util.js +23 -1
package/index.js
CHANGED
|
@@ -12,7 +12,6 @@ var _head = _interopRequireDefault(require("next/head"));
|
|
|
12
12
|
var _navigation = require("next/navigation");
|
|
13
13
|
var _axios = _interopRequireDefault(require("axios"));
|
|
14
14
|
var _queryString = _interopRequireDefault(require("query-string"));
|
|
15
|
-
var _jsCookie = _interopRequireDefault(require("js-cookie"));
|
|
16
15
|
var _router = _interopRequireDefault(require("next/router"));
|
|
17
16
|
var _ga4React = _interopRequireDefault(require("ga-4-react"));
|
|
18
17
|
var _zustand = require("zustand");
|
|
@@ -29,7 +28,7 @@ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructur
|
|
|
29
28
|
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); }
|
|
30
29
|
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; }
|
|
31
30
|
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; } }
|
|
32
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
31
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } // import Cookies from 'js-cookie';
|
|
33
32
|
// comment this out
|
|
34
33
|
// import { authService, apiService, setupOEMProps, OEMStyleSheet } from 'authscape';
|
|
35
34
|
|
|
@@ -85,7 +84,7 @@ function AuthScapeApp(_ref) {
|
|
|
85
84
|
case 5:
|
|
86
85
|
codeVerifier = window.localStorage.getItem("verifier");
|
|
87
86
|
if (!(queryCode != null && codeVerifier != null)) {
|
|
88
|
-
_context.next =
|
|
87
|
+
_context.next = 28;
|
|
89
88
|
break;
|
|
90
89
|
}
|
|
91
90
|
headers = {
|
|
@@ -108,25 +107,33 @@ function AuthScapeApp(_ref) {
|
|
|
108
107
|
response = _context.sent;
|
|
109
108
|
domainHost = window.location.hostname.split('.').slice(-2).join('.');
|
|
110
109
|
window.localStorage.removeItem("verifier");
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
_context.next = 17;
|
|
111
|
+
return setCookie('access_token', response.data.access_token, {
|
|
112
|
+
maxAge: 60 * 60 * 24 * 365,
|
|
113
|
+
// 1 year,
|
|
113
114
|
path: '/',
|
|
114
115
|
domain: domainHost,
|
|
115
116
|
secure: true
|
|
116
117
|
});
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
case 17:
|
|
119
|
+
_context.next = 19;
|
|
120
|
+
return setCookie('expires_in', response.data.expires_in, {
|
|
121
|
+
maxAge: 60 * 60 * 24 * 365,
|
|
122
|
+
// 1 year,
|
|
119
123
|
path: '/',
|
|
120
124
|
domain: domainHost,
|
|
121
125
|
secure: true
|
|
122
126
|
});
|
|
123
|
-
|
|
124
|
-
|
|
127
|
+
case 19:
|
|
128
|
+
_context.next = 21;
|
|
129
|
+
return setCookie('refresh_token', response.data.refresh_token, {
|
|
130
|
+
maxAge: 60 * 60 * 24 * 365,
|
|
131
|
+
// 1 year,
|
|
125
132
|
path: '/',
|
|
126
133
|
domain: domainHost,
|
|
127
134
|
secure: true
|
|
128
135
|
});
|
|
129
|
-
|
|
136
|
+
case 21:
|
|
130
137
|
// await setCookie(null, "access_token", response.data.access_token,
|
|
131
138
|
// {
|
|
132
139
|
// maxAge: 2147483647,
|
|
@@ -134,7 +141,6 @@ function AuthScapeApp(_ref) {
|
|
|
134
141
|
// domain: domainHost,
|
|
135
142
|
// secure: true
|
|
136
143
|
// });
|
|
137
|
-
|
|
138
144
|
// await setCookie(null, "expires_in", response.data.expires_in,
|
|
139
145
|
// {
|
|
140
146
|
// maxAge: 2147483647,
|
|
@@ -142,7 +148,6 @@ function AuthScapeApp(_ref) {
|
|
|
142
148
|
// domain: domainHost,
|
|
143
149
|
// secure: true
|
|
144
150
|
// });
|
|
145
|
-
|
|
146
151
|
// await setCookie(null, "refresh_token", response.data.refresh_token,
|
|
147
152
|
// {
|
|
148
153
|
// maxAge: 2147483647,
|
|
@@ -157,16 +162,16 @@ function AuthScapeApp(_ref) {
|
|
|
157
162
|
} else {
|
|
158
163
|
window.location.href = "/";
|
|
159
164
|
}
|
|
160
|
-
_context.next =
|
|
165
|
+
_context.next = 28;
|
|
161
166
|
break;
|
|
162
|
-
case
|
|
163
|
-
_context.prev =
|
|
167
|
+
case 26:
|
|
168
|
+
_context.prev = 26;
|
|
164
169
|
_context.t0 = _context["catch"](9);
|
|
165
|
-
case
|
|
170
|
+
case 28:
|
|
166
171
|
case "end":
|
|
167
172
|
return _context.stop();
|
|
168
173
|
}
|
|
169
|
-
}, _callee, null, [[9,
|
|
174
|
+
}, _callee, null, [[9, 26]]);
|
|
170
175
|
}));
|
|
171
176
|
return function signInValidator(_x2) {
|
|
172
177
|
return _ref2.apply(this, arguments);
|
|
@@ -8447,53 +8452,39 @@ var RefreshToken = /*#__PURE__*/function () {
|
|
|
8447
8452
|
});
|
|
8448
8453
|
case 4:
|
|
8449
8454
|
response = _context2.sent;
|
|
8450
|
-
if (response != null && response.status == 200) {
|
|
8451
|
-
|
|
8452
|
-
|
|
8453
|
-
_jsCookie["default"].set('access_token', response.data.access_token, {
|
|
8454
|
-
maxAge: 2147483647,
|
|
8455
|
-
path: '/',
|
|
8456
|
-
domain: domainHost,
|
|
8457
|
-
secure: true
|
|
8458
|
-
});
|
|
8459
|
-
_jsCookie["default"].set('expires_in', response.data.expires_in, {
|
|
8460
|
-
maxAge: 2147483647,
|
|
8461
|
-
path: '/',
|
|
8462
|
-
domain: domainHost,
|
|
8463
|
-
secure: true
|
|
8464
|
-
});
|
|
8465
|
-
_jsCookie["default"].set('refresh_token', response.data.refresh_token, {
|
|
8466
|
-
maxAge: 2147483647,
|
|
8467
|
-
path: '/',
|
|
8468
|
-
domain: domainHost,
|
|
8469
|
-
secure: true
|
|
8470
|
-
});
|
|
8471
|
-
|
|
8472
|
-
// await setCookie(null, "access_token", response.data.access_token,
|
|
8473
|
-
// {
|
|
8474
|
-
// maxAge: 2147483647,
|
|
8475
|
-
// path: '/',
|
|
8476
|
-
// domain: domainHost,
|
|
8477
|
-
// secure: true
|
|
8478
|
-
// });
|
|
8479
|
-
|
|
8480
|
-
// await setCookie(null, "expires_in", response.data.expires_in,
|
|
8481
|
-
// {
|
|
8482
|
-
// maxAge: 2147483647,
|
|
8483
|
-
// path: '/',
|
|
8484
|
-
// domain: domainHost,
|
|
8485
|
-
// secure: true
|
|
8486
|
-
// });
|
|
8487
|
-
|
|
8488
|
-
// await setCookie(null, "refresh_token", response.data.refresh_token,
|
|
8489
|
-
// {
|
|
8490
|
-
// maxAge: 2147483647,
|
|
8491
|
-
// path: '/',
|
|
8492
|
-
// domain: domainHost,
|
|
8493
|
-
// secure: true
|
|
8494
|
-
// });
|
|
8455
|
+
if (!(response != null && response.status == 200)) {
|
|
8456
|
+
_context2.next = 14;
|
|
8457
|
+
break;
|
|
8495
8458
|
}
|
|
8496
|
-
|
|
8459
|
+
domainHost = window.location.hostname.split('.').slice(-2).join('.');
|
|
8460
|
+
originalRequest.headers['Authorization'] = 'Bearer ' + response.data.access_token;
|
|
8461
|
+
_context2.next = 10;
|
|
8462
|
+
return setCookie('access_token', response.data.access_token, {
|
|
8463
|
+
maxAge: 60 * 60 * 24 * 365,
|
|
8464
|
+
// 1 year,
|
|
8465
|
+
path: '/',
|
|
8466
|
+
domain: domainHost,
|
|
8467
|
+
secure: true
|
|
8468
|
+
});
|
|
8469
|
+
case 10:
|
|
8470
|
+
_context2.next = 12;
|
|
8471
|
+
return setCookie('expires_in', response.data.expires_in, {
|
|
8472
|
+
maxAge: 60 * 60 * 24 * 365,
|
|
8473
|
+
// 1 year,
|
|
8474
|
+
path: '/',
|
|
8475
|
+
domain: domainHost,
|
|
8476
|
+
secure: true
|
|
8477
|
+
});
|
|
8478
|
+
case 12:
|
|
8479
|
+
_context2.next = 14;
|
|
8480
|
+
return setCookie('refresh_token', response.data.refresh_token, {
|
|
8481
|
+
maxAge: 60 * 60 * 24 * 365,
|
|
8482
|
+
// 1 year,
|
|
8483
|
+
path: '/',
|
|
8484
|
+
domain: domainHost,
|
|
8485
|
+
secure: true
|
|
8486
|
+
});
|
|
8487
|
+
case 14:
|
|
8497
8488
|
case "end":
|
|
8498
8489
|
return _context2.stop();
|
|
8499
8490
|
}
|
|
@@ -9262,13 +9253,14 @@ exports.signInValidator = void 0;
|
|
|
9262
9253
|
var _react = _interopRequireWildcard(require("react"));
|
|
9263
9254
|
var _axios = _interopRequireDefault(require("axios"));
|
|
9264
9255
|
var _queryString = _interopRequireDefault(require("query-string"));
|
|
9265
|
-
var _jsCookie = _interopRequireDefault(require("js-cookie"));
|
|
9266
9256
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
9267
9257
|
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); }
|
|
9268
9258
|
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; }
|
|
9269
9259
|
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; }
|
|
9270
9260
|
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); } }
|
|
9271
9261
|
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); }); }; }
|
|
9262
|
+
// import Cookies from 'js-cookie';
|
|
9263
|
+
|
|
9272
9264
|
var signInValidator = /*#__PURE__*/function () {
|
|
9273
9265
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(queryCode) {
|
|
9274
9266
|
var codeVerifier, headers, queryString, response, domainHost, redirectUri;
|
|
@@ -9277,7 +9269,7 @@ var signInValidator = /*#__PURE__*/function () {
|
|
|
9277
9269
|
case 0:
|
|
9278
9270
|
codeVerifier = window.localStorage.getItem("verifier");
|
|
9279
9271
|
if (!(queryCode != null && codeVerifier != null)) {
|
|
9280
|
-
_context.next =
|
|
9272
|
+
_context.next = 18;
|
|
9281
9273
|
break;
|
|
9282
9274
|
}
|
|
9283
9275
|
headers = {
|
|
@@ -9299,25 +9291,33 @@ var signInValidator = /*#__PURE__*/function () {
|
|
|
9299
9291
|
response = _context.sent;
|
|
9300
9292
|
domainHost = window.location.hostname.split('.').slice(-2).join('.');
|
|
9301
9293
|
window.localStorage.removeItem("verifier");
|
|
9302
|
-
|
|
9303
|
-
|
|
9294
|
+
_context.next = 11;
|
|
9295
|
+
return setCookie('access_token', response.data.access_token, {
|
|
9296
|
+
maxAge: 60 * 60 * 24 * 365,
|
|
9297
|
+
// 1 year,
|
|
9304
9298
|
path: '/',
|
|
9305
9299
|
domain: domainHost,
|
|
9306
9300
|
secure: true
|
|
9307
9301
|
});
|
|
9308
|
-
|
|
9309
|
-
|
|
9302
|
+
case 11:
|
|
9303
|
+
_context.next = 13;
|
|
9304
|
+
return setCookie('expires_in', response.data.expires_in, {
|
|
9305
|
+
maxAge: 60 * 60 * 24 * 365,
|
|
9306
|
+
// 1 year,
|
|
9310
9307
|
path: '/',
|
|
9311
9308
|
domain: domainHost,
|
|
9312
9309
|
secure: true
|
|
9313
9310
|
});
|
|
9314
|
-
|
|
9315
|
-
|
|
9311
|
+
case 13:
|
|
9312
|
+
_context.next = 15;
|
|
9313
|
+
return setCookie('refresh_token', response.data.refresh_token, {
|
|
9314
|
+
maxAge: 60 * 60 * 24 * 365,
|
|
9315
|
+
// 1 year,
|
|
9316
9316
|
path: '/',
|
|
9317
9317
|
domain: domainHost,
|
|
9318
9318
|
secure: true
|
|
9319
9319
|
});
|
|
9320
|
-
|
|
9320
|
+
case 15:
|
|
9321
9321
|
// await setCookie(null, "access_token", response.data.access_token,
|
|
9322
9322
|
// {
|
|
9323
9323
|
// maxAge: 2147483647,
|
|
@@ -9325,7 +9325,6 @@ var signInValidator = /*#__PURE__*/function () {
|
|
|
9325
9325
|
// domain: domainHost,
|
|
9326
9326
|
// secure: true
|
|
9327
9327
|
// });
|
|
9328
|
-
|
|
9329
9328
|
// await setCookie(null, "expires_in", response.data.expires_in,
|
|
9330
9329
|
// {
|
|
9331
9330
|
// maxAge: 2147483647,
|
|
@@ -9333,7 +9332,6 @@ var signInValidator = /*#__PURE__*/function () {
|
|
|
9333
9332
|
// domain: domainHost,
|
|
9334
9333
|
// secure: true
|
|
9335
9334
|
// });
|
|
9336
|
-
|
|
9337
9335
|
// await setCookie(null, "refresh_token", response.data.refresh_token,
|
|
9338
9336
|
// {
|
|
9339
9337
|
// maxAge: 2147483647,
|
|
@@ -9348,7 +9346,7 @@ var signInValidator = /*#__PURE__*/function () {
|
|
|
9348
9346
|
} else {
|
|
9349
9347
|
window.location.href = "/";
|
|
9350
9348
|
}
|
|
9351
|
-
case
|
|
9349
|
+
case 18:
|
|
9352
9350
|
case "end":
|
|
9353
9351
|
return _context.stop();
|
|
9354
9352
|
}
|
|
@@ -9412,7 +9410,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
9412
9410
|
Object.defineProperty(exports, "__esModule", {
|
|
9413
9411
|
value: true
|
|
9414
9412
|
});
|
|
9415
|
-
exports.GetBaseUrl = void 0;
|
|
9413
|
+
exports.setCookie = exports.GetBaseUrl = void 0;
|
|
9416
9414
|
var _react = _interopRequireWildcard(require("react"));
|
|
9417
9415
|
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); }
|
|
9418
9416
|
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; }
|
|
@@ -9420,3 +9418,24 @@ var GetBaseUrl = function GetBaseUrl() {
|
|
|
9420
9418
|
return window.location.protocol + "//" + window.location.host;
|
|
9421
9419
|
};
|
|
9422
9420
|
exports.GetBaseUrl = GetBaseUrl;
|
|
9421
|
+
var setCookie = function setCookie(name, value) {
|
|
9422
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
9423
|
+
return new Promise(function (resolve) {
|
|
9424
|
+
var cookieString = "".concat(name, "=").concat(value, ";");
|
|
9425
|
+
if (options.maxAge) {
|
|
9426
|
+
cookieString += "max-age=".concat(options.maxAge, ";");
|
|
9427
|
+
}
|
|
9428
|
+
if (options.path) {
|
|
9429
|
+
cookieString += "path=".concat(options.path, ";");
|
|
9430
|
+
}
|
|
9431
|
+
if (options.domain) {
|
|
9432
|
+
cookieString += "domain=".concat(options.domain, ";");
|
|
9433
|
+
}
|
|
9434
|
+
if (options.secure) {
|
|
9435
|
+
cookieString += "secure;";
|
|
9436
|
+
}
|
|
9437
|
+
document.cookie = cookieString;
|
|
9438
|
+
resolve();
|
|
9439
|
+
});
|
|
9440
|
+
};
|
|
9441
|
+
exports.setCookie = setCookie;
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ import Head from "next/head";
|
|
|
5
5
|
import { useSearchParams, usePathname } from 'next/navigation';
|
|
6
6
|
import axios from 'axios';
|
|
7
7
|
import querystring from "query-string";
|
|
8
|
-
import Cookies from 'js-cookie';
|
|
8
|
+
// import Cookies from 'js-cookie';
|
|
9
9
|
import Router from 'next/router';
|
|
10
10
|
import GA4React from 'ga-4-react';
|
|
11
11
|
import { create } from 'zustand'
|
|
@@ -69,22 +69,22 @@ export function AuthScapeApp ({Component, layout, loadingLayout, pageProps, muiT
|
|
|
69
69
|
let domainHost = window.location.hostname.split('.').slice(-2).join('.');
|
|
70
70
|
window.localStorage.removeItem("verifier");
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
maxAge:
|
|
72
|
+
await setCookie('access_token', response.data.access_token, {
|
|
73
|
+
maxAge: 60 * 60 * 24 * 365, // 1 year,
|
|
74
74
|
path: '/',
|
|
75
75
|
domain: domainHost,
|
|
76
76
|
secure: true
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
maxAge:
|
|
79
|
+
await setCookie('expires_in', response.data.expires_in, {
|
|
80
|
+
maxAge: 60 * 60 * 24 * 365, // 1 year,
|
|
81
81
|
path: '/',
|
|
82
82
|
domain: domainHost,
|
|
83
83
|
secure: true
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
maxAge:
|
|
86
|
+
await setCookie('refresh_token', response.data.refresh_token, {
|
|
87
|
+
maxAge: 60 * 60 * 24 * 365, // 1 year,
|
|
88
88
|
path: '/',
|
|
89
89
|
domain: domainHost,
|
|
90
90
|
secure: true
|
|
@@ -62,22 +62,22 @@ const RefreshToken = async (originalRequest, instance) => {
|
|
|
62
62
|
|
|
63
63
|
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
maxAge:
|
|
65
|
+
await setCookie('access_token', response.data.access_token, {
|
|
66
|
+
maxAge: 60 * 60 * 24 * 365, // 1 year,
|
|
67
67
|
path: '/',
|
|
68
68
|
domain: domainHost,
|
|
69
69
|
secure: true
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
maxAge:
|
|
72
|
+
await setCookie('expires_in', response.data.expires_in, {
|
|
73
|
+
maxAge: 60 * 60 * 24 * 365, // 1 year,
|
|
74
74
|
path: '/',
|
|
75
75
|
domain: domainHost,
|
|
76
76
|
secure: true
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
maxAge:
|
|
79
|
+
await setCookie('refresh_token', response.data.refresh_token, {
|
|
80
|
+
maxAge: 60 * 60 * 24 * 365, // 1 year,
|
|
81
81
|
path: '/',
|
|
82
82
|
domain: domainHost,
|
|
83
83
|
secure: true
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import axios from 'axios';
|
|
3
3
|
import querystring from "query-string";
|
|
4
|
-
import Cookies from 'js-cookie';
|
|
4
|
+
// import Cookies from 'js-cookie';
|
|
5
5
|
|
|
6
6
|
export const signInValidator = async (queryCode) => {
|
|
7
7
|
|
|
@@ -28,22 +28,22 @@ export const signInValidator = async (queryCode) => {
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
maxAge:
|
|
31
|
+
await setCookie('access_token', response.data.access_token, {
|
|
32
|
+
maxAge: 60 * 60 * 24 * 365, // 1 year,
|
|
33
33
|
path: '/',
|
|
34
34
|
domain: domainHost,
|
|
35
35
|
secure: true
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
maxAge:
|
|
38
|
+
await setCookie('expires_in', response.data.expires_in, {
|
|
39
|
+
maxAge: 60 * 60 * 24 * 365, // 1 year,
|
|
40
40
|
path: '/',
|
|
41
41
|
domain: domainHost,
|
|
42
42
|
secure: true
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
maxAge:
|
|
45
|
+
await setCookie('refresh_token', response.data.refresh_token, {
|
|
46
|
+
maxAge: 60 * 60 * 24 * 365, // 1 year,
|
|
47
47
|
path: '/',
|
|
48
48
|
domain: domainHost,
|
|
49
49
|
secure: true
|
package/src/services/util.js
CHANGED
|
@@ -2,4 +2,26 @@ import React, { useState, useRef, useEffect } from "react";
|
|
|
2
2
|
|
|
3
3
|
export const GetBaseUrl = () => {
|
|
4
4
|
return window.location.protocol + "//" + window.location.host;
|
|
5
|
-
}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const setCookie = (name, value, options = {}) => {
|
|
8
|
+
return new Promise((resolve) => {
|
|
9
|
+
let cookieString = `${name}=${value};`;
|
|
10
|
+
|
|
11
|
+
if (options.maxAge) {
|
|
12
|
+
cookieString += `max-age=${options.maxAge};`;
|
|
13
|
+
}
|
|
14
|
+
if (options.path) {
|
|
15
|
+
cookieString += `path=${options.path};`;
|
|
16
|
+
}
|
|
17
|
+
if (options.domain) {
|
|
18
|
+
cookieString += `domain=${options.domain};`;
|
|
19
|
+
}
|
|
20
|
+
if (options.secure) {
|
|
21
|
+
cookieString += `secure;`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
document.cookie = cookieString;
|
|
25
|
+
resolve();
|
|
26
|
+
});
|
|
27
|
+
}
|