@verdocs/web-sdk 4.2.76 → 4.2.78
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/dist/cjs/verdocs-auth.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-preview_10.cjs.entry.js +3 -0
- package/dist/collection/components/embeds/verdocs-auth/verdocs-auth.js +1 -1
- package/dist/collection/components/embeds/verdocs-send/verdocs-send.js +3 -0
- package/dist/components/verdocs-auth.js +1 -1
- package/dist/components/verdocs-send2.js +3 -0
- package/dist/custom-elements.json +2022 -0
- package/dist/esm/verdocs-auth.entry.js +1 -1
- package/dist/esm/verdocs-preview_10.entry.js +3 -0
- package/dist/esm-es5/verdocs-auth.entry.js +1 -1
- package/dist/esm-es5/verdocs-preview_10.entry.js +1 -1
- package/dist/verdocs-web-sdk/p-089f5e74.system.entry.js +1 -0
- package/dist/verdocs-web-sdk/p-12a60f9b.system.entry.js +1 -0
- package/dist/verdocs-web-sdk/p-34325ad6.system.js +1 -1
- package/dist/verdocs-web-sdk/p-62af2a52.entry.js +1 -0
- package/dist/verdocs-web-sdk/p-fdd7fa4b.entry.js +1 -0
- package/dist/verdocs-web-sdk/verdocs-web-sdk.esm.js +1 -1
- package/package.json +1 -1
- package/dist/verdocs-web-sdk/p-1dc77449.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-5a1c0ca0.system.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-826aa2cd.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-e3a7db09.system.entry.js +0 -1
@@ -95,7 +95,7 @@ const VerdocsAuth = class {
|
|
95
95
|
this.submitting = false;
|
96
96
|
(_a = this.authenticated) === null || _a === void 0 ? void 0 : _a.emit({ authenticated: false, profile: null, session: null });
|
97
97
|
(_b = this.sdkError) === null || _b === void 0 ? void 0 : _b.emit(new SDKError(e.message, (_c = e.response) === null || _c === void 0 ? void 0 : _c.status, (_d = e.response) === null || _d === void 0 ? void 0 : _d.data));
|
98
|
-
VerdocsToast('Signup failed: ' + ((_f = (_e = e.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.
|
98
|
+
VerdocsToast('Signup failed: ' + ((_f = (_e = e.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.error) || 'Unknown Error', { style: 'error' });
|
99
99
|
});
|
100
100
|
}
|
101
101
|
async handleVerification() {
|
@@ -1 +1 @@
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,t,i,r){function n(e){return e instanceof i?e:new i((function(t){t(e)}))}return new(i||(i=Promise))((function(i,s){function o(e){try{l(r.next(e))}catch(e){s(e)}}function a(e){try{l(r["throw"](e))}catch(e){s(e)}}function l(e){e.done?i(e.value):n(e.value).then(o,a)}l((r=r.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var i={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,n,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(e){return function(t){return l([e,t])}}function l(a){if(r)throw new TypeError("Generator is already executing.");while(o&&(o=0,a[0]&&(i=0)),i)try{if(r=1,n&&(s=a[0]&2?n["return"]:a[0]?n["throw"]||((s=n["return"])&&s.call(n),0):n.next)&&!(s=s.call(n,a[1])).done)return s;if(n=0,s)a=[a[0]&2,s.value];switch(a[0]){case 0:case 1:s=a;break;case 4:i.label++;return{value:a[1],done:false};case 5:i.label++;n=a[1];a=[0];continue;case 7:a=i.ops.pop();i.trys.pop();continue;default:if(!(s=i.trys,s=s.length>0&&s[s.length-1])&&(a[0]===6||a[0]===2)){i=0;continue}if(a[0]===3&&(!s||a[1]>s[0]&&a[1]<s[3])){i.label=a[1];break}if(a[0]===6&&i.label<s[1]){i.label=s[1];s=a;break}if(s&&i.label<s[2]){i.label=s[2];i.ops.push(a);break}if(s[2])i.ops.pop();i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e];n=0}finally{r=s=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};import{r as registerInstance,c as createEvent,h}from"./index-d3ac9650.js";import{VerdocsEndpoint,createProfile,verifyEmail,authenticate,getMyUser,resendVerification,resetPassword}from"@verdocs/js-sdk";import{V as VerdocsToast}from"./Toast-c4843828.js";import{S as SDKError}from"./errors-887f1e88.js";var verdocsAuthCss='@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}verdocs-auth{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:center;justify-content:center}verdocs-auth .form{width:320px;display:-ms-flexbox;display:flex;padding:20px;max-width:90%;-ms-flex-align:center;align-items:center;-ms-flex-direction:column;flex-direction:column;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-flex-pack:center;justify-content:center;background:#ffffff}verdocs-auth .logo{width:128px;max-width:100%;margin:20px 0 30px}verdocs-auth h3{text-align:center;font-weight:400;font-size:16px;line-height:1.75;margin:0}verdocs-auth h4{text-align:center;font-weight:400;font-size:14px;line-height:1.43;margin:0}verdocs-auth h4 verdocs-button button.normal .button-label{padding:0}verdocs-auth h6{text-align:center;font-weight:500;font-size:16px;line-height:1.75;margin:0 0 20px 0}verdocs-auth em{font-size:14px;margin:15px 0}verdocs-auth .buttons{gap:20px;margin:20px 0 0 0;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:center;justify-content:center}verdocs-auth .status-result{display:none}verdocs-auth .status-result.debug{white-space:pre-wrap;font-size:14px;background:#fff;padding:10px;display:block;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:center;justify-content:center}verdocs-auth form{width:100%}verdocs-auth verdocs-text-input{margin-bottom:10px}verdocs-auth .account-option{gap:8px;margin:20px 0 8px 0;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row}verdocs-auth p{margin:0 0 1em 0}verdocs-auth p+p{margin-top:0}verdocs-auth verdocs-help-icon{margin-top:18px;display:-ms-flexbox;display:flex;width:32px;height:32px;-ms-flex:0 0 32px;flex:0 0 32px}';var VerdocsAuthStyle0=verdocsAuthCss;var VerdocsAuth=function(){function e(e){registerInstance(this,e);this.authenticated=createEvent(this,"authenticated",7);this.sdkError=createEvent(this,"sdkError",7);this.resendDisabledTimer=null;this.tempAuthEndpoint=new VerdocsEndpoint({baseURL:VerdocsEndpoint.getDefault().getBaseURL(),persist:false});this.endpoint=VerdocsEndpoint.getDefault();this.visible=true;this.logo="https://app.verdocs.com/assets/blue-logo.svg";this.displayMode="login";this.org_name="";this.first_name="";this.last_name="";this.email="";this.verificationCode="";this.password="";this.confirmpass="";this.submitting=false;this.resendDisabled=false;this.session=null;this.profile=null}e.prototype.componentWillLoad=function(){var e=this;this.endpoint.loadSession();VerdocsEndpoint.getDefault().onSessionChanged((function(t,i,r){var n,s;e.session=i;e.profile=r;if(i){(n=e.authenticated)===null||n===void 0?void 0:n.emit({authenticated:true,session:i,profile:r})}else{(s=e.authenticated)===null||s===void 0?void 0:s.emit({authenticated:false,session:i,profile:r})}}))};e.prototype.isPasswordComplex=function(e){var t=function(e){return/[A-Z]/.test(e)};var i=function(e){return/[a-z]/.test(e)};var r=function(e){return/[`!@#$%^&*()_\-+=\[\]{};':"\\|,.<>\/?~ ]/.test(e)};var n=0,s=0,o=0;for(var a=0;a<e.length;a++){var l=e.charAt(a);if(t(l))n++;else if(i(l))s++;else if(r(l))o++}return e.length>=8&&s>0&&n>0&&o>0};e.prototype.handleSignup=function(){var e=this;if(!this.isPasswordComplex(this.password)){VerdocsToast("Password must be at least 8 characters long and contain at least one uppercase, one lowercase, and one special character.",{style:"error"});return}if(this.password!==this.confirmpass){VerdocsToast("Passwords do not match.",{style:"error"});return}this.submitting=true;this.tempAuthEndpoint.clearSession();createProfile(this.tempAuthEndpoint,{email:this.email,password:this.password,first_name:this.first_name,last_name:this.last_name,org_name:this.org_name}).then((function(t){console.log("[AUTH] Profile creation result",t);e.tempAuthEndpoint.setToken(t.access_token);e.clearForms();e.displayMode="verify"})).catch((function(t){var i,r,n,s,o,a;console.log("[AUTH] Signup error",t.response);e.submitting=false;(i=e.authenticated)===null||i===void 0?void 0:i.emit({authenticated:false,profile:null,session:null});(r=e.sdkError)===null||r===void 0?void 0:r.emit(new SDKError(t.message,(n=t.response)===null||n===void 0?void 0:n.status,(s=t.response)===null||s===void 0?void 0:s.data));VerdocsToast("Signup failed: "+((a=(o=t.response)===null||o===void 0?void 0:o.data)===null||a===void 0?void 0:a.message)||"Unknown Error",{style:"error"})}))};e.prototype.handleVerification=function(){return __awaiter(this,void 0,void 0,(function(){var e,t;return __generator(this,(function(i){switch(i.label){case 0:this.submitting=true;i.label=1;case 1:i.trys.push([1,3,,4]);this.submitting=false;return[4,verifyEmail(this.tempAuthEndpoint,{email:this.email,token:this.verificationCode})];case 2:e=i.sent();VerdocsToast("Thank you for verifying your email address.",{style:"success"});this.completeLogin(e);return[3,4];case 3:t=i.sent();this.submitting=false;console.log("Verification error",t);VerdocsToast("Verification error, please check the code and try again.");return[3,4];case 4:return[2]}}))}))};e.prototype.completeLogin=function(e){this.clearForms();this.tempAuthEndpoint.clearSession();this.endpoint.setToken(e.access_token)};e.prototype.loginAndCheckVerification=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,i,r;return __generator(this,(function(n){switch(n.label){case 0:if(this.submitting){return[2]}this.submitting=true;this.tempAuthEndpoint.clearSession();n.label=1;case 1:n.trys.push([1,4,,5]);this.submitting=false;return[4,authenticate(this.tempAuthEndpoint,{username:this.email,password:this.password,grant_type:"password"})];case 2:t=n.sent();console.log("[AUTH] Authenticated, checking email verification");this.tempAuthEndpoint.setToken(t.access_token);return[4,getMyUser(this.tempAuthEndpoint)];case 3:i=n.sent();console.log("Got user",i);if(!i.email_verified){console.log("[AUTH] Logged in, pending email address verification");this.displayMode="verify"}else{console.log("[AUTH] Email address is verified, completing login");this.completeLogin(t)}return[3,5];case 4:r=n.sent();this.submitting=false;console.log("[AUTH] Auth failure",((e=r.response)===null||e===void 0?void 0:e.data)||r);VerdocsToast("Login failed. Please check your credentials and try again.",{style:"error"});return[3,5];case 5:return[2]}}))}))};e.prototype.clearForms=function(){this.submitting=false;this.resendDisabled=false;this.email="";this.password="";this.confirmpass="";this.verificationCode="";this.first_name="";this.last_name="";this.org_name=""};e.prototype.handleLogout=function(){console.log("logging out");this.endpoint.clearSession();this.tempAuthEndpoint.clearSession();this.clearForms();this.displayMode="login"};e.prototype.handleResend=function(){var e=this;this.resendDisabled=true;this.resendDisabledTimer=setTimeout((function(){e.resendDisabled=false;e.resendDisabledTimer=null}),3e4);resendVerification(this.tempAuthEndpoint).then((function(e){console.log("[AUTH] Verification request resent",e);VerdocsToast("Please check your email for a verification code.",{style:"info"})})).catch((function(e){console.log("[AUTH] Unable to resend verification",e);VerdocsToast("Unable to resend code. Please try again later.",{style:"error"})}))};e.prototype.handleReset=function(){return __awaiter(this,void 0,void 0,(function(){var e,t;return __generator(this,(function(i){switch(i.label){case 0:this.submitting=true;i.label=1;case 1:i.trys.push([1,3,,4]);return[4,resetPassword(this.endpoint,{email:this.email})];case 2:e=i.sent();console.log("[AUTH] Reset sent",e);this.submitting=false;this.displayMode="login";VerdocsToast("If your email address is registered, you will receive instructions on resetting your password shortly.",{style:"info"});return[3,4];case 3:t=i.sent();console.log("[AUTH] Unable to reset password",t);this.submitting=false;VerdocsToast("Unable to reset password. Please check your email address and try again.",{style:"error"});return[3,4];case 4:return[2]}}))}))};e.prototype.render=function(){var e=this;if(!this.visible){return h("div",{style:{display:"none"}},"Authenticated")}if(this.session){return h("verdocs-button",{label:"Sign Out",disabled:this.submitting,onClick:function(){return e.handleLogout()},style:{display:"flex",justifyContent:"center",margin:"30px auto 0"}})}if(this.displayMode==="signup"){var t=this.submitting||!this.first_name||!this.last_name||!this.email||!this.password||!this.confirmpass||!this.org_name;return h("div",{class:"form"},h("a",{href:"https://verdocs.com/en/"},h("img",{src:this.logo,alt:"Verdocs Logo",class:"logo"})),h("h3",null,"Sign up for a free account"),h("h5",null,"Already have an account?",h("verdocs-button",{label:"Log In",variant:"text",onClick:function(){return e.displayMode="login"},disabled:this.submitting})),h("form",{onSubmit:function(){return e.handleSignup()}},h("div",{style:{display:"flex",flexDirection:"row",columnGap:"20px"}},h("verdocs-text-input",{label:"First Name",autocomplete:"first",required:true,value:this.first_name,onInput:function(t){return e.first_name=t.target.value},disabled:this.submitting}),h("verdocs-text-input",{label:"Last Name",autocomplete:"last",required:true,value:this.last_name,onInput:function(t){return e.last_name=t.target.value},disabled:this.submitting})),h("verdocs-text-input",{label:"Email Address",autocomplete:"email",required:true,value:this.email,onInput:function(t){return e.email=t.target.value},disabled:this.submitting}),h("verdocs-text-input",{label:"Password",type:"password",required:true,autocomplete:"new-password",value:this.password,onInput:function(t){return e.password=t.target.value},disabled:this.submitting}),h("verdocs-text-input",{label:"Confirm Password",type:"password",required:true,autocomplete:"off",value:this.confirmpass,onInput:function(t){return e.confirmpass=t.target.value},disabled:this.submitting}),h("verdocs-text-input",{label:"Organization Name",autocomplete:"org",required:true,value:this.org_name,onInput:function(t){return e.org_name=t.target.value},disabled:this.submitting,style:{flex:"1"}}),h("div",{style:{marginTop:"30px"}}),h("verdocs-button",{label:"Next",disabled:t,onClick:t?function(){}:function(){return e.handleSignup()},style:{display:"flex",justifyContent:"center",margin:"30px auto 0"}})))}if(this.displayMode==="verify"){return h("div",{class:"form"},h("form",{onSubmit:function(){return e.handleVerification()}},h("p",null,"Please check your e-mail inbox for a verification code and enter it below."),h("verdocs-text-input",{label:"Verification Code",required:true,value:this.verificationCode,onInput:function(t){return e.verificationCode=t.target.value},disabled:this.submitting}),h("div",{class:"buttons"},h("verdocs-button",{label:"Sign Out",variant:"outline",disabled:this.submitting,onClick:function(){return e.handleLogout()}}),h("verdocs-button",{label:"Verify",disabled:this.submitting||!this.verificationCode||this.verificationCode.length!==6,onClick:function(){return e.handleVerification()}})),h("div",{class:"buttons"},h("verdocs-button",{variant:"text",label:"Resend Code",disabled:this.resendDisabled||this.submitting,onClick:function(){return e.handleResend()}}))))}if(this.displayMode==="forgot"){return h("div",{class:"form"},h("a",{href:"https://verdocs.com/en/"},h("img",{src:this.logo,alt:"Verdocs Logo",class:"logo"})),h("h3",null,"Forgot your password?"),h("p",null,"Enter your e-mail address below, and reset instructions will be sent to your Inbox. Please allow up to 15 minutes to arrive. Check your spam folder if you do not receive the message."),h("form",{onSubmit:function(){return e.handleSignup()}},h("verdocs-text-input",{label:"Email Address",autocomplete:"email",required:true,value:this.email,onInput:function(t){return e.email=t.target.value},disabled:this.submitting}),h("div",{style:{marginTop:"30px"}}),h("div",{class:"buttons"},h("verdocs-button",{label:"Cancel",variant:"outline",disabled:this.submitting,onClick:function(){return e.displayMode="login"}}),h("verdocs-button",{label:"Reset",disabled:this.submitting,onClick:function(){return e.handleReset()}}))))}return h("div",{class:"form"},h("a",{href:"https://verdocs.com/en/"},h("img",{src:this.logo,alt:"Verdocs Logo",class:"logo"})),h("h3",null,"Log in to your account"),h("h4",null,"Don't have an account?",h("verdocs-button",{label:"Sign Up",variant:"text",onClick:function(){return e.displayMode="signup"},disabled:this.submitting})),h("form",{onSubmit:function(){return e.loginAndCheckVerification()}},h("verdocs-text-input",{label:"Email",autocomplete:"username",value:this.email,onInput:function(t){return e.email=t.target.value},disabled:this.submitting}),h("verdocs-text-input",{label:"Password",type:"password",autocomplete:"current-password",value:this.password,onInput:function(t){return e.password=t.target.value},disabled:this.submitting}),h("verdocs-button",{label:"Forgot Your Password?",variant:"text",onClick:function(){return e.displayMode="forgot"},disabled:this.submitting,style:{display:"flex",justifyContent:"center",margin:"10px auto 20px"}}),h("verdocs-button",{label:"Login",disabled:this.submitting,onClick:function(){return e.loginAndCheckVerification()},style:{display:"flex",justifyContent:"center",margin:"10px auto 0"}})))};return e}();VerdocsAuth.style=VerdocsAuthStyle0;export{VerdocsAuth as verdocs_auth};
|
1
|
+
var __awaiter=this&&this.__awaiter||function(e,t,i,r){function n(e){return e instanceof i?e:new i((function(t){t(e)}))}return new(i||(i=Promise))((function(i,s){function o(e){try{l(r.next(e))}catch(e){s(e)}}function a(e){try{l(r["throw"](e))}catch(e){s(e)}}function l(e){e.done?i(e.value):n(e.value).then(o,a)}l((r=r.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var i={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,n,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(e){return function(t){return l([e,t])}}function l(a){if(r)throw new TypeError("Generator is already executing.");while(o&&(o=0,a[0]&&(i=0)),i)try{if(r=1,n&&(s=a[0]&2?n["return"]:a[0]?n["throw"]||((s=n["return"])&&s.call(n),0):n.next)&&!(s=s.call(n,a[1])).done)return s;if(n=0,s)a=[a[0]&2,s.value];switch(a[0]){case 0:case 1:s=a;break;case 4:i.label++;return{value:a[1],done:false};case 5:i.label++;n=a[1];a=[0];continue;case 7:a=i.ops.pop();i.trys.pop();continue;default:if(!(s=i.trys,s=s.length>0&&s[s.length-1])&&(a[0]===6||a[0]===2)){i=0;continue}if(a[0]===3&&(!s||a[1]>s[0]&&a[1]<s[3])){i.label=a[1];break}if(a[0]===6&&i.label<s[1]){i.label=s[1];s=a;break}if(s&&i.label<s[2]){i.label=s[2];i.ops.push(a);break}if(s[2])i.ops.pop();i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e];n=0}finally{r=s=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};import{r as registerInstance,c as createEvent,h}from"./index-d3ac9650.js";import{VerdocsEndpoint,createProfile,verifyEmail,authenticate,getMyUser,resendVerification,resetPassword}from"@verdocs/js-sdk";import{V as VerdocsToast}from"./Toast-c4843828.js";import{S as SDKError}from"./errors-887f1e88.js";var verdocsAuthCss='@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}verdocs-auth{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:center;justify-content:center}verdocs-auth .form{width:320px;display:-ms-flexbox;display:flex;padding:20px;max-width:90%;-ms-flex-align:center;align-items:center;-ms-flex-direction:column;flex-direction:column;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-flex-pack:center;justify-content:center;background:#ffffff}verdocs-auth .logo{width:128px;max-width:100%;margin:20px 0 30px}verdocs-auth h3{text-align:center;font-weight:400;font-size:16px;line-height:1.75;margin:0}verdocs-auth h4{text-align:center;font-weight:400;font-size:14px;line-height:1.43;margin:0}verdocs-auth h4 verdocs-button button.normal .button-label{padding:0}verdocs-auth h6{text-align:center;font-weight:500;font-size:16px;line-height:1.75;margin:0 0 20px 0}verdocs-auth em{font-size:14px;margin:15px 0}verdocs-auth .buttons{gap:20px;margin:20px 0 0 0;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:center;justify-content:center}verdocs-auth .status-result{display:none}verdocs-auth .status-result.debug{white-space:pre-wrap;font-size:14px;background:#fff;padding:10px;display:block;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:center;justify-content:center}verdocs-auth form{width:100%}verdocs-auth verdocs-text-input{margin-bottom:10px}verdocs-auth .account-option{gap:8px;margin:20px 0 8px 0;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row}verdocs-auth p{margin:0 0 1em 0}verdocs-auth p+p{margin-top:0}verdocs-auth verdocs-help-icon{margin-top:18px;display:-ms-flexbox;display:flex;width:32px;height:32px;-ms-flex:0 0 32px;flex:0 0 32px}';var VerdocsAuthStyle0=verdocsAuthCss;var VerdocsAuth=function(){function e(e){registerInstance(this,e);this.authenticated=createEvent(this,"authenticated",7);this.sdkError=createEvent(this,"sdkError",7);this.resendDisabledTimer=null;this.tempAuthEndpoint=new VerdocsEndpoint({baseURL:VerdocsEndpoint.getDefault().getBaseURL(),persist:false});this.endpoint=VerdocsEndpoint.getDefault();this.visible=true;this.logo="https://app.verdocs.com/assets/blue-logo.svg";this.displayMode="login";this.org_name="";this.first_name="";this.last_name="";this.email="";this.verificationCode="";this.password="";this.confirmpass="";this.submitting=false;this.resendDisabled=false;this.session=null;this.profile=null}e.prototype.componentWillLoad=function(){var e=this;this.endpoint.loadSession();VerdocsEndpoint.getDefault().onSessionChanged((function(t,i,r){var n,s;e.session=i;e.profile=r;if(i){(n=e.authenticated)===null||n===void 0?void 0:n.emit({authenticated:true,session:i,profile:r})}else{(s=e.authenticated)===null||s===void 0?void 0:s.emit({authenticated:false,session:i,profile:r})}}))};e.prototype.isPasswordComplex=function(e){var t=function(e){return/[A-Z]/.test(e)};var i=function(e){return/[a-z]/.test(e)};var r=function(e){return/[`!@#$%^&*()_\-+=\[\]{};':"\\|,.<>\/?~ ]/.test(e)};var n=0,s=0,o=0;for(var a=0;a<e.length;a++){var l=e.charAt(a);if(t(l))n++;else if(i(l))s++;else if(r(l))o++}return e.length>=8&&s>0&&n>0&&o>0};e.prototype.handleSignup=function(){var e=this;if(!this.isPasswordComplex(this.password)){VerdocsToast("Password must be at least 8 characters long and contain at least one uppercase, one lowercase, and one special character.",{style:"error"});return}if(this.password!==this.confirmpass){VerdocsToast("Passwords do not match.",{style:"error"});return}this.submitting=true;this.tempAuthEndpoint.clearSession();createProfile(this.tempAuthEndpoint,{email:this.email,password:this.password,first_name:this.first_name,last_name:this.last_name,org_name:this.org_name}).then((function(t){console.log("[AUTH] Profile creation result",t);e.tempAuthEndpoint.setToken(t.access_token);e.clearForms();e.displayMode="verify"})).catch((function(t){var i,r,n,s,o,a;console.log("[AUTH] Signup error",t.response);e.submitting=false;(i=e.authenticated)===null||i===void 0?void 0:i.emit({authenticated:false,profile:null,session:null});(r=e.sdkError)===null||r===void 0?void 0:r.emit(new SDKError(t.message,(n=t.response)===null||n===void 0?void 0:n.status,(s=t.response)===null||s===void 0?void 0:s.data));VerdocsToast("Signup failed: "+((a=(o=t.response)===null||o===void 0?void 0:o.data)===null||a===void 0?void 0:a.error)||"Unknown Error",{style:"error"})}))};e.prototype.handleVerification=function(){return __awaiter(this,void 0,void 0,(function(){var e,t;return __generator(this,(function(i){switch(i.label){case 0:this.submitting=true;i.label=1;case 1:i.trys.push([1,3,,4]);this.submitting=false;return[4,verifyEmail(this.tempAuthEndpoint,{email:this.email,token:this.verificationCode})];case 2:e=i.sent();VerdocsToast("Thank you for verifying your email address.",{style:"success"});this.completeLogin(e);return[3,4];case 3:t=i.sent();this.submitting=false;console.log("Verification error",t);VerdocsToast("Verification error, please check the code and try again.");return[3,4];case 4:return[2]}}))}))};e.prototype.completeLogin=function(e){this.clearForms();this.tempAuthEndpoint.clearSession();this.endpoint.setToken(e.access_token)};e.prototype.loginAndCheckVerification=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,i,r;return __generator(this,(function(n){switch(n.label){case 0:if(this.submitting){return[2]}this.submitting=true;this.tempAuthEndpoint.clearSession();n.label=1;case 1:n.trys.push([1,4,,5]);this.submitting=false;return[4,authenticate(this.tempAuthEndpoint,{username:this.email,password:this.password,grant_type:"password"})];case 2:t=n.sent();console.log("[AUTH] Authenticated, checking email verification");this.tempAuthEndpoint.setToken(t.access_token);return[4,getMyUser(this.tempAuthEndpoint)];case 3:i=n.sent();console.log("Got user",i);if(!i.email_verified){console.log("[AUTH] Logged in, pending email address verification");this.displayMode="verify"}else{console.log("[AUTH] Email address is verified, completing login");this.completeLogin(t)}return[3,5];case 4:r=n.sent();this.submitting=false;console.log("[AUTH] Auth failure",((e=r.response)===null||e===void 0?void 0:e.data)||r);VerdocsToast("Login failed. Please check your credentials and try again.",{style:"error"});return[3,5];case 5:return[2]}}))}))};e.prototype.clearForms=function(){this.submitting=false;this.resendDisabled=false;this.email="";this.password="";this.confirmpass="";this.verificationCode="";this.first_name="";this.last_name="";this.org_name=""};e.prototype.handleLogout=function(){console.log("logging out");this.endpoint.clearSession();this.tempAuthEndpoint.clearSession();this.clearForms();this.displayMode="login"};e.prototype.handleResend=function(){var e=this;this.resendDisabled=true;this.resendDisabledTimer=setTimeout((function(){e.resendDisabled=false;e.resendDisabledTimer=null}),3e4);resendVerification(this.tempAuthEndpoint).then((function(e){console.log("[AUTH] Verification request resent",e);VerdocsToast("Please check your email for a verification code.",{style:"info"})})).catch((function(e){console.log("[AUTH] Unable to resend verification",e);VerdocsToast("Unable to resend code. Please try again later.",{style:"error"})}))};e.prototype.handleReset=function(){return __awaiter(this,void 0,void 0,(function(){var e,t;return __generator(this,(function(i){switch(i.label){case 0:this.submitting=true;i.label=1;case 1:i.trys.push([1,3,,4]);return[4,resetPassword(this.endpoint,{email:this.email})];case 2:e=i.sent();console.log("[AUTH] Reset sent",e);this.submitting=false;this.displayMode="login";VerdocsToast("If your email address is registered, you will receive instructions on resetting your password shortly.",{style:"info"});return[3,4];case 3:t=i.sent();console.log("[AUTH] Unable to reset password",t);this.submitting=false;VerdocsToast("Unable to reset password. Please check your email address and try again.",{style:"error"});return[3,4];case 4:return[2]}}))}))};e.prototype.render=function(){var e=this;if(!this.visible){return h("div",{style:{display:"none"}},"Authenticated")}if(this.session){return h("verdocs-button",{label:"Sign Out",disabled:this.submitting,onClick:function(){return e.handleLogout()},style:{display:"flex",justifyContent:"center",margin:"30px auto 0"}})}if(this.displayMode==="signup"){var t=this.submitting||!this.first_name||!this.last_name||!this.email||!this.password||!this.confirmpass||!this.org_name;return h("div",{class:"form"},h("a",{href:"https://verdocs.com/en/"},h("img",{src:this.logo,alt:"Verdocs Logo",class:"logo"})),h("h3",null,"Sign up for a free account"),h("h5",null,"Already have an account?",h("verdocs-button",{label:"Log In",variant:"text",onClick:function(){return e.displayMode="login"},disabled:this.submitting})),h("form",{onSubmit:function(){return e.handleSignup()}},h("div",{style:{display:"flex",flexDirection:"row",columnGap:"20px"}},h("verdocs-text-input",{label:"First Name",autocomplete:"first",required:true,value:this.first_name,onInput:function(t){return e.first_name=t.target.value},disabled:this.submitting}),h("verdocs-text-input",{label:"Last Name",autocomplete:"last",required:true,value:this.last_name,onInput:function(t){return e.last_name=t.target.value},disabled:this.submitting})),h("verdocs-text-input",{label:"Email Address",autocomplete:"email",required:true,value:this.email,onInput:function(t){return e.email=t.target.value},disabled:this.submitting}),h("verdocs-text-input",{label:"Password",type:"password",required:true,autocomplete:"new-password",value:this.password,onInput:function(t){return e.password=t.target.value},disabled:this.submitting}),h("verdocs-text-input",{label:"Confirm Password",type:"password",required:true,autocomplete:"off",value:this.confirmpass,onInput:function(t){return e.confirmpass=t.target.value},disabled:this.submitting}),h("verdocs-text-input",{label:"Organization Name",autocomplete:"org",required:true,value:this.org_name,onInput:function(t){return e.org_name=t.target.value},disabled:this.submitting,style:{flex:"1"}}),h("div",{style:{marginTop:"30px"}}),h("verdocs-button",{label:"Next",disabled:t,onClick:t?function(){}:function(){return e.handleSignup()},style:{display:"flex",justifyContent:"center",margin:"30px auto 0"}})))}if(this.displayMode==="verify"){return h("div",{class:"form"},h("form",{onSubmit:function(){return e.handleVerification()}},h("p",null,"Please check your e-mail inbox for a verification code and enter it below."),h("verdocs-text-input",{label:"Verification Code",required:true,value:this.verificationCode,onInput:function(t){return e.verificationCode=t.target.value},disabled:this.submitting}),h("div",{class:"buttons"},h("verdocs-button",{label:"Sign Out",variant:"outline",disabled:this.submitting,onClick:function(){return e.handleLogout()}}),h("verdocs-button",{label:"Verify",disabled:this.submitting||!this.verificationCode||this.verificationCode.length!==6,onClick:function(){return e.handleVerification()}})),h("div",{class:"buttons"},h("verdocs-button",{variant:"text",label:"Resend Code",disabled:this.resendDisabled||this.submitting,onClick:function(){return e.handleResend()}}))))}if(this.displayMode==="forgot"){return h("div",{class:"form"},h("a",{href:"https://verdocs.com/en/"},h("img",{src:this.logo,alt:"Verdocs Logo",class:"logo"})),h("h3",null,"Forgot your password?"),h("p",null,"Enter your e-mail address below, and reset instructions will be sent to your Inbox. Please allow up to 15 minutes to arrive. Check your spam folder if you do not receive the message."),h("form",{onSubmit:function(){return e.handleSignup()}},h("verdocs-text-input",{label:"Email Address",autocomplete:"email",required:true,value:this.email,onInput:function(t){return e.email=t.target.value},disabled:this.submitting}),h("div",{style:{marginTop:"30px"}}),h("div",{class:"buttons"},h("verdocs-button",{label:"Cancel",variant:"outline",disabled:this.submitting,onClick:function(){return e.displayMode="login"}}),h("verdocs-button",{label:"Reset",disabled:this.submitting,onClick:function(){return e.handleReset()}}))))}return h("div",{class:"form"},h("a",{href:"https://verdocs.com/en/"},h("img",{src:this.logo,alt:"Verdocs Logo",class:"logo"})),h("h3",null,"Log in to your account"),h("h4",null,"Don't have an account?",h("verdocs-button",{label:"Sign Up",variant:"text",onClick:function(){return e.displayMode="signup"},disabled:this.submitting})),h("form",{onSubmit:function(){return e.loginAndCheckVerification()}},h("verdocs-text-input",{label:"Email",autocomplete:"username",value:this.email,onInput:function(t){return e.email=t.target.value},disabled:this.submitting}),h("verdocs-text-input",{label:"Password",type:"password",autocomplete:"current-password",value:this.password,onInput:function(t){return e.password=t.target.value},disabled:this.submitting}),h("verdocs-button",{label:"Forgot Your Password?",variant:"text",onClick:function(){return e.displayMode="forgot"},disabled:this.submitting,style:{display:"flex",justifyContent:"center",margin:"10px auto 20px"}}),h("verdocs-button",{label:"Login",disabled:this.submitting,onClick:function(){return e.loginAndCheckVerification()},style:{display:"flex",justifyContent:"center",margin:"10px auto 0"}})))};return e}();VerdocsAuth.style=VerdocsAuthStyle0;export{VerdocsAuth as verdocs_auth};
|