jwtbutler 1.7.7 → 1.8.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
@@ -67,7 +67,7 @@ sso: [
67
67
  ];
68
68
  ```
69
69
 
70
- then deploy the helper file [sso.html](https://github.com/vielhuber/jwtbutler/blob/master/_dist/sso.html) in the root public directories of all pages that use single sign on. don't forget to fill out all origin page domains in line 7. Also make sure to add a valid Content-Security-Policy (for example with the help of a [.htaccess](https://github.com/vielhuber/jwtbutler/blob/master/_dist/.htaccess) file).
70
+ then deploy the helper file [sso.html](https://github.com/vielhuber/jwtbutler/blob/main/_dist/sso.html) in the root public directories of all pages that use single sign on. don't forget to fill out all origin page domains in line 7. Also make sure to add a valid Content-Security-Policy (for example with the help of a [.htaccess](https://github.com/vielhuber/jwtbutler/blob/main/_dist/.htaccess) file).
71
71
 
72
72
  ### custom login dom
73
73
 
@@ -212,6 +212,7 @@ if (@$_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
212
212
  }
213
213
 
214
214
  try {
215
+ // access token is delivered via authorization header or cookie
215
216
  $token = null;
216
217
  if ($_SERVER['HTTP_AUTHORIZATION'] ?? '') {
217
218
  $token = str_replace('Bearer ', '', $_SERVER['HTTP_AUTHORIZATION']);
@@ -219,7 +220,7 @@ try {
219
220
  $token = str_replace('Bearer ', '', $_COOKIE['access_token']);
220
221
  }
221
222
  $user_id = JWT::decode(
222
- $token, // access token
223
+ $token,
223
224
  new Key('WM38tprPABEgkldbt2yTAgxf2CGstfr5', 'HS256'), // secret key
224
225
  )->sub;
225
226
  http_response_code(200);
@@ -4,8 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- require("core-js/modules/es.regexp.constructor.js");
8
- require("core-js/modules/es.regexp.exec.js");
9
7
  class helpers {
10
8
  static cookieExists(cookie_name) {
11
9
  if (document.cookie !== undefined && this.cookieGet(cookie_name) !== null) {
@@ -275,7 +275,25 @@ class jwtbutler {
275
275
  }
276
276
  buildUpLoginFormHtml() {
277
277
  if (!('login_form' in this.config) || this.config.login_form == '') {
278
- this.config.login_form = "<div class=\"login-form\">\n <div class=\"login-form__inner\">\n <form class=\"login-form__form\">\n <ul class=\"login-form__items\">\n <li class=\"login-form__item\">\n <label class=\"login-form__label login-form__label--".concat(this.config.auth_login, "\" for=\"login-form__label--").concat(this.config.auth_login, "\">").concat(this.config.auth_login === 'email' ? 'E-Mail-Adresse' : this.config.auth_login === 'username' ? 'Benutzername' : this.config.auth_login, "</label>\n <input class=\"login-form__input login-form__input--").concat(this.config.auth_login, "\" id=\"login-form__label--").concat(this.config.auth_login, "\" type=\"text\" required=\"required\" name=\"").concat(this.config.auth_login, "\" />\n </li>\n <li class=\"login-form__item\">\n <label class=\"login-form__label login-form__label--password\" for=\"login-form__label--password\">Passwort</label>\n <input class=\"login-form__input login-form__input--password\" id=\"login-form__label--password\" type=\"password\" required=\"required\" name=\"password\" />\n </li>\n <li class=\"login-form__item\">\n <input class=\"login-form__submit\" type=\"submit\" value=\"Anmelden\" />\n </li>\n </ul>\n </form>\n </div>\n </div>");
278
+ this.config.login_form = `<div class="login-form">
279
+ <div class="login-form__inner">
280
+ <form class="login-form__form">
281
+ <ul class="login-form__items">
282
+ <li class="login-form__item">
283
+ <label class="login-form__label login-form__label--${this.config.auth_login}" for="login-form__label--${this.config.auth_login}">${this.config.auth_login === 'email' ? 'E-Mail-Adresse' : this.config.auth_login === 'username' ? 'Benutzername' : this.config.auth_login}</label>
284
+ <input class="login-form__input login-form__input--${this.config.auth_login}" id="login-form__label--${this.config.auth_login}" type="text" required="required" name="${this.config.auth_login}" />
285
+ </li>
286
+ <li class="login-form__item">
287
+ <label class="login-form__label login-form__label--password" for="login-form__label--password">Passwort</label>
288
+ <input class="login-form__input login-form__input--password" id="login-form__label--password" type="password" required="required" name="password" />
289
+ </li>
290
+ <li class="login-form__item">
291
+ <input class="login-form__submit" type="submit" value="Anmelden" />
292
+ </li>
293
+ </ul>
294
+ </form>
295
+ </div>
296
+ </div>`;
279
297
  }
280
298
  let dom = new DOMParser().parseFromString(this.config.login_form, 'text/html').body.childNodes[0];
281
299
  this.config.login_form_class = dom.getAttribute('class').split(' ')[0];
package/package.json CHANGED
@@ -84,7 +84,7 @@
84
84
  },
85
85
  "devDependencies": {},
86
86
  "name": "jwtbutler",
87
- "version": "1.7.7",
87
+ "version": "1.8.0",
88
88
  "description": "",
89
89
  "main": "_js/_build/script.js",
90
90
  "files": [