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