@luigi-project/plugin-auth-oauth2 2.29.1-dev.202603250048 → 2.29.1-dev.202603270053

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 CHANGED
@@ -32,7 +32,7 @@
32
32
  var parts = item.split('=');
33
33
  result[parts[0]] = parts[1];
34
34
  return result;
35
- }, {});
35
+ }, Object.create(null));
36
36
  };
37
37
 
38
38
  const processExpDate = (expiresInString) => {
package/package.json CHANGED
@@ -16,5 +16,5 @@
16
16
  "oauth2",
17
17
  "provider"
18
18
  ],
19
- "version": "2.29.1-dev.202603250048"
19
+ "version": "2.29.1-dev.202603270053"
20
20
  }
package/plugin.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["LuigiPlugin-auth-oauth2"]=t():e["LuigiPlugin-auth-oauth2"]=t()}(self,()=>(()=>{"use strict";var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function i(e){var t=function(e){if("object"!=o(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=o(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==o(t)?t:t+""}function r(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,i(o.key),o)}}function a(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function u(e,t,n){return(t=i(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}e.d(t,{default:()=>s});var c=new(function(){return a(function e(){n(this,e)},[{key:"getRandomId",value:function(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}},{key:"isFunction",value:function(e){return e&&"[object Function]"==={}.toString.call(e)}},{key:"isPromise",value:function(e){return e&&this.isFunction(e.then)}},{key:"isObject",value:function(e){return e&&"object"===o(e)&&!Array.isArray(e)}},{key:"deepMerge",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];if(!n.length)return e;var i=n.shift();if(this.isObject(e)&&this.isObject(i))for(var r in i)this.isObject(i[r])?(e[r]||Object.assign(e,u({},r,{})),this.deepMerge(e[r],i[r])):Object.assign(e,u({},r,i[r]));return this.deepMerge.apply(this,[e].concat(n))}},{key:"prependOrigin",value:function(e){if(e.startsWith("http"))return e;var t=e.startsWith("/");return e.length?window.location.origin+(t?"":"/")+e:window.location.origin}}])}()),s=function(){return a(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};n(this,e);var o={oAuthData:{redirect_uri:window.location.origin+"/assets/auth-oauth2/callback.html",response_type:"id_token token",scope:""},authorizeMethod:"GET",logoutUrl:"",post_logout_redirect_uri:window.location.origin+"/logout.html",accessTokenExpiringNotificationTime:60,expirationCheckInterval:5},i=c.deepMerge(o,t);this.settings=i},[{key:"getAuthData",value:function(){return Luigi.auth().store.getAuthData()}},{key:"parseIdToken",value:function(e){var t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/");return JSON.parse(window.atob(t))}},{key:"userInfo",value:function(){var e=this;return new Promise(function(t,n){var o=e.getAuthData(),i=e.parseIdToken(o.idToken);t({email:i.email?i.email:"",name:i.name?i.name:""})})}},{key:"login",value:function(){var e=this;return new Promise(function(t,n){var o=e.settings,i=o.nonceFn&&o.nonceFn()||e.generateNonce();sessionStorage.setItem("luigi.nonceValue",i),o.oAuthData.nonce||(o.oAuthData.nonce=i);var r=function(e,t){return Object.assign(document.createElement("input"),{name:e,id:e,value:t,type:"hidden"})},a=Object.assign(document.createElement("form"),{name:"signIn",id:"signIn",action:o.authorizeUrl,method:o.authorizeMethod,target:"_self"});for(var u in o.oAuthData.redirect_uri="".concat(c.prependOrigin(o.oAuthData.redirect_uri),"?storageType=").concat(Luigi.auth().store.getStorageType()),o.oAuthData.state=btoa(encodeURI(window.location.href)+"_luigiNonce="+i),o.oAuthData){var s=r(u,o.oAuthData[u]);a.appendChild(s.cloneNode())}document.getElementsByTagName("body")[0].appendChild(a),setTimeout(function(){document.querySelector("form#signIn").submit()}),document.querySelector("form#signIn").addEventListener("load",function(t){console.info("load, e",t,e)})})}},{key:"logout",value:function(e,t){var n=this.settings,o="".concat(n.logoutUrl,"?id_token_hint=").concat(e.idToken,"&client_id=").concat(n.oAuthData.client_id,"&post_logout_redirect_uri=").concat(c.prependOrigin(n.post_logout_redirect_uri));t&&t(),setTimeout(function(){window.location.href=o})}},{key:"setTokenExpirationAction",value:function(){var e=this;this.expirationCheckIntervalInstance=setInterval(function(){var t=e.getAuthData();if(!t)return clearInterval(e.expirationCheckIntervalInstance);if((t&&t.accessTokenExpirationDate||0)-new Date<5e3){clearInterval(e.expirationCheckIntervalInstance),Luigi.auth().store.removeAuthData();var n="".concat(e.settings.logoutUrl,"?error=tokenExpired&post_logout_redirect_uri=").concat(c.prependOrigin(e.settings.post_logout_redirect_uri));Luigi.auth().handleAuthEvent("onAuthExpired",e.settings,void 0,n)}},5e3)}},{key:"setTokenExpireSoonAction",value:function(){var e=this,t=1e3*this.settings.accessTokenExpiringNotificationTime,n=1e3*this.settings.expirationCheckInterval,o=this.getAuthData();o&&(this.expirationSoonCheckIntervalInstance=setInterval(function(){(o&&o.accessTokenExpirationDate||0)-(new Date).getTime()<t&&(Luigi.auth().handleAuthEvent("onAuthExpireSoon",e.settings),clearInterval(e.expirationSoonCheckIntervalInstance))},n))}},{key:"generateNonce",value:function(){var e=window.crypto;return Array.from(e.getRandomValues(new Uint8Array(20))).map(function(e){return"0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz"[e%61]}).join("")}},{key:"resetExpirationChecks",value:function(){this.unload(),this.setTokenExpirationAction(),this.setTokenExpireSoonAction()}},{key:"unload",value:function(){clearInterval(this.expirationCheckIntervalInstance),clearInterval(this.expirationSoonCheckIntervalInstance)}}])}();return t.default})());
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["LuigiPlugin-auth-oauth2"]=t():e["LuigiPlugin-auth-oauth2"]=t()}(self,()=>(()=>{"use strict";var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function i(e){var t=function(e){if("object"!=o(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=o(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==o(t)?t:t+""}function r(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,i(o.key),o)}}function a(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function u(e,t,n){return(t=i(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}e.d(t,{default:()=>s});var c=new(function(){return a(function e(){n(this,e)},[{key:"getRandomId",value:function(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}},{key:"isFunction",value:function(e){return e&&"[object Function]"==={}.toString.call(e)}},{key:"isPromise",value:function(e){return e&&this.isFunction(e.then)}},{key:"isObject",value:function(e){return e&&"object"===o(e)&&!Array.isArray(e)}},{key:"deepMerge",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];if(!n.length)return e;var i=n.shift();if(this.isObject(e)&&this.isObject(i))for(var r in i)this.isObject(i[r])?(e[r]||Object.assign(e,u({},r,{})),this.deepMerge(e[r],i[r])):Object.assign(e,u({},r,i[r]));return this.deepMerge.apply(this,[e].concat(n))}},{key:"prependOrigin",value:function(e){if(e.startsWith("http"))return e;var t=e.startsWith("/");return e.length?window.location.origin+(t?"":"/")+e:window.location.origin}}])}()),s=function(){return a(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};n(this,e);var o={oAuthData:{redirect_uri:window.location.origin+"/assets/auth-oauth2/callback.html",response_type:"id_token token",scope:""},authorizeMethod:"GET",logoutUrl:"",post_logout_redirect_uri:window.location.origin+"/logout.html",accessTokenExpiringNotificationTime:60,expirationCheckInterval:5},i=c.deepMerge(o,t);this.settings=i},[{key:"getAuthData",value:function(){return Luigi.auth().store.getAuthData()}},{key:"parseIdToken",value:function(e){var t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/");return JSON.parse(window.atob(t))}},{key:"userInfo",value:function(){var e=this;return new Promise(function(t,n){var o=e.getAuthData(),i=e.parseIdToken(o.idToken);t({email:i.email?i.email:"",name:i.name?i.name:""})})}},{key:"login",value:function(){var e=this;return new Promise(function(t,n){var o=e.settings,i=o.nonceFn&&o.nonceFn()||e.generateNonce();sessionStorage.setItem("luigi.nonceValue",i),o.oAuthData.nonce||(o.oAuthData.nonce=i);var r=function(e,t){return Object.assign(document.createElement("input"),{name:e,id:e,value:t,type:"hidden"})},a=Object.assign(document.createElement("form"),{name:"signIn",id:"signIn",action:o.authorizeUrl,method:o.authorizeMethod,target:"_self"});for(var u in o.oAuthData.redirect_uri="".concat(c.prependOrigin(o.oAuthData.redirect_uri),"?storageType=").concat(Luigi.auth().store.getStorageType()),o.oAuthData.state=btoa(encodeURI(window.location.href)+"_luigiNonce="+i),o.oAuthData){var s=r(u,o.oAuthData[u]);a.appendChild(s.cloneNode())}document.getElementsByTagName("body")[0].appendChild(a),setTimeout(function(){document.querySelector("form#signIn").submit()}),document.querySelector("form#signIn").addEventListener("load",function(t){console.info("load, e",t,e)})})}},{key:"logout",value:function(e,t){var n=this.settings,o="".concat(n.logoutUrl,"?id_token_hint=").concat(e.idToken,"&client_id=").concat(n.oAuthData.client_id,"&post_logout_redirect_uri=").concat(c.prependOrigin(n.post_logout_redirect_uri));t&&t(),setTimeout(function(){window.location.href=o})}},{key:"setTokenExpirationAction",value:function(){var e=this;this.expirationCheckIntervalInstance=setInterval(function(){var t=e.getAuthData();if(!t)return clearInterval(e.expirationCheckIntervalInstance);if((t&&t.accessTokenExpirationDate||0)-new Date<5e3){clearInterval(e.expirationCheckIntervalInstance),Luigi.auth().store.removeAuthData();var n="".concat(e.settings.logoutUrl,"?error=tokenExpired&post_logout_redirect_uri=").concat(c.prependOrigin(e.settings.post_logout_redirect_uri));Luigi.auth().handleAuthEvent("onAuthExpired",e.settings,void 0,n)}},5e3)}},{key:"setTokenExpireSoonAction",value:function(){var e=this,t=1e3*this.settings.accessTokenExpiringNotificationTime,n=1e3*this.settings.expirationCheckInterval,o=this.getAuthData();o&&(this.expirationSoonCheckIntervalInstance=setInterval(function(){(o&&o.accessTokenExpirationDate||0)-(new Date).getTime()<t&&(Luigi.auth().handleAuthEvent("onAuthExpireSoon",e.settings),clearInterval(e.expirationSoonCheckIntervalInstance))},n))}},{key:"generateNonce",value:function(){var e=window.crypto;return Array.from(e.getRandomValues(new Uint8Array(20))).map(function(t){for(;t>=61*Math.floor(256/61);)t=e.getRandomValues(new Uint8Array(1))[0];return"0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz"[t%61]}).join("")}},{key:"resetExpirationChecks",value:function(){this.unload(),this.setTokenExpirationAction(),this.setTokenExpireSoonAction()}},{key:"unload",value:function(){clearInterval(this.expirationCheckIntervalInstance),clearInterval(this.expirationSoonCheckIntervalInstance)}}])}();return t.default})());