@luigi-project/plugin-auth-oauth2 1.24.0 → 1.25.1
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/callback.html +6 -23
- package/package.json +1 -1
package/callback.html
CHANGED
|
@@ -5,24 +5,8 @@
|
|
|
5
5
|
<script type="text/javascript">
|
|
6
6
|
const tokenLifetimeDays = 7;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* defaults to use location.href
|
|
11
|
-
* examples:
|
|
12
|
-
* // query string: ?foo=lorem&bar=&baz
|
|
13
|
-
* var foo = getParameterByName('foo'); // "lorem"
|
|
14
|
-
* var bar = getParameterByName('bar'); // "" (present with empty value)
|
|
15
|
-
* var baz = getParameterByName('baz'); // "" (present with no value)
|
|
16
|
-
* var qux = getParameterByName('qux'); // null (absent)
|
|
17
|
-
*/
|
|
18
|
-
const getParameterByName = (name, url) => {
|
|
19
|
-
if (!url) url = encodeURIComponent(window.location.href);
|
|
20
|
-
name = name.replace(/[\[\]]/g, '\\$&');
|
|
21
|
-
const regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
|
|
22
|
-
results = regex.exec(url);
|
|
23
|
-
if (!results) return null;
|
|
24
|
-
if (!results[2]) return '';
|
|
25
|
-
return decodeURIComponent(results[2].replace(/\+/g, ' '));
|
|
8
|
+
const getParameterByName = name => {
|
|
9
|
+
return new URLSearchParams(location.search).get(name);
|
|
26
10
|
};
|
|
27
11
|
|
|
28
12
|
const setAuthData = data => {
|
|
@@ -57,8 +41,7 @@
|
|
|
57
41
|
if (!isNaN(expiresIn) && expiresIn > 0) {
|
|
58
42
|
const nsToMsMultiplier = 1000;
|
|
59
43
|
expirationDate =
|
|
60
|
-
Number(new Date()) +
|
|
61
|
-
nsToMsMultiplier * (expiresIn - tokenLifetimeDays);
|
|
44
|
+
Number(new Date()) + nsToMsMultiplier * (expiresIn - tokenLifetimeDays);
|
|
62
45
|
}
|
|
63
46
|
return expirationDate;
|
|
64
47
|
};
|
|
@@ -99,9 +82,9 @@
|
|
|
99
82
|
|
|
100
83
|
setAuthData(data);
|
|
101
84
|
|
|
102
|
-
const decodedState = atob(
|
|
103
|
-
|
|
104
|
-
)
|
|
85
|
+
const decodedState = atob(decodeURIComponent(hashParams['state'])).split(
|
|
86
|
+
'_luigiNonce='
|
|
87
|
+
);
|
|
105
88
|
const appState = decodeURI(decodedState[0] || '');
|
|
106
89
|
const nonce = decodedState[1];
|
|
107
90
|
|
package/package.json
CHANGED