@luigi-project/plugin-auth-oauth2 1.23.1 → 1.25.0

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/README.md CHANGED
@@ -1,17 +1,19 @@
1
1
  <!-- meta
2
2
  {
3
3
  "node": {
4
- "label": "OAuth2",
4
+ "label": "OAuth2 Plugin",
5
5
  "category": {
6
- "label": "Authorization Plugins"
6
+ "label": "Authorization",
7
+ "collapsible": true
7
8
  },
8
9
  "metaData": {
9
- "categoryPosition": 2,
10
- "position": 12
10
+ "categoryPosition": 4,
11
+ "position": 2
11
12
  }
12
13
  }
13
14
  }
14
15
  meta -->
16
+
15
17
  # OAuth2 - Authorization Plugin for Luigi Core
16
18
 
17
19
  ## Overview
@@ -76,4 +78,4 @@ If your application does not use webpack or you installed Luigi without a framew
76
78
  "copyCallbackOAuth": "copyfiles -f node_modules/@luigi-project/plugin-auth-oauth2/callback.html public/assets/auth-oauth2"
77
79
  ```
78
80
 
79
- Running `npm run build` should then suffice to bundle the config and also copy the callback file.
81
+ Running `npm run build` should then suffice to bundle the config and also copy the callback file.
package/callback.html CHANGED
@@ -5,24 +5,8 @@
5
5
  <script type="text/javascript">
6
6
  const tokenLifetimeDays = 7;
7
7
 
8
- /**
9
- * get query parameter from url
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
- decodeURIComponent(hashParams['state'])
104
- ).split('_luigiNonce=');
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
@@ -16,5 +16,5 @@
16
16
  "oauth2",
17
17
  "provider"
18
18
  ],
19
- "version": "1.23.1"
19
+ "version": "1.25.0"
20
20
  }