@htmlbricks/hb-auth-social-login-button 0.60.13 → 0.60.15

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/main.iife.js CHANGED
@@ -15,5 +15,5 @@
15
15
  *
16
16
  * @license: MIT License
17
17
  *
18
- */function r(f,m){t.$$host.dispatchEvent(new CustomEvent(f,{detail:m}))}let n=Ne(t,"provider",7,void 0),i=Ne(t,"auth_cookie_name",7,void 0),s=Ne(t,"social_auth_server_url",7,void 0),o=Ne(t,"redirectonlogin",7,void 0),a=Ne(t,"id",7,"");zt(()=>{if(typeof n()=="string")try{n(JSON.parse(n()))}catch(f){console.error(f)}});async function l(){if(!n()?.name||!n().url&&!n().params)return console.error("Provider not defined");if(n().url)location.href=n().url;else if(n().params?.client_id&&n().params.redirect_url){if(!n().params.client_id||!n().params.redirect_url)return console.error("Missing client_id or redirect_url in oauth2ProvidersObj");let f;switch(n().name){case"google":f=`https://accounts.google.com/o/oauth2/v2/auth?scope=${n().params.scope}&include_granted_scopes=true&response_type=token&state=state_parameter_passthrough_value&client_id=${n().params.client_id}&redirect_uri=${n().params.redirect_url}`;break;case"github":f=`https://github.com/login/oauth/authorize?scope=${n().params.scope}&client_id=${n().params.client_id}&redirect_uri=${n().params.redirect_url}`;break;case"gitlab":f=`https://gitlab.com/oauth/authorize?scope=${n().params.scope}&response_type=code&state=${new Date().valueOf()}&client_id=${n().params.client_id}&redirect_uri=${n().params.redirect_url}`;break;case"facebook":f=`https://gitlab.com/oauth/authorize?scope=${n().params.scope}&response_type=code&state=${new Date().valueOf()}&client_id=${n().params.client_id}&redirect_uri=${n().params.redirect_url}`;break;case"authentik":f=`https://${n().params.auth_server_url}/application/o/authorize?scope=${n().params.scope}&response_type=code&state=${new Date().valueOf()}&client_id=${n().params.client_id}&redirect_uri=${n().params.redirect_url}`;break;default:return console.error("no provider uri composed for "+n().name)}if(f)location.href=f;else return console.error("no provider url obtained!?",n())}else console.warn("no provider uri or params defined for "+n().name),r("oauthFlowCustom",{provider:n().name})}function u(f){i()&&s()&&q.socialLoginOauthAnswer(f,{authUrl:s(),authCookieName:i()}).then(m=>{console.log("auth",m),o()?location.href=o():r("oauthFlowSuccess",{token:m})}).catch(m=>console.error("flowerr",m))}function c(){if(console.info("detecting by uri",location.href),n()?.name){if(n().name==="google"&&location?.href&&location.href.split("access_token=").length>1&&location.href.includes("google")){console.info("google auth login detected");const f=location.href.split("access_token=")[1].split("&")[0];u({provider:n().name,token:f}),r("oauthFlowInit",{provider:n().name,token:f})}if(n().name==="github"&&location?.href&&location.href.includes("code=")&&location.href.includes("provider=")&&location.href.split("provider=")[1].split("&")[0]==="github"){console.info("github auth login detected");const f=location.href.split("code=")[1].split("&")[0];u({provider:n().name,token:f,tmpCode:f}),r("oauthFlowInit",{provider:n().name,token:f,tmpCode:f})}if(n().name==="facebook"&&location?.href&&location.href.includes("code=")&&location.href.includes("provider=")&&location.href.split("provider=")[1].split("&")[0]==="facebook"){console.info("facebook auth login detected");const f=location.href.split("code=")[1].split("&")[0],m=location.href.split("state=")[1].split("&")[0],$=location.href.replace("&state=","").replace("?state=","").replace("&code=","").replace("?code=","").replace(f,"").replace(m,"");u({provider:n().name,token:f,tmpCode:f,redirect_uri:$}),r("oauthFlowInit",{provider:n().name,token:f,tmpCode:f,redirect_uri:$})}if(n().name==="gitlab"&&location?.href&&location.href.includes("provider=")&&location.href.includes("code=")&&location.href.split("provider=")[1].split("&")[0]==="gitlab"){const f=location.href.split("code=")[1].split("&")[0],m=location.href.split("state=")[1].split("&")[0],$=location.href.replace("&state=","").replace("?state=","").replace("&code=","").replace("?code=","").replace(f,"").replace(m,"");u({provider:n().name,token:f,tmpCode:f,redirect_uri:$}),r("oauthFlowInit",{provider:n().name,token:f,tmpCode:f,redirect_uri:location.href.replace("&state=","").replace("?state=","").replace("&code=","").replace("?code=","").replace(f,"").replace(m,"")})}if(n().name==="authentik"&&location?.href&&location.href.includes("provider=")&&location.href.includes("code=")&&location.href.split("provider=")[1].split("&")[0]==="authentik"){console.info("authentik auth login detected");const f=location.href.split("code=")[1].split("&")[0],m=location.href.split("state=")[1].split("&")[0],$=location.href.replace("&state=","").replace("?state=","").replace("&code=","").replace("?code=","").replace(f,"").replace(m,"");u({provider:n().name,token:f,tmpCode:f,redirect_uri:$}),r("oauthFlowInit",{provider:n().name,token:f,tmpCode:f,redirect_uri:$})}}}bn(()=>{c()});var _={get provider(){return n()},set provider(f=void 0){n(f),ce()},get auth_cookie_name(){return i()},set auth_cookie_name(f=void 0){i(f),ce()},get social_auth_server_url(){return s()},set social_auth_server_url(f=void 0){s(f),ce()},get redirectonlogin(){return o()},set redirectonlogin(f=void 0){o(f),ce()},get id(){return a()},set id(f=""){a(f),ce()}},d=Pn(),h=Yt(d);h.__click=[Ln,l],h.__keydown=[Nn,l];var v=Yt(h);return En(v,t,"default",{},f=>{var m=Oe(),$=xe(m);{var x=B=>{var we=An();L(B,we)},ze=B=>{var we=Oe(),jn=xe(we);{var qn=$e=>{var He=Rn();L($e,He)},Bn=$e=>{var He=Oe(),Un=xe(He);{var Yn=ye=>{var Ze=In();L(ye,Ze)},Vn=ye=>{var Ze=Oe(),zn=xe(Ze);{var Hn=ke=>{var Ge=Fn();L(ke,Ge)},Zn=ke=>{var Ge=Oe(),Gn=xe(Ge);{var Jn=be=>{var ft=Dn();L(be,ft)},Wn=be=>{var ft=mn("btn");L(be,ft)};Le(Gn,be=>{n()?.name==="authentik"?be(Jn):be(Wn,!1)},!0)}L(ke,Ge)};Le(zn,ke=>{n()?.name==="google"?ke(Hn):ke(Zn,!1)},!0)}L(ye,Ze)};Le(Un,ye=>{n()?.name==="facebook"?ye(Yn):ye(Vn,!1)},!0)}L($e,He)};Le(jn,$e=>{n()?.name==="github"?$e(qn):$e(Bn,!1)},!0)}L(B,we)};Le($,B=>{n()?.name==="gitlab"?B(x):B(ze,!1)})}L(f,m)}),bt(h),bt(d),L(e,d),St(_)}_n(["click","keydown"]),customElements.define("hb-auth-social-login-button",On(dr,{provider:{},auth_cookie_name:{},social_auth_server_url:{},redirectonlogin:{},id:{}},["default"],[],!0)),ct.Component=dr,Object.defineProperty(ct,Symbol.toStringTag,{value:"Module"})})(this["auth-social-login-button"]=this["auth-social-login-button"]||{});
18
+ */function r(f,m){t.$$host.dispatchEvent(new CustomEvent(f,{detail:m}))}let n=Ne(t,"provider",7,void 0),i=Ne(t,"auth_cookie_name",7,void 0),s=Ne(t,"social_auth_server_url",7,void 0),o=Ne(t,"redirectonlogin",7,void 0),a=Ne(t,"id",7,"");zt(()=>{if(typeof n()=="string")try{n(JSON.parse(n()))}catch(f){console.error(f)}});async function l(){if(!n()?.name||!n().url&&!n().params)return console.error("Provider not defined");if(n().url)location.href=n().url;else if(n().params?.client_id&&n().params.redirect_url){if(!n().params.client_id||!n().params.redirect_url)return console.error("Missing client_id or redirect_url in oauth2ProvidersObj");let f;switch(n().name){case"google":f=`https://accounts.google.com/o/oauth2/v2/auth?scope=${n().params.scope}&include_granted_scopes=true&response_type=token&state=state_parameter_passthrough_value&client_id=${n().params.client_id}&redirect_uri=${n().params.redirect_url}`;break;case"github":f=`https://github.com/login/oauth/authorize?scope=${n().params.scope}&client_id=${n().params.client_id}&redirect_uri=${n().params.redirect_url}`;break;case"gitlab":f=`https://gitlab.com/oauth/authorize?scope=${n().params.scope}&response_type=code&state=${new Date().valueOf()}&client_id=${n().params.client_id}&redirect_uri=${n().params.redirect_url}`;break;case"facebook":f=`https://gitlab.com/oauth/authorize?scope=${n().params.scope}&response_type=code&state=${new Date().valueOf()}&client_id=${n().params.client_id}&redirect_uri=${n().params.redirect_url}`;break;case"authentik":f=`${n().params.auth_server_url}/application/o/authorize/?scope=${n().params.scope}&response_type=code&state=${new Date().valueOf()}&client_id=${n().params.client_id}&redirect_uri=${n().params.redirect_url}`;break;default:return console.error("no provider uri composed for "+n().name)}if(f)location.href=f;else return console.error("no provider url obtained!?",n())}else console.warn("no provider uri or params defined for "+n().name),r("oauthFlowCustom",{provider:n().name})}function u(f){i()&&s()&&q.socialLoginOauthAnswer(f,{authUrl:s(),authCookieName:i()}).then(m=>{console.log("auth",m),o()?location.href=o():r("oauthFlowSuccess",{token:m})}).catch(m=>console.error("flowerr",m))}function c(){if(console.info("detecting by uri",location.href),n()?.name){if(n().name==="google"&&location?.href&&location.href.split("access_token=").length>1&&location.href.includes("google")){console.info("google auth login detected");const f=location.href.split("access_token=")[1].split("&")[0];u({provider:n().name,token:f}),r("oauthFlowInit",{provider:n().name,token:f})}if(n().name==="github"&&location?.href&&location.href.includes("code=")&&location.href.includes("provider=")&&location.href.split("provider=")[1].split("&")[0]==="github"){console.info("github auth login detected");const f=location.href.split("code=")[1].split("&")[0];u({provider:n().name,token:f,tmpCode:f}),r("oauthFlowInit",{provider:n().name,token:f,tmpCode:f})}if(n().name==="facebook"&&location?.href&&location.href.includes("code=")&&location.href.includes("provider=")&&location.href.split("provider=")[1].split("&")[0]==="facebook"){console.info("facebook auth login detected");const f=location.href.split("code=")[1].split("&")[0],m=location.href.split("state=")[1].split("&")[0],$=location.href.replace("&state=","").replace("?state=","").replace("&code=","").replace("?code=","").replace(f,"").replace(m,"");u({provider:n().name,token:f,tmpCode:f,redirect_uri:$}),r("oauthFlowInit",{provider:n().name,token:f,tmpCode:f,redirect_uri:$})}if(n().name==="gitlab"&&location?.href&&location.href.includes("provider=")&&location.href.includes("code=")&&location.href.split("provider=")[1].split("&")[0]==="gitlab"){const f=location.href.split("code=")[1].split("&")[0],m=location.href.split("state=")[1].split("&")[0],$=location.href.replace("&state=","").replace("?state=","").replace("&code=","").replace("?code=","").replace(f,"").replace(m,"");u({provider:n().name,token:f,tmpCode:f,redirect_uri:$}),r("oauthFlowInit",{provider:n().name,token:f,tmpCode:f,redirect_uri:location.href.replace("&state=","").replace("?state=","").replace("&code=","").replace("?code=","").replace(f,"").replace(m,"")})}if(n().name==="authentik"&&location?.href&&location.href.includes("provider=")&&location.href.includes("code=")&&location.href.split("provider=")[1].split("&")[0]==="authentik"){console.info("authentik auth login detected");const f=location.href.split("code=")[1].split("&")[0],m=location.href.split("state=")[1].split("&")[0],$=location.href.replace("&state=","").replace("?state=","").replace("&code=","").replace("?code=","").replace(f,"").replace(m,"");u({provider:n().name,token:f,tmpCode:f,redirect_uri:$}),r("oauthFlowInit",{provider:n().name,token:f,tmpCode:f,redirect_uri:$})}}}bn(()=>{c()});var _={get provider(){return n()},set provider(f=void 0){n(f),ce()},get auth_cookie_name(){return i()},set auth_cookie_name(f=void 0){i(f),ce()},get social_auth_server_url(){return s()},set social_auth_server_url(f=void 0){s(f),ce()},get redirectonlogin(){return o()},set redirectonlogin(f=void 0){o(f),ce()},get id(){return a()},set id(f=""){a(f),ce()}},d=Pn(),h=Yt(d);h.__click=[Ln,l],h.__keydown=[Nn,l];var v=Yt(h);return En(v,t,"default",{},f=>{var m=Oe(),$=xe(m);{var x=B=>{var we=An();L(B,we)},ze=B=>{var we=Oe(),jn=xe(we);{var qn=$e=>{var He=Rn();L($e,He)},Bn=$e=>{var He=Oe(),Un=xe(He);{var Yn=ye=>{var Ze=In();L(ye,Ze)},Vn=ye=>{var Ze=Oe(),zn=xe(Ze);{var Hn=ke=>{var Ge=Fn();L(ke,Ge)},Zn=ke=>{var Ge=Oe(),Gn=xe(Ge);{var Jn=be=>{var ft=Dn();L(be,ft)},Wn=be=>{var ft=mn("btn");L(be,ft)};Le(Gn,be=>{n()?.name==="authentik"?be(Jn):be(Wn,!1)},!0)}L(ke,Ge)};Le(zn,ke=>{n()?.name==="google"?ke(Hn):ke(Zn,!1)},!0)}L(ye,Ze)};Le(Un,ye=>{n()?.name==="facebook"?ye(Yn):ye(Vn,!1)},!0)}L($e,He)};Le(jn,$e=>{n()?.name==="github"?$e(qn):$e(Bn,!1)},!0)}L(B,we)};Le($,B=>{n()?.name==="gitlab"?B(x):B(ze,!1)})}L(f,m)}),bt(h),bt(d),L(e,d),St(_)}_n(["click","keydown"]),customElements.define("hb-auth-social-login-button",On(dr,{provider:{},auth_cookie_name:{},social_auth_server_url:{},redirectonlogin:{},id:{}},["default"],[],!0)),ct.Component=dr,Object.defineProperty(ct,Symbol.toStringTag,{value:"Module"})})(this["auth-social-login-button"]=this["auth-social-login-button"]||{});
19
19
  //# sourceMappingURL=main.iife.js.map