@formspree/core
Advanced tools
Comparing version 2.8.2 to 2.8.3
@@ -1,1 +0,1 @@ | ||
var E=Object.defineProperty,Y=Object.defineProperties,k=Object.getOwnPropertyDescriptor,K=Object.getOwnPropertyDescriptors,$=Object.getOwnPropertyNames,O=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var C=(e,t,r)=>t in e?E(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,S=(e,t)=>{for(var r in t||(t={}))P.call(t,r)&&C(e,r,t[r]);if(O)for(var r of O(t))z.call(t,r)&&C(e,r,t[r]);return e},g=(e,t)=>Y(e,K(t));var J=(e,t)=>{for(var r in t)E(e,r,{get:t[r],enumerable:!0})},q=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of $(t))!P.call(e,i)&&i!==r&&E(e,i,{get:()=>t[i],enumerable:!(o=k(t,i))||o.enumerable});return e};var G=e=>q(E({},"__esModule",{value:!0}),e);var R=(e,t,r)=>new Promise((o,i)=>{var s=p=>{try{n(r.next(p))}catch(c){i(c)}},a=p=>{try{n(r.throw(p))}catch(c){i(c)}},n=p=>p.done?o(p.value):Promise.resolve(p.value).then(s,a);n((r=r.apply(e,t)).next())});var Z={};J(Z,{Client:()=>b,createClient:()=>x,getDefaultClient:()=>U,isFieldError:()=>M});module.exports=G(Z);var m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",H=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;function w(e){e=String(e);for(var t,r,o,i,s="",a=0,n=e.length%3;a<e.length;){if((r=e.charCodeAt(a++))>255||(o=e.charCodeAt(a++))>255||(i=e.charCodeAt(a++))>255)throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");t=r<<16|o<<8|i,s+=m.charAt(t>>18&63)+m.charAt(t>>12&63)+m.charAt(t>>6&63)+m.charAt(t&63)}return n?s.slice(0,n-3)+"===".substring(n):s}function F(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!H.test(e))throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");e+="==".slice(2-(e.length&3));for(var t,r="",o,i,s=0;s<e.length;)t=m.indexOf(e.charAt(s++))<<18|m.indexOf(e.charAt(s++))<<12|(o=m.indexOf(e.charAt(s++)))<<6|(i=m.indexOf(e.charAt(s++))),r+=o===64?String.fromCharCode(t>>16&255):i===64?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,t&255);return r}var A="2.8.2";var D=(s=>(s.REQUIRED_FIELD_MISSING="REQUIRED_FIELD_MISSING",s.REQUIRED_FIELD_EMPTY="REQUIRED_FIELD_EMPTY",s.TYPE_EMAIL="TYPE_EMAIL",s.TYPE_NUMERIC="TYPE_NUMERIC",s.TYPE_TEXT="TYPE_TEXT",s))(D||{});function M(e){return e.code in D&&e.field!==void 0}function N(e){return e.errors!==void 0}var j=e=>w(JSON.stringify(e));var L=e=>{let t=`@formspree/core@${A}`;return e?`${e} ${t}`:t},v=()=>1*new Date,h=(e,t,r)=>{e instanceof FormData?e.append(t,r):e=Object.assign(e,{[t]:r})},B=p=>R(void 0,[p],function*({stripePromise:e,response:t,responseData:r,payload:o,data:i,fetchImpl:s,request:a,url:n}){let c=yield e.handleCardAction(r.stripe.paymentIntentClientSecret);if(c.error)return{response:t,body:{errors:[{code:"STRIPE_CLIENT_ERROR",message:"Stripe SCA error",field:"paymentMethod"}]}};{o.paymentMethod.id||h(i,"paymentMethod",o.paymentMethod.id),h(i,"paymentIntent",c.paymentIntent.id),h(i,"resubmitKey",r.resubmitKey);let l=yield s(n,g(S({},a),{body:JSON.stringify({paymentIntent:c.paymentIntent.id,resubmitKey:r.resubmitKey})})),u=yield l.json();return{response:l,body:u}}});function _({body:e,response:t}){return!N(e)&&(e!=null&&e.error)&&(e={errors:[{message:e.error}]}),{body:e,response:t}}var V=()=>navigator.webdriver||!!document.documentElement.getAttribute(F("d2ViZHJpdmVy"))||!!window.callPhantom||!!window._phantom,I=class{constructor(){this.loadedAt=v(),this.webdriver=V()}teardown(){}data(){return{loadedAt:this.loadedAt,webdriver:this.webdriver}}};var b=class{constructor(t={}){this.project=t.project,this.stripePromise=t.stripePromise,typeof window!="undefined"&&this.startBrowserSession()}startBrowserSession(){this.session||(this.session=new I)}teardown(){this.session&&this.session.teardown()}submitForm(i,s){return R(this,arguments,function*(t,r,o={}){let a=o.endpoint||"https://formspree.io",n=o.fetchImpl||fetch,p=this.project?`${a}/p/${this.project}/f/${t}`:`${a}/f/${t}`,c=d=>d instanceof FormData?d:JSON.stringify(d),l={Accept:"application/json","Formspree-Client":L(o.clientName)};this.session&&(l["Formspree-Session-Data"]=j(this.session.data())),r instanceof FormData||(l["Content-Type"]="application/json");let u={method:"POST",mode:"cors",body:c(r),headers:l};if(this.stripePromise&&o.createPaymentMethod){let d=yield o.createPaymentMethod();if(d.error)return{response:null,body:{errors:[{code:"STRIPE_CLIENT_ERROR",message:"Error creating payment method",field:"paymentMethod"}]}};h(r,"paymentMethod",d.paymentMethod.id);let y=yield n(p,g(S({},u),{body:r})),f=yield y.json();return f&&f.stripe&&f.stripe.requiresAction&&f.resubmitKey?yield B({stripePromise:this.stripePromise,responseData:f,response:y,payload:d,data:r,fetchImpl:n,request:u,url:p}):_({response:y,body:f})}else return n(p,u).then(d=>d.json().then(y=>_({body:y,response:d}))).catch()})}},x=e=>new b(e),U=()=>(T||(T=x()),T),T;0&&(module.exports={Client,createClient,getDefaultClient,isFieldError}); | ||
var E=Object.defineProperty,Y=Object.defineProperties,k=Object.getOwnPropertyDescriptor,K=Object.getOwnPropertyDescriptors,$=Object.getOwnPropertyNames,O=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var C=(e,t,r)=>t in e?E(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,S=(e,t)=>{for(var r in t||(t={}))P.call(t,r)&&C(e,r,t[r]);if(O)for(var r of O(t))z.call(t,r)&&C(e,r,t[r]);return e},g=(e,t)=>Y(e,K(t));var J=(e,t)=>{for(var r in t)E(e,r,{get:t[r],enumerable:!0})},q=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of $(t))!P.call(e,i)&&i!==r&&E(e,i,{get:()=>t[i],enumerable:!(o=k(t,i))||o.enumerable});return e};var G=e=>q(E({},"__esModule",{value:!0}),e);var R=(e,t,r)=>new Promise((o,i)=>{var s=p=>{try{n(r.next(p))}catch(c){i(c)}},a=p=>{try{n(r.throw(p))}catch(c){i(c)}},n=p=>p.done?o(p.value):Promise.resolve(p.value).then(s,a);n((r=r.apply(e,t)).next())});var Z={};J(Z,{Client:()=>b,createClient:()=>x,getDefaultClient:()=>U,isFieldError:()=>M});module.exports=G(Z);var m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",H=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;function w(e){e=String(e);for(var t,r,o,i,s="",a=0,n=e.length%3;a<e.length;){if((r=e.charCodeAt(a++))>255||(o=e.charCodeAt(a++))>255||(i=e.charCodeAt(a++))>255)throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");t=r<<16|o<<8|i,s+=m.charAt(t>>18&63)+m.charAt(t>>12&63)+m.charAt(t>>6&63)+m.charAt(t&63)}return n?s.slice(0,n-3)+"===".substring(n):s}function F(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!H.test(e))throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");e+="==".slice(2-(e.length&3));for(var t,r="",o,i,s=0;s<e.length;)t=m.indexOf(e.charAt(s++))<<18|m.indexOf(e.charAt(s++))<<12|(o=m.indexOf(e.charAt(s++)))<<6|(i=m.indexOf(e.charAt(s++))),r+=o===64?String.fromCharCode(t>>16&255):i===64?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,t&255);return r}var A="2.8.3";var D=(s=>(s.REQUIRED_FIELD_MISSING="REQUIRED_FIELD_MISSING",s.REQUIRED_FIELD_EMPTY="REQUIRED_FIELD_EMPTY",s.TYPE_EMAIL="TYPE_EMAIL",s.TYPE_NUMERIC="TYPE_NUMERIC",s.TYPE_TEXT="TYPE_TEXT",s))(D||{});function M(e){return e.code in D&&e.field!==void 0}function N(e){return e.errors!==void 0}var j=e=>w(JSON.stringify(e));var L=e=>{let t=`@formspree/core@${A}`;return e?`${e} ${t}`:t},v=()=>1*new Date,h=(e,t,r)=>{e instanceof FormData?e.append(t,r):e=Object.assign(e,{[t]:r})},B=p=>R(void 0,[p],function*({stripePromise:e,response:t,responseData:r,payload:o,data:i,fetchImpl:s,request:a,url:n}){let c=yield e.handleCardAction(r.stripe.paymentIntentClientSecret);if(c.error)return{response:t,body:{errors:[{code:"STRIPE_CLIENT_ERROR",message:"Stripe SCA error",field:"paymentMethod"}]}};{o.paymentMethod.id||h(i,"paymentMethod",o.paymentMethod.id),h(i,"paymentIntent",c.paymentIntent.id),h(i,"resubmitKey",r.resubmitKey);let l=yield s(n,g(S({},a),{body:JSON.stringify({paymentIntent:c.paymentIntent.id,resubmitKey:r.resubmitKey})})),u=yield l.json();return{response:l,body:u}}});function _({body:e,response:t}){return!N(e)&&(e!=null&&e.error)&&(e={errors:[{message:e.error}]}),{body:e,response:t}}var V=()=>navigator.webdriver||!!document.documentElement.getAttribute(F("d2ViZHJpdmVy"))||!!window.callPhantom||!!window._phantom,I=class{constructor(){this.loadedAt=v(),this.webdriver=V()}teardown(){}data(){return{loadedAt:this.loadedAt,webdriver:this.webdriver}}};var b=class{constructor(t={}){this.project=t.project,this.stripePromise=t.stripePromise,typeof window!="undefined"&&this.startBrowserSession()}startBrowserSession(){this.session||(this.session=new I)}teardown(){this.session&&this.session.teardown()}submitForm(i,s){return R(this,arguments,function*(t,r,o={}){let a=o.endpoint||"https://formspree.io",n=o.fetchImpl||fetch,p=this.project?`${a}/p/${this.project}/f/${t}`:`${a}/f/${t}`,c=d=>d instanceof FormData?d:JSON.stringify(d),l={Accept:"application/json","Formspree-Client":L(o.clientName)};this.session&&(l["Formspree-Session-Data"]=j(this.session.data())),r instanceof FormData||(l["Content-Type"]="application/json");let u={method:"POST",mode:"cors",body:c(r),headers:l};if(this.stripePromise&&o.createPaymentMethod){let d=yield o.createPaymentMethod();if(d.error)return{response:null,body:{errors:[{code:"STRIPE_CLIENT_ERROR",message:"Error creating payment method",field:"paymentMethod"}]}};h(r,"paymentMethod",d.paymentMethod.id);let y=yield n(p,g(S({},u),{body:r})),f=yield y.json();return f&&f.stripe&&f.stripe.requiresAction&&f.resubmitKey?yield B({stripePromise:this.stripePromise,responseData:f,response:y,payload:d,data:r,fetchImpl:n,request:u,url:p}):_({response:y,body:f})}else return n(p,u).then(d=>d.json().then(y=>_({body:y,response:d}))).catch()})}},x=e=>new b(e),U=()=>(T||(T=x()),T),T;0&&(module.exports={Client,createClient,getDefaultClient,isFieldError}); |
{ | ||
"name": "@formspree/core", | ||
"version": "2.8.2", | ||
"version": "2.8.3", | ||
"private": false, | ||
@@ -39,3 +39,2 @@ "description": "The core library for Formspree", | ||
"devDependencies": { | ||
"jest": "^26.4.2", | ||
"np": "^3.0.4", | ||
@@ -42,0 +41,0 @@ "tsup": "^6.2.2" |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
2
2
14913