Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@formspree/core

Package Overview
Dependencies
Maintainers
3
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@formspree/core - npm Package Compare versions

Comparing version 2.8.1 to 2.8.2

8

dist/index.d.ts
import { PaymentMethodResult, Stripe } from '@stripe/stripe-js';
declare type SubmissionData = FormData | any;
type SubmissionData = FormData | any;
interface SubmissionOptions {

@@ -29,4 +29,4 @@ endpoint?: string;

}
declare type FormErrorCode = keyof typeof FormErrorCodeEnum;
declare type FieldErrorCode = keyof typeof FieldErrorCodeEnum;
type FormErrorCode = keyof typeof FormErrorCodeEnum;
type FieldErrorCode = keyof typeof FieldErrorCodeEnum;
interface FormError {

@@ -52,3 +52,3 @@ field?: string;

}
declare type SubmissionBody = SuccessBody | ErrorBody;
type SubmissionBody = SuccessBody | ErrorBody;
interface SubmissionResponse {

@@ -55,0 +55,0 @@ body: SubmissionBody;

@@ -1,1 +0,1 @@

"use strict";var b=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var N=(e,t)=>{for(var r in t)b(e,r,{get:t[r],enumerable:!0})},L=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of j(t))!M.call(e,s)&&s!==r&&b(e,s,{get:()=>t[s],enumerable:!(i=D(t,s))||i.enumerable});return e};var v=e=>L(b({},"__esModule",{value:!0}),e);var Y={};N(Y,{Client:()=>y,createClient:()=>g,getDefaultClient:()=>A,isFieldError:()=>T});module.exports=v(Y);var p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",B=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;function R(e){e=String(e);for(var t,r,i,s,o="",a=0,d=e.length%3;a<e.length;){if((r=e.charCodeAt(a++))>255||(i=e.charCodeAt(a++))>255||(s=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|i<<8|s,o+=p.charAt(t>>18&63)+p.charAt(t>>12&63)+p.charAt(t>>6&63)+p.charAt(t&63)}return d?o.slice(0,d-3)+"===".substring(d):o}function I(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!B.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="",i,s,o=0;o<e.length;)t=p.indexOf(e.charAt(o++))<<18|p.indexOf(e.charAt(o++))<<12|(i=p.indexOf(e.charAt(o++)))<<6|(s=p.indexOf(e.charAt(o++))),r+=i===64?String.fromCharCode(t>>16&255):s===64?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,t&255);return r}var _="2.8.1";var x=(o=>(o.REQUIRED_FIELD_MISSING="REQUIRED_FIELD_MISSING",o.REQUIRED_FIELD_EMPTY="REQUIRED_FIELD_EMPTY",o.TYPE_EMAIL="TYPE_EMAIL",o.TYPE_NUMERIC="TYPE_NUMERIC",o.TYPE_TEXT="TYPE_TEXT",o))(x||{});function T(e){return e.code in x&&e.field!==void 0}function O(e){return e.errors!==void 0}var C=e=>R(JSON.stringify(e));var P=e=>{let t=`@formspree/core@${_}`;return e?`${e} ${t}`:t},w=()=>1*new Date,u=(e,t,r)=>{e instanceof FormData?e.append(t,r):e=Object.assign(e,{[t]:r})},F=async({stripePromise:e,response:t,responseData:r,payload:i,data:s,fetchImpl:o,request:a,url:d})=>{let c=await e.handleCardAction(r.stripe.paymentIntentClientSecret);if(c.error)return{response:t,body:{errors:[{code:"STRIPE_CLIENT_ERROR",message:"Stripe SCA error",field:"paymentMethod"}]}};{i.paymentMethod.id||u(s,"paymentMethod",i.paymentMethod.id),u(s,"paymentIntent",c.paymentIntent.id),u(s,"resubmitKey",r.resubmitKey);let m=await o(d,{...a,body:JSON.stringify({paymentIntent:c.paymentIntent.id,resubmitKey:r.resubmitKey})}),n=await m.json();return{response:m,body:n}}};function E({body:e,response:t}){return!O(e)&&(e==null?void 0:e.error)&&(e={errors:[{message:e.error}]}),{body:e,response:t}}var U=()=>navigator.webdriver||!!document.documentElement.getAttribute(I("d2ViZHJpdmVy"))||!!window.callPhantom||!!window._phantom,h=class{constructor(){this.loadedAt=w(),this.webdriver=U()}teardown(){}data(){return{loadedAt:this.loadedAt,webdriver:this.webdriver}}};var y=class{constructor(t={}){this.project=t.project,this.stripePromise=t.stripePromise,typeof window<"u"&&this.startBrowserSession()}startBrowserSession(){this.session||(this.session=new h)}teardown(){this.session&&this.session.teardown()}async submitForm(t,r,i={}){let s=i.endpoint||"https://formspree.io",o=i.fetchImpl||fetch,a=this.project?`${s}/p/${this.project}/f/${t}`:`${s}/f/${t}`,d=n=>n instanceof FormData?n:JSON.stringify(n),c={Accept:"application/json","Formspree-Client":P(i.clientName)};this.session&&(c["Formspree-Session-Data"]=C(this.session.data())),r instanceof FormData||(c["Content-Type"]="application/json");let m={method:"POST",mode:"cors",body:d(r),headers:c};if(this.stripePromise&&i.createPaymentMethod){let n=await i.createPaymentMethod();if(n.error)return{response:null,body:{errors:[{code:"STRIPE_CLIENT_ERROR",message:"Error creating payment method",field:"paymentMethod"}]}};u(r,"paymentMethod",n.paymentMethod.id);let f=await o(a,{...m,body:r}),l=await f.json();return l&&l.stripe&&l.stripe.requiresAction&&l.resubmitKey?await F({stripePromise:this.stripePromise,responseData:l,response:f,payload:n,data:r,fetchImpl:o,request:m,url:a}):E({response:f,body:l})}else return o(a,m).then(n=>n.json().then(f=>E({body:f,response:n}))).catch()}},g=e=>new y(e),A=()=>(S||(S=g()),S),S;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.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});
{
"name": "@formspree/core",
"version": "2.8.1",
"version": "2.8.2",
"private": false,
"description": "The core library for Formspree",
"private": false,
"homepage": "https://formspree.io",

@@ -21,8 +21,8 @@ "bugs": {

],
"sideEffects": false,
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist/**"
],
"sideEffects": false,
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {

@@ -33,19 +33,5 @@ "build": "tsup src/index.ts --format esm,cjs --dts --minify",

"lint": "eslint src/*.ts*",
"test": "jest"
"test": "jest",
"typecheck": "tsc --noEmit"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{js,ts,css,json,md}": [
"npx prettier --write",
"git add"
],
"package.json": [
"npx sort-package-json",
"git add"
]
},
"dependencies": {

@@ -55,10 +41,5 @@ "@stripe/stripe-js": "^1.35.0"

"devDependencies": {
"husky": "^3.1.0",
"jest": "^26.4.2",
"lint-staged": "^9.5.0",
"np": "^3.0.4",
"prettier": "^1.19.1",
"sort-package-json": "^1.36.0",
"tsup": "^6.2.2",
"typescript": "^4.7.4"
"tsup": "^6.2.2"
},

@@ -65,0 +46,0 @@ "publishConfig": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc