-
Notifications
You must be signed in to change notification settings - Fork 0
/
404.26051bc334d8aa0f9dbf.js
1 lines (1 loc) · 7.59 KB
/
404.26051bc334d8aa0f9dbf.js
1
"use strict";(self.webpackChunksparkworks_console=self.webpackChunksparkworks_console||[]).push([[404],{95404:function(Z,B,s){s.r(B),s.d(B,{amplify_amazon_button:function(){return L},amplify_auth0_button:function(){return N},amplify_facebook_button:function(){return F},amplify_google_button:function(){return x},amplify_oauth_button:function(){return R}});var O=s(8239),w=s(75134),E=s(47289),M=s(88774),I=s.n(M),u=s(65513),C=s(45013),S=s(53799),D=s(82073),i=s(33542),b=s(33754),A=s(84665),T=s(83126),W=new C.k("amplify-amazon-button"),L=function(){function r(a){var e=this;(0,w.Z)(this,r),(0,u.r)(this,a),this.handleAuthStateChange=T.d,this.federatedSignIn=function(n){var t=n.access_token,_=n.expires_in;if(t){if(!i.g||"function"!=typeof i.g.federatedSignIn||"function"!=typeof i.g.currentAuthenticatedUser)throw new Error(A.N);var h=1e3*_+(new Date).getTime();window.amazon.Login.retrieveProfile(function(){var v=(0,O.Z)(I().mark(function l(f){var p;return I().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(f.success){c.next=2;break}return c.abrupt("return",W.debug("Get user Info failed"));case 2:return p={name:f.profile.Name,email:f.profile.PrimaryEmail},c.next=5,i.g.federatedSignIn("amazon",{token:t,expires_at:h},p);case 5:return c.next=7,i.g.currentAuthenticatedUser();case 7:e.handleAuthStateChange(D.A.SignedIn,c.sent);case 9:case"end":return c.stop()}},l)}));return function(l){return v.apply(this,arguments)}}())}}}return(0,E.Z)(r,[{key:"signInWithAmazon",value:function(e){var n=this;e.preventDefault(),window.amazon.Login.setClientId(this.clientId),window.amazon.Login.authorize({scope:"profile"},function(t){if(t.error)return W.debug("Failed to login with amazon: "+t.error);try{window.localStorage.setItem(A.h,JSON.stringify({provider:"amazon"}))}catch(_){W.debug("Failed to cache auth source into localStorage",_)}n.federatedSignIn(t)})}},{key:"render",value:function(){var e=this;return(0,u.h)("amplify-sign-in-button",{onClick:function(t){return e.signInWithAmazon(t)},provider:"amazon"},(0,u.h)("script",{src:"https://assets.loginwithamazon.com/sdk/na/login1.js"}),S.o.get(b.T.SIGN_IN_WITH_AMAZON))}}]),r}(),k=new C.k("amplify-auth0-button"),N=function(){function r(a){var e=this;(0,w.Z)(this,r),(0,u.r)(this,a),this.handleAuthStateChange=T.d,this.handleLoad=function(){var t=i.g.configure().oauth,g=e.config,h=void 0===g?(void 0===t?{}:t).auth0:g;h?(k.debug("auth0 configuration",h),e._auth0||(e._auth0=new window.auth0.WebAuth(h)),e._auth0.parseHash(function(v,l){if(v)k.debug("Failed to parse the url for Auth0",v);else if(l){var f={provider:"auth0",opts:{returnTo:h.returnTo,clientID:h.clientID,federated:h.federated}};try{localStorage.setItem(A.h,JSON.stringify(f))}catch(p){k.debug("Failed to cache auth source into localStorage",p)}e._auth0.client.userInfo(l.accessToken,function(){var p=(0,O.Z)(I().mark(function o(d,c){var m,U;return I().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return m=void 0,U=void 0,d?k.debug("Failed to get the user info",d):(m=c.name,U=c.email),y.next=5,i.g.federatedSignIn(h.domain,{token:l.idToken,expires_at:1e3*l.expiresIn+(new Date).getTime()},{name:m,email:U});case 5:return y.next=7,i.g.currentAuthenticatedUser();case 7:e.handleAuthStateChange(D.A.SignedIn,y.sent);case 9:case"end":return y.stop()}},o)}));return function(o,d){return p.apply(this,arguments)}}())}else k.debug("Auth0 found no authResult in hash")})):k.debug("Auth0 is not configured")}}return(0,E.Z)(r,[{key:"signInWithAuth0",value:function(e){if(e.preventDefault(),!this._auth0)throw new Error("the auth0 client is not configured");this._auth0.authorize()}},{key:"render",value:function(){var e=this;return(0,u.h)("amplify-sign-in-button",{onClick:function(t){return e.signInWithAuth0(t)},provider:"auth0"},(0,u.h)("script",{onLoad:this.handleLoad,src:"https://cdn.auth0.com/js/auth0/9.11/auth0.min.js"}),S.o.get(b.T.SIGN_IN_WITH_AUTH0))}}]),r}(),z=new C.k("amplify-facebook-button"),F=function(){function r(a){var e=this;(0,w.Z)(this,r),(0,u.r)(this,a),this.handleAuthStateChange=T.d,this.federatedSignIn=function(n){var t=n.accessToken,_=n.expiresIn;if(t){if(!i.g||"function"!=typeof i.g.federatedSignIn||"function"!=typeof i.g.currentAuthenticatedUser)throw new Error(A.N);var h=1e3*_+(new Date).getTime();window.FB.api("/me",{fields:"name,email"},function(){var l=(0,O.Z)(I().mark(function f(p){var o;return I().wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return o={name:p.name,email:p.email},m.next=3,i.g.federatedSignIn("facebook",{token:t,expires_at:h},o);case 3:return m.next=5,i.g.currentAuthenticatedUser();case 5:e.handleAuthStateChange(D.A.SignedIn,m.sent);case 7:case"end":return m.stop()}},f)}));return function(f){return l.apply(this,arguments)}}())}},this.getLoginStatus=function(){window.FB.getLoginStatus(function(n){try{window.localStorage.setItem(A.h,JSON.stringify({provider:"facebook"}))}catch(t){z.debug("Failed to cache auth source into localStorage",t)}if("connected"===n.status)return e.federatedSignIn(n.authResponse);e.login()})},this.login=function(){window.FB.login(function(t){t&&t.authResponse&&e.federatedSignIn(t.authResponse)},{scope:"public_profile,email"})}}return(0,E.Z)(r,[{key:"signInWithFacebook",value:function(e){e.preventDefault(),window.FB.init({appId:this.appId,cookie:!0,xfbml:!1,version:"v5.0"}),this.getLoginStatus()}},{key:"render",value:function(){var e=this;return(0,u.h)("amplify-sign-in-button",{onClick:function(t){return e.signInWithFacebook(t)},provider:"facebook"},(0,u.h)("script",{async:!0,defer:!0,src:"https://connect.facebook.net/en_US/sdk.js"}),S.o.get(b.T.SIGN_IN_WITH_FACEBOOK))}}]),r}(),j=new C.k("amplify-google-button"),x=function(){function r(a){var e=this;(0,w.Z)(this,r),(0,u.r)(this,a),this.handleAuthStateChange=T.d,this.handleError=function(n){console.error(n)},this.handleLoad=function(){window.gapi.load("auth2")},this.handleUser=function(){var n=(0,O.Z)(I().mark(function t(_){var g,h,v,l,f;return I().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(i.g&&"function"==typeof i.g.federatedSignIn&&"function"==typeof i.g.currentAuthenticatedUser){o.next=2;break}throw new Error(A.N);case 2:try{window.localStorage.setItem(A.h,JSON.stringify({provider:"google"}))}catch(d){j.debug("Failed to cache auth source into localStorage",d)}return g=_.getAuthResponse(),h=g.id_token,v=g.expires_at,l=_.getBasicProfile(),o.next=7,i.g.federatedSignIn("google",{token:h,expires_at:v},{email:l.getEmail(),name:l.getName(),picture:l.getImageUrl()});case 7:return o.next=9,i.g.currentAuthenticatedUser();case 9:f=o.sent;try{e.handleAuthStateChange(D.A.SignedIn,f)}catch(d){e.handleError(d)}case 11:case"end":return o.stop()}},t)}));return function(t){return n.apply(this,arguments)}}()}return(0,E.Z)(r,[{key:"getAuthInstance",value:function(){return window.gapi&&window.gapi.auth2?window.gapi.auth2.getAuthInstance()||window.gapi.auth2.init({client_id:this.clientId,cookiepolicy:"single_host_origin",scope:"profile email openid"}):null}},{key:"signInWithGoogle",value:function(e){e.preventDefault(),this.getAuthInstance().signIn().then(this.handleUser).catch(this.handleError)}},{key:"render",value:function(){var e=this;return(0,u.h)("amplify-sign-in-button",{onClick:function(t){return e.signInWithGoogle(t)},provider:"google"},(0,u.h)("script",{onLoad:this.handleLoad,src:"https://apis.google.com/js/api:client.js"}),S.o.get(b.T.SIGN_IN_WITH_GOOGLE))}}]),r}(),R=function(){function r(a){(0,w.Z)(this,r),(0,u.r)(this,a),this.config={}}return(0,E.Z)(r,[{key:"signInWithOAuth",value:function(e){e.preventDefault(),i.g.federatedSignIn()}},{key:"render",value:function(){var e=this;return(0,u.h)("amplify-sign-in-button",{onClick:function(t){return e.signInWithOAuth(t)},provider:"oauth"},this.config.label||S.o.get(b.T.SIGN_IN_WITH_AWS))}}]),r}()}}]);