@verdocs/web-sdk 2.3.62 → 2.3.63

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.
@@ -1 +0,0 @@
1
- import{r as e,c as i,h as t,H as s,F as o}from"./p-14b44491.js";import{e as n,a,u as l,f as r,h as d,i as h}from"./p-dc2ad047.js";import{R as c}from"./p-05788c2b.js";import{e as p,a as u,b as v}from"./p-3cd894ff.js";import{V as g}from"./p-035f6b38.js";import{i as m,a as f}from"./p-e8ce0b6f.js";import{f as x,i as b}from"./p-5e808a0b.js";import{a as w,u as y,r as k,b as S}from"./p-f0dd9355.js";import{a as N}from"./p-6eb2ce21.js";import{V as I}from"./p-ed416acf.js";import{S as G}from"./p-7a1b2643.js";import"./p-eab67c09.js";import"./p-aa124212.js";import"./p-839f6f0d.js";import"./p-c220af42.js";import"./p-7648c449.js";const j=[{id:"later",label:"Finish Later"},{id:"decline",label:"Decline to Sign"},{id:"print",label:"Print Without Signing"},{id:"download",label:"Download"}],F=[{id:"print",label:"Print"},{id:"download",label:"Download"}],R=class{constructor(t){e(this,t),this.sdkError=i(this,"sdkError",7),this.envelopeLoaded=i(this,"envelopeLoaded",7),this.envelopeUpdated=i(this,"envelopeUpdated",7),this.endpoint=null,this.recipientIndex=-1,this.envelopeId=null,this.roleId=null,this.inviteCode=null,this.headerTargetId=null,this.envelope=null,this.roleNames=[],this.sortedRecipients=[],this.recipient=null,this.signerToken=null,this.hasSignature=!1,this.nextButtonLabel="Start",this.nextSubmits=!1,this.errorMessage="",this.focusedField="",this.submitting=!1,this.isDone=!1,this.showDone=!1,this.showLoadError=!1,this.finishLater=!1,this.showFinishLater=!1,this.agreed=!1,this.documentsSingularPlural="document"}componentWillLoad(){this.endpoint=new g({sessionType:"signing"})}async componentWillRender(){var e,i,t,s,o,l,r;if(this.envelopeId)if(this.roleId)if(this.inviteCode)try{console.log(`[SIGN] Processing invite code for ${this.envelopeId} / ${this.roleId}`);const{session:e,recipient:i,signerToken:t}=await n(this.endpoint,{envelopeId:this.envelopeId,roleId:this.roleId,inviteCode:this.inviteCode});console.log(`[SIGN] Loaded signing session ${e.email} / ${e.profile_id}`),this.recipient=i,console.log("[SIGN] We are recipient",this.recipient),this.signerToken=t,this.endpoint.setToken(t),this.agreed&&(this.nextButtonLabel="Next"),this.envelope=await a(this.endpoint,this.envelopeId);const o=N(this.envelope);console.log("made fs",o),this.sortedRecipients=[...this.envelope.recipients],this.sortedRecipients.sort(((e,i)=>e.sequence===i.sequence?e.order-i.order:e.sequence-i.sequence)),this.roleNames=this.sortedRecipients.map((e=>e.role_name)),this.envelope.documents.length>0&&(this.documentsSingularPlural="document(s)"),this.recipientIndex=this.roleNames.findIndex((e=>e==this.roleId)),this.recipientIndex>-1?(this.recipient=this.sortedRecipients[this.recipientIndex],this.agreed=this.recipient.agreed,console.log("[SIGN] Found our recipient in the envelope",this.recipientIndex,this.recipient)):console.log("[SIGN] Could not find our recipient record",this.roleId,this.sortedRecipients),this.isDone=["submitted","canceled","declined"].includes(this.recipient.status),this.checkRecipientFields(),null===(s=this.envelopeLoaded)||void 0===s||s.emit({endpoint:this.endpoint,envelope:this.envelope})}catch(e){console.log("Error with signing session",e),null===(o=this.sdkError)||void 0===o||o.emit(new G(e.message,null===(l=e.response)||void 0===l?void 0:l.status,null===(r=e.response)||void 0===r?void 0:r.data)),this.showLoadError=!0}else null===(t=this.sdkError)||void 0===t||t.emit(new G("[SIGN] Missing required inviteCode",500,""));else null===(i=this.sdkError)||void 0===i||i.emit(new G("[SIGN] Missing required roleId",500,""));else null===(e=this.sdkError)||void 0===e||e.emit(new G("[SIGN] Missing required envelopId",500,""))}componentDidRender(){const e=this.headerTargetId?document.getElementById(this.headerTargetId):null,i=document.getElementById("verdocs-sign-header");e&&i&&(console.log("[SIGN] Moving header"),i.remove(),e.append(i))}handleClickAgree(){this.submitting=!0,p(this.endpoint,this.envelopeId,this.roleId,!0).then((()=>{var e;this.nextButtonLabel="Next",this.recipient.agreed=!0,this.submitting=!1,this.agreed=!0,null===(e=this.envelopeUpdated)||void 0===e||e.emit({endpoint:this.endpoint,envelope:this.envelope,event:"agreed"})})).catch((e=>{var i,t,s;console.log("Update failure",e),this.submitting=!1,null===(i=this.sdkError)||void 0===i||i.emit(new G(e.message,null===(t=e.response)||void 0===t?void 0:t.status,null===(s=e.response)||void 0===s?void 0:s.data))}))}async handleOptionSelected(e){var i,t,s,o,n;switch(e.detail.id){case"later":this.finishLater=!0,this.showFinishLater=!0,null===(i=this.envelopeUpdated)||void 0===i||i.emit({endpoint:this.endpoint,envelope:this.envelope,event:"later"});break;case"claim":I("This feature will be available in an upcoming release."),null===(t=this.envelopeUpdated)||void 0===t||t.emit({endpoint:this.endpoint,envelope:this.envelope,event:"claimed"});break;case"decline":{this.submitting=!0;const e=await u(this.endpoint,this.envelopeId,this.roleId);console.log("Decline result",e),null===(s=this.envelopeUpdated)||void 0===s||s.emit({endpoint:this.endpoint,envelope:this.envelope,event:"declined"}),this.submitting=!1,this.isDone=!0}break;case"print":window.print(),null===(o=this.envelopeUpdated)||void 0===o||o.emit({endpoint:this.endpoint,envelope:this.envelope,event:"printed"});break;case"download":w(this.endpoint,this.envelope,this.envelope.envelope_document_id).catch((e=>{console.log("Error downloading PDF",e)})),null===(n=this.envelopeUpdated)||void 0===n||n.emit({endpoint:this.endpoint,envelope:this.envelope,event:"downloaded"})}}updateRecipientFieldValue(e,i){console.log("[SIGN] updateRecipientFieldValue",e),this.getRecipientFields().forEach((t=>{t.name===e&&(t.settings=i.settings,y(t),this.checkRecipientFields())}))}saveFieldChange(e,i){console.log("[SIGN] updateRecipientFieldValue",e),l(this.endpoint,this.envelopeId,e,i).then((i=>this.updateRecipientFieldValue(e,i))).catch((e=>{var i,t,s,o,n,a;401===(null===(i=e.response)||void 0===i?void 0:i.status)&&"jwt expired"===(null===(s=null===(t=e.response)||void 0===t?void 0:t.data)||void 0===s?void 0:s.error)?(console.log("[SIGN] Signing session expired"),this.errorMessage="Signing session expired. Please reload your browser to continue."):console.log("[SIGN] Server error",e),null===(o=this.sdkError)||void 0===o||o.emit(new G(e.message,null===(n=e.response)||void 0===n?void 0:n.status,null===(a=e.response)||void 0===a?void 0:a.data))}))}async handleFieldChange(e,i){const{value:t,checked:s}=i.target;switch(e.type){case"textbox":return this.saveFieldChange(e.name,{prepared:!1,value:t});case"checkbox_group":{const t=e.settings.options.map((e=>({id:e.id,checked:i.target.checked})));return this.saveFieldChange(e.name,{prepared:!1,value:{options:t}})}case"radio_button_group":{const t=e.settings.options.map((e=>({id:e.id,selected:i.target.value===e.id})));return this.saveFieldChange(e.name,{prepared:!1,value:{options:t}})}case"dropdown":return this.saveFieldChange(e.name,{prepared:!1,value:i.detail});case"initial":if(!i.detail)return;const l=await(await fetch(i.detail)).blob();return(o=this.endpoint,"initial",n=l,a=new FormData,a.append("initial",n,"initial"),o.api.post("/initials",a).then((function(e){return e.data}))).then((async i=>{const t=await d(this.endpoint,this.envelopeId,e.name,i.id);this.updateRecipientFieldValue(e.name,t)}));case"signature":if(!i.detail)return;const h=await(await fetch(i.detail)).blob();return function(e,i,t){var s=new FormData;return s.append("signature",t,"signature"),e.api.post("/signatures",s).then((function(e){return e.data}))}(this.endpoint,0,h).then((async i=>{console.log("Signature update result",i);const t=await r(this.endpoint,this.envelopeId,e.name,i.id);this.updateRecipientFieldValue(e.name,t)})).catch((e=>{console.warn("Error updating signature",e)}));case"date":const{date:c,formattedDate:p}=i.detail;return console.log("dt",{date:c,formattedDate:p}),this.saveFieldChange(e.name,{prepared:!1,value:p});case"timestamp":console.log("Updating timestamp",{value:t,ts:i.target.getAttribute("timestamp")});break;default:console.log("Unhandled field update",{value:t,checked:s},e)}var o,n,a}isFieldValid(e){var i,t,s,o,n,a,l;const{required:r=!1}=e,{result:d="",value:h="",base64:c=""}=e.settings||{};switch(e.type){case"textbox":switch((null===(i=e.settings)||void 0===i?void 0:i.validator)||""){case"email":return f(d);case"phone":return m(d);default:return!r||""!==d}case"signature":case"initial":return!r||""!==c;case"timestamp":return!0;case"textarea":case"date":case"attachment":return console.log("Checking date-type field validity",{required:r,result:d,output:!r||""!==d}),!r||""!==d;case"dropdown":return!r||""!==h;case"checkbox_group":const p=((null===(s=null===(t=e.settings)||void 0===t?void 0:t.options)||void 0===s?void 0:s.filter((e=>e.checked)))||[]).length;return!r||p>=((null===(o=e.settings)||void 0===o?void 0:o.minimum_checked)||0)&&p<=((null===(n=e.settings)||void 0===n?void 0:n.maximum_checked)||999);case"radio_button_group":return!r||((null===(l=null===(a=e.settings)||void 0===a?void 0:a.options)||void 0===l?void 0:l.filter((e=>e.selected)))||[]).length>0;default:return!1}}async handleNext(){var e;if(this.nextSubmits){try{this.submitting=!0;const e=await v(this.endpoint,this.envelopeId,this.roleId);console.log("[SIGN] Submitted successfully",e),this.recipient.status="submitted",this.showDone=!0,this.isDone=!0}catch(e){console.log("[SIGN] Error submitting",e)}return void(this.submitting=!1)}const i=this.getRecipientFields().filter((e=>e.required));let t=i.findIndex((e=>e.name===this.focusedField))+1;t>=i.length&&(t=0);let s=i[t],o=0;if(o<i.length&&["signature","initial"].includes(s.type)&&"signed"===(null===(e=s.settings)||void 0===e?void 0:e.result)&&(o++,t++,t>=i.length&&(t=0),s=i[t]),o>=i.length&&(s=null),s){const e=S(s),i=document.getElementById(e);null==i||i.focusField(),this.focusedField=s.name}}getRecipientFields(){return this.envelope.fields.filter((e=>e.recipient_role===this.recipient.role_name))}checkRecipientFields(){const e=this.getRecipientFields().filter((e=>!this.isFieldValid(e)));e.length<1?(this.nextButtonLabel="Finish",this.nextSubmits||(this.nextSubmits=!0)):(console.log("[SIGN] Remaining invalid fields",e),this.nextButtonLabel="Next",this.nextSubmits=!1)}attachFieldAttributes(e,i,t){var s;t.addEventListener("input",(e=>{console.log("[SIGN] onfieldInput",e.detail,e.target.value),e.target.name.includes("checkbox_group")||e.target.name.includes("radio_button_group")?this.handleFieldChange(i,e).finally((()=>this.checkRecipientFields())):this.checkRecipientFields()})),t.addEventListener("attached",(async e=>{console.log("[SIGN] onAttached",e.detail,e.target.value);const t=await h(this.endpoint,this.envelopeId,this.roleId,i.name,e.detail);console.log("upload result",t),this.checkRecipientFields()})),t.addEventListener("removed",(e=>{console.log("[SIGN] onRemoved",e.detail,e.target.value)})),t.addEventListener("focusout",(e=>this.handleFieldChange(i,e).finally((()=>this.checkRecipientFields())))),t.addEventListener("fieldChange",(e=>this.handleFieldChange(i,e).finally((()=>this.checkRecipientFields())))),t.setAttribute("templateid",this.envelope.template_id),t.setAttribute("fieldname",i.name),t.setAttribute("page",e.pageNumber),t.setAttribute("xScale",e.xScale),t.setAttribute("yScale",e.yScale),t.setAttribute("initials",this.recipient?x(this.recipient.full_name):""),t.setAttribute("name",(null===(s=this.recipient)||void 0===s?void 0:s.full_name)||"")}handlePageRendered(e){const i=e.detail;this.getRecipientFields().filter((e=>e.page===i.pageNumber)).filter((e=>e.page===i.pageNumber)).forEach((e=>{const t=k(e,i,{disabled:!1,editable:!1,draggable:!1,done:this.isDone});t&&(Array.isArray(t)?t.map((t=>this.attachFieldAttributes(i,e,t))):this.attachFieldAttributes(i,e,t))})),this.sortedRecipients.filter((e=>e.role_name!==this.recipient.role_name&&(e.status===c.INVITED||e.status===c.OPENED||e.status===c.PENDING))).forEach((()=>{this.getRecipientFields().filter((e=>e.page===i.pageNumber)).forEach((e=>{const t=k(e,i,{disabled:!0,editable:!1,draggable:!1,done:this.isDone});t&&(Array.isArray(t)?t.map((t=>this.attachFieldAttributes(i,e,t))):this.attachFieldAttributes(i,e,t))}))})),this.checkRecipientFields()}render(){return this.envelope?this.isDone?t(s,{class:{agreed:this.agreed}},t("verdocs-view",{endpoint:this.endpoint,envelopeId:this.envelopeId,onSdkError:e=>{var i;return null===(i=this.sdkError)||void 0===i?void 0:i.emit(e.detail)}}),this.errorMessage&&t("verdocs-ok-dialog",{heading:"Network Error",message:this.errorMessage,onNext:()=>this.errorMessage=""}),this.showDone&&t("verdocs-ok-dialog",{heading:"You're Done!",message:`You can access the ${this.documentsSingularPlural} at any time by clicking on the link from the invitation email.<br /><br />After all recipients have completed their actions, you will receive an email with the document and envelope certificate attached.`,onNext:()=>{this.showDone=!1,this.isDone=!0}}),this.submitting&&t("div",{class:"loading-indicator"},t("verdocs-loader",null))):t(s,{class:{agreed:this.agreed}},t("div",{id:"verdocs-sign-header"},t("div",{class:"inner"},t("img",{src:"https://verdocs.com/assets/white-logo.svg",alt:"Verdocs Logo",class:"logo"}),t("div",{class:"title"},this.envelope.name),t("div",{style:{flex:"1"}}),!this.finishLater&&t("verdocs-button",{size:"small",label:this.nextButtonLabel,disabled:!this.agreed,onClick:()=>this.handleNext()}),t("div",{style:{marginLeft:"10px"}}),t("verdocs-dropdown",{options:this.isDone||this.finishLater?F:j,onOptionSelected:e=>this.handleOptionSelected(e)}))),t("div",{class:"document",style:{paddingTop:this.headerTargetId?"70px":"15px"}},(this.envelope.documents||[]).map((e=>{const i=b(1,e.page_numbers);return t(o,null,i.map((i=>t("verdocs-envelope-document-page",{envelopeId:this.envelopeId,documentId:e.id,endpoint:this.endpoint,virtualWidth:612,virtualHeight:792,pageNumber:i,onPageRendered:e=>this.handlePageRendered(e),type:"filled",layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]}))))}))),this.showFinishLater&&t("verdocs-ok-dialog",{heading:"You've saved your document to finish later.",message:`To complete the ${this.documentsSingularPlural}, use the link in the original email notification inviting you to review and finish the document.`,onNext:()=>this.showFinishLater=!1}),this.errorMessage&&t("verdocs-ok-dialog",{heading:"Network Error",message:this.errorMessage,onNext:()=>this.errorMessage=""}),this.showDone&&t("verdocs-ok-dialog",{heading:"You're Done!",message:`You can access the ${this.documentsSingularPlural} at any time by clicking on the link from the invitation email.<br /><br />After all recipients have completed their actions, you will receive an email with the document and envelope certificate attached.`,onNext:()=>{this.showDone=!1,this.isDone=!0}}),this.showLoadError&&t("verdocs-ok-dialog",{heading:"Error Loading Document",message:"Please check with the sender to ensure it has not been canceled, and try again later.",buttonLabel:"Retry",onNext:()=>{this.showLoadError=!1,window.location.reload()}}),this.submitting&&t("div",{class:"loading-indicator"},t("verdocs-loader",null)),!this.agreed&&t("div",{class:"cover"},t("div",{class:"agree"},t("verdocs-checkbox",{name:"agree",label:"By checking this box, you:",onInput:()=>this.handleClickAgree()}),t("ul",null,t("li",null,"Agree to use electronic records and signatures, and confirm you have read the"," ",t("a",{href:"https://verdocs.com/en/electronic-record-signature-disclosure/",target:"_blank"},"Electronic Record and Signatures Disclosure"),"."),t("li",null,"Agree to Verdocs"," ",t("a",{href:"https://verdocs.com/en/eula",target:"_blank"},"End User License Agreement")," ","and confirm you have read Verdocs'"," ",t("a",{href:"https://verdocs.com/en/privacy-policy/",target:"_blank"},"Privacy Policy"),"."))))):t(s,null,t("verdocs-loader",null))}};R.style='verdocs-sign{display:-ms-flexbox;display:flex;overflow:hidden;position:relative;min-height:600px;-ms-flex-direction:column;flex-direction:column;-webkit-box-sizing:border-box;box-sizing:border-box;font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-sign div{display:block;-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-sign input{vertical-align:top}verdocs-sign>.document{-ms-flex:1;flex:1;width:100%;height:100%;-ms-flex-item-align:center;align-self:center;display:-ms-flexbox;display:flex;padding:15px;row-gap:15px;max-width:1200px;min-height:200px;position:relative;overflow-y:scroll;-ms-flex-align:center;align-items:center;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-flex-direction:column;flex-direction:column}verdocs-sign>.document .inner{width:100%;max-width:1028px}verdocs-sign .cover{top:0;left:0;right:0;bottom:0;display:-ms-flexbox;display:flex;z-index:5000;position:absolute;padding-top:100px;-ms-flex-align:center;align-items:center;-ms-flex-direction:column;flex-direction:column;background:rgba(0, 0, 0, 0.5)}verdocs-sign .agree{-ms-flex:0;flex:0;width:600px;display:-ms-flexbox;display:flex;max-width:90%;padding:30px 15px;-ms-flex-direction:column;flex-direction:column;background-color:#ffffff}verdocs-sign .agree .header{-ms-flex:0 0 56px;flex:0 0 56px}verdocs-sign .agree li{margin:0.5em 0}verdocs-sign verdocs-ok-dialog .background-overlay{-ms-flex-align:start;align-items:flex-start;padding-top:100px}verdocs-sign .loading-indicator{top:0;left:0;right:0;bottom:0;display:-ms-flexbox;display:flex;z-index:10000;position:fixed;background-color:rgba(0, 0, 0, 0.7)}@media print{verdocs-sign .header{display:none}}#verdocs-sign-header{color:#fff;width:100%;display:-ms-flexbox;display:flex;z-index:1000;-ms-flex:0 0 56px;flex:0 0 56px;font-size:12px;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-webkit-transition:all 0.25s;transition:all 0.25s;background-color:#33354c;-webkit-box-shadow:0 4px 4px 0 rgba(0, 0, 0, 0.24), 0 0 4px 0 rgba(0, 0, 0, 0.12);box-shadow:0 4px 4px 0 rgba(0, 0, 0, 0.24), 0 0 4px 0 rgba(0, 0, 0, 0.12)}#verdocs-sign-header .inner{width:100%;display:-ms-flexbox;display:flex;margin:0 auto;padding:0 20px;max-width:1200px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row}#verdocs-sign-header .logo{width:80px;display:none;margin:-6px 0 0 0}#verdocs-sign-header .title{font-size:18px;font-weight:500;overflow:hidden;white-space:nowrap;padding:0 10px 0 0;text-overflow:ellipsis}';export{R as verdocs_sign}