authscape 1.0.229 → 1.0.231

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 CHANGED
@@ -99,7 +99,7 @@ function AuthScapeApp(_ref) {
99
99
  open: isLoading
100
100
  }, /*#__PURE__*/_react["default"].createElement(_CircularProgress["default"], {
101
101
  color: "inherit"
102
- })), /*#__PURE__*/_react["default"].createElement(_reactToastify.ToastContainer, null))), process.env.microsoftClarityTrackingCode != null && /*#__PURE__*/_react["default"].createElement("script", {
102
+ })), /*#__PURE__*/_react["default"].createElement(_reactToastify.ToastContainer, null))), loadedUser && process.env.microsoftClarityTrackingCode != null && /*#__PURE__*/_react["default"].createElement("script", {
103
103
  dangerouslySetInnerHTML: {
104
104
  __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.microsoftClarityTrackingCode + "\");"
105
105
  }
@@ -2453,7 +2453,7 @@ var setupDefaultOptions = /*#__PURE__*/function () {
2453
2453
  }();
2454
2454
  var RefreshToken = /*#__PURE__*/function () {
2455
2455
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(originalRequest, instance) {
2456
- var accessToken, refreshToken, response;
2456
+ var accessToken, refreshToken, response, domainHost;
2457
2457
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2458
2458
  while (1) switch (_context2.prev = _context2.next) {
2459
2459
  case 0:
@@ -2474,34 +2474,35 @@ var RefreshToken = /*#__PURE__*/function () {
2474
2474
  case 4:
2475
2475
  response = _context2.sent;
2476
2476
  if (!(response != null && response.status == 200)) {
2477
- _context2.next = 13;
2477
+ _context2.next = 14;
2478
2478
  break;
2479
2479
  }
2480
+ domainHost = window.location.hostname.split('.').slice(-2).join('.');
2480
2481
  originalRequest.headers['Authorization'] = 'Bearer ' + response.data.access_token;
2481
- _context2.next = 9;
2482
+ _context2.next = 10;
2482
2483
  return (0, _nookies.setCookie)(null, "access_token", response.data.access_token, {
2483
2484
  maxAge: 2147483647,
2484
2485
  path: '/',
2485
- domain: window.location.host,
2486
+ domain: domainHost,
2486
2487
  secure: true
2487
2488
  });
2488
- case 9:
2489
- _context2.next = 11;
2489
+ case 10:
2490
+ _context2.next = 12;
2490
2491
  return (0, _nookies.setCookie)(null, "expires_in", response.data.expires_in, {
2491
2492
  maxAge: 2147483647,
2492
2493
  path: '/',
2493
- domain: window.location.host,
2494
+ domain: domainHost,
2494
2495
  secure: true
2495
2496
  });
2496
- case 11:
2497
- _context2.next = 13;
2497
+ case 12:
2498
+ _context2.next = 14;
2498
2499
  return (0, _nookies.setCookie)(null, "refresh_token", response.data.refresh_token, {
2499
2500
  maxAge: 2147483647,
2500
2501
  path: '/',
2501
- domain: window.location.host,
2502
+ domain: domainHost,
2502
2503
  secure: true
2503
2504
  });
2504
- case 13:
2505
+ case 14:
2505
2506
  case "end":
2506
2507
  return _context2.stop();
2507
2508
  }
@@ -2528,7 +2529,7 @@ var apiService = function apiService() {
2528
2529
  return response;
2529
2530
  }, /*#__PURE__*/function () {
2530
2531
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(error) {
2531
- var originalConfig;
2532
+ var originalConfig, domainHost;
2532
2533
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
2533
2534
  while (1) switch (_context3.prev = _context3.next) {
2534
2535
  case 0:
@@ -2558,20 +2559,21 @@ var apiService = function apiService() {
2558
2559
  if (error.response.config.url.includes("/connect/token"))
2559
2560
  // remove the access and refresh if invalid
2560
2561
  {
2562
+ domainHost = window.location.hostname.split('.').slice(-2).join('.');
2561
2563
  (0, _nookies.destroyCookie)(null, "access_token", {
2562
2564
  maxAge: 2147483647,
2563
2565
  path: '/',
2564
- domain: window.location.host
2566
+ domain: domainHost
2565
2567
  });
2566
2568
  (0, _nookies.destroyCookie)(null, "refresh_token", {
2567
2569
  maxAge: 2147483647,
2568
2570
  path: '/',
2569
- domain: window.location.host
2571
+ domain: domainHost
2570
2572
  });
2571
2573
  (0, _nookies.destroyCookie)(null, "expires_in", {
2572
2574
  maxAge: 2147483647,
2573
2575
  path: '/',
2574
- domain: window.location.host
2576
+ domain: domainHost
2575
2577
  });
2576
2578
  }
2577
2579
  return _context3.abrupt("return", Promise.reject(error));
@@ -3025,27 +3027,29 @@ var authService = function authService() {
3025
3027
  logout: function () {
3026
3028
  var _logout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
3027
3029
  var redirectUri,
3030
+ domainHost,
3028
3031
  AuthUri,
3029
3032
  _args4 = arguments;
3030
3033
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
3031
3034
  while (1) switch (_context4.prev = _context4.next) {
3032
3035
  case 0:
3033
3036
  redirectUri = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : null;
3037
+ domainHost = window.location.hostname.split('.').slice(-2).join('.');
3034
3038
  AuthUri = process.env.authorityUri;
3035
3039
  (0, _nookies.destroyCookie)({}, "access_token", {
3036
3040
  maxAge: 2147483647,
3037
3041
  path: '/',
3038
- domain: window.location.host
3042
+ domain: domainHost
3039
3043
  });
3040
3044
  (0, _nookies.destroyCookie)({}, "refresh_token", {
3041
3045
  maxAge: 2147483647,
3042
3046
  path: '/',
3043
- domain: window.location.host
3047
+ domain: domainHost
3044
3048
  });
3045
3049
  (0, _nookies.destroyCookie)({}, "expires_in", {
3046
3050
  maxAge: 2147483647,
3047
3051
  path: '/',
3048
- domain: window.location.host
3052
+ domain: domainHost
3049
3053
  });
3050
3054
  setTimeout(function () {
3051
3055
  if (redirectUri == null) {
@@ -3054,7 +3058,7 @@ var authService = function authService() {
3054
3058
  window.location.href = AuthUri + "/connect/logout?redirect=" + redirectUri;
3055
3059
  }
3056
3060
  }, 500);
3057
- case 6:
3061
+ case 7:
3058
3062
  case "end":
3059
3063
  return _context4.stop();
3060
3064
  }
@@ -3143,13 +3147,13 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
3143
3147
  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); }); }; }
3144
3148
  var signInValidator = /*#__PURE__*/function () {
3145
3149
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(queryCode) {
3146
- var codeVerifier, headers, queryString, response, redirectUri;
3150
+ var codeVerifier, headers, queryString, response, domainHost, redirectUri;
3147
3151
  return _regeneratorRuntime().wrap(function _callee$(_context) {
3148
3152
  while (1) switch (_context.prev = _context.next) {
3149
3153
  case 0:
3150
3154
  codeVerifier = window.localStorage.getItem("verifier");
3151
3155
  if (!(queryCode != null && codeVerifier != null)) {
3152
- _context.next = 17;
3156
+ _context.next = 18;
3153
3157
  break;
3154
3158
  }
3155
3159
  headers = {
@@ -3169,31 +3173,32 @@ var signInValidator = /*#__PURE__*/function () {
3169
3173
  });
3170
3174
  case 6:
3171
3175
  response = _context.sent;
3176
+ domainHost = window.location.hostname.split('.').slice(-2).join('.');
3172
3177
  window.localStorage.removeItem("verifier");
3173
- _context.next = 10;
3178
+ _context.next = 11;
3174
3179
  return (0, _nookies.setCookie)(null, "access_token", response.data.access_token, {
3175
3180
  maxAge: 2147483647,
3176
3181
  path: '/',
3177
- domain: window.location.host,
3182
+ domain: domainHost,
3178
3183
  secure: true
3179
3184
  });
3180
- case 10:
3181
- _context.next = 12;
3185
+ case 11:
3186
+ _context.next = 13;
3182
3187
  return (0, _nookies.setCookie)(null, "expires_in", response.data.expires_in, {
3183
3188
  maxAge: 2147483647,
3184
3189
  path: '/',
3185
- domain: window.location.host,
3190
+ domain: domainHost,
3186
3191
  secure: true
3187
3192
  });
3188
- case 12:
3189
- _context.next = 14;
3193
+ case 13:
3194
+ _context.next = 15;
3190
3195
  return (0, _nookies.setCookie)(null, "refresh_token", response.data.refresh_token, {
3191
3196
  maxAge: 2147483647,
3192
3197
  path: '/',
3193
- domain: window.location.host,
3198
+ domain: domainHost,
3194
3199
  secure: true
3195
3200
  });
3196
- case 14:
3201
+ case 15:
3197
3202
  redirectUri = localStorage.getItem("redirectUri");
3198
3203
  localStorage.clear();
3199
3204
  if (redirectUri != null) {
@@ -3201,7 +3206,7 @@ var signInValidator = /*#__PURE__*/function () {
3201
3206
  } else {
3202
3207
  window.location.href = "/";
3203
3208
  }
3204
- case 17:
3209
+ case 18:
3205
3210
  case "end":
3206
3211
  return _context.stop();
3207
3212
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authscape",
3
- "version": "1.0.229",
3
+ "version": "1.0.231",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -91,7 +91,7 @@ export function AuthScapeApp({Component, pageProps, muiTheme = {}, enforceLogged
91
91
  }
92
92
  </ThemeProvider>
93
93
 
94
- {process.env.microsoftClarityTrackingCode != null &&
94
+ {(loadedUser && process.env.microsoftClarityTrackingCode != null) &&
95
95
  <script
96
96
  dangerouslySetInnerHTML={{
97
97
  __html: `
@@ -55,13 +55,14 @@ const RefreshToken = async (originalRequest, instance) => {
55
55
 
56
56
  if (response != null && response.status == 200)
57
57
  {
58
+ let domainHost = window.location.hostname.split('.').slice(-2).join('.');
58
59
  originalRequest.headers['Authorization'] = 'Bearer ' + response.data.access_token;
59
60
 
60
61
  await setCookie(null, "access_token", response.data.access_token,
61
62
  {
62
63
  maxAge: 2147483647,
63
64
  path: '/',
64
- domain: window.location.host,
65
+ domain: domainHost,
65
66
  secure: true
66
67
  });
67
68
 
@@ -69,7 +70,7 @@ const RefreshToken = async (originalRequest, instance) => {
69
70
  {
70
71
  maxAge: 2147483647,
71
72
  path: '/',
72
- domain: window.location.host,
73
+ domain: domainHost,
73
74
  secure: true
74
75
  });
75
76
 
@@ -77,7 +78,7 @@ const RefreshToken = async (originalRequest, instance) => {
77
78
  {
78
79
  maxAge: 2147483647,
79
80
  path: '/',
80
- domain: window.location.host,
81
+ domain: domainHost,
81
82
  secure: true
82
83
  });
83
84
  }
@@ -123,22 +124,24 @@ export const apiService = (ctx = null) => {
123
124
 
124
125
  if (error.response.config.url.includes("/connect/token")) // remove the access and refresh if invalid
125
126
  {
127
+ let domainHost = window.location.hostname.split('.').slice(-2).join('.');
128
+
126
129
  destroyCookie(null, "access_token", {
127
130
  maxAge: 2147483647,
128
131
  path: '/',
129
- domain: window.location.host
132
+ domain: domainHost
130
133
  });
131
134
 
132
135
  destroyCookie(null, "refresh_token", {
133
136
  maxAge: 2147483647,
134
137
  path: '/',
135
- domain: window.location.host
138
+ domain: domainHost
136
139
  });
137
140
 
138
141
  destroyCookie(null, "expires_in", {
139
142
  maxAge: 2147483647,
140
143
  path: '/',
141
- domain: window.location.host
144
+ domain: domainHost
142
145
  });
143
146
  }
144
147
 
@@ -83,23 +83,24 @@ export const authService = () => {
83
83
  },
84
84
  logout: async (redirectUri = null) => {
85
85
 
86
+ let domainHost = window.location.hostname.split('.').slice(-2).join('.');
86
87
  let AuthUri = process.env.authorityUri;
87
88
  destroyCookie({}, "access_token", {
88
89
  maxAge: 2147483647,
89
90
  path: '/',
90
- domain: window.location.host
91
+ domain: domainHost
91
92
  });
92
93
 
93
94
  destroyCookie({}, "refresh_token", {
94
95
  maxAge: 2147483647,
95
96
  path: '/',
96
- domain: window.location.host
97
+ domain: domainHost
97
98
  });
98
99
 
99
100
  destroyCookie({}, "expires_in", {
100
101
  maxAge: 2147483647,
101
102
  path: '/',
102
- domain: window.location.host
103
+ domain: domainHost
103
104
  });
104
105
 
105
106
  setTimeout(() => {
@@ -23,13 +23,14 @@ export const signInValidator = async (queryCode) => {
23
23
  headers: headers
24
24
  });
25
25
 
26
+ let domainHost = window.location.hostname.split('.').slice(-2).join('.');
26
27
  window.localStorage.removeItem("verifier");
27
28
 
28
29
  await setCookie(null, "access_token", response.data.access_token,
29
30
  {
30
31
  maxAge: 2147483647,
31
32
  path: '/',
32
- domain: window.location.host,
33
+ domain: domainHost,
33
34
  secure: true
34
35
  });
35
36
 
@@ -37,7 +38,7 @@ export const signInValidator = async (queryCode) => {
37
38
  {
38
39
  maxAge: 2147483647,
39
40
  path: '/',
40
- domain: window.location.host,
41
+ domain: domainHost,
41
42
  secure: true
42
43
  });
43
44
 
@@ -45,7 +46,7 @@ export const signInValidator = async (queryCode) => {
45
46
  {
46
47
  maxAge: 2147483647,
47
48
  path: '/',
48
- domain: window.location.host,
49
+ domain: domainHost,
49
50
  secure: true
50
51
  });
51
52