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

@formspree/core

Package Overview
Dependencies
Maintainers
4
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.6.4 to 2.7.0

688

dist/formspree.cjs.js

@@ -7,5 +7,412 @@ 'use strict';

var Promise = _interopDefault(require('promise-polyfill'));
var PromisePolyfill = _interopDefault(require('promise-polyfill'));
var fetchPonyfill = _interopDefault(require('fetch-ponyfill'));
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
enumerableOnly && (symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
})), keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = null != arguments[i] ? arguments[i] : {};
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
_defineProperty(target, key, source[key]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
return target;
}
function _regeneratorRuntime() {
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
_regeneratorRuntime = function () {
return exports;
};
var exports = {},
Op = Object.prototype,
hasOwn = Op.hasOwnProperty,
$Symbol = "function" == typeof Symbol ? Symbol : {},
iteratorSymbol = $Symbol.iterator || "@@iterator",
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
function define(obj, key, value) {
return Object.defineProperty(obj, key, {
value: value,
enumerable: !0,
configurable: !0,
writable: !0
}), obj[key];
}
try {
define({}, "");
} catch (err) {
define = function (obj, key, value) {
return obj[key] = value;
};
}
function wrap(innerFn, outerFn, self, tryLocsList) {
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
generator = Object.create(protoGenerator.prototype),
context = new Context(tryLocsList || []);
return generator._invoke = function (innerFn, self, context) {
var state = "suspendedStart";
return function (method, arg) {
if ("executing" === state) throw new Error("Generator is already running");
if ("completed" === state) {
if ("throw" === method) throw arg;
return doneResult();
}
for (context.method = method, context.arg = arg;;) {
var delegate = context.delegate;
if (delegate) {
var delegateResult = maybeInvokeDelegate(delegate, context);
if (delegateResult) {
if (delegateResult === ContinueSentinel) continue;
return delegateResult;
}
}
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
if ("suspendedStart" === state) throw state = "completed", context.arg;
context.dispatchException(context.arg);
} else "return" === context.method && context.abrupt("return", context.arg);
state = "executing";
var record = tryCatch(innerFn, self, context);
if ("normal" === record.type) {
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
return {
value: record.arg,
done: context.done
};
}
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
}
};
}(innerFn, self, context), generator;
}
function tryCatch(fn, obj, arg) {
try {
return {
type: "normal",
arg: fn.call(obj, arg)
};
} catch (err) {
return {
type: "throw",
arg: err
};
}
}
exports.wrap = wrap;
var ContinueSentinel = {};
function Generator() {}
function GeneratorFunction() {}
function GeneratorFunctionPrototype() {}
var IteratorPrototype = {};
define(IteratorPrototype, iteratorSymbol, function () {
return this;
});
var getProto = Object.getPrototypeOf,
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
function defineIteratorMethods(prototype) {
["next", "throw", "return"].forEach(function (method) {
define(prototype, method, function (arg) {
return this._invoke(method, arg);
});
});
}
function AsyncIterator(generator, PromiseImpl) {
function invoke(method, arg, resolve, reject) {
var record = tryCatch(generator[method], generator, arg);
if ("throw" !== record.type) {
var result = record.arg,
value = result.value;
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
invoke("next", value, resolve, reject);
}, function (err) {
invoke("throw", err, resolve, reject);
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
result.value = unwrapped, resolve(result);
}, function (error) {
return invoke("throw", error, resolve, reject);
});
}
reject(record.arg);
}
var previousPromise;
this._invoke = function (method, arg) {
function callInvokeWithMethodAndArg() {
return new PromiseImpl(function (resolve, reject) {
invoke(method, arg, resolve, reject);
});
}
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
};
}
function maybeInvokeDelegate(delegate, context) {
var method = delegate.iterator[context.method];
if (undefined === method) {
if (context.delegate = null, "throw" === context.method) {
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
}
return ContinueSentinel;
}
var record = tryCatch(method, delegate.iterator, context.arg);
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
var info = record.arg;
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
}
function pushTryEntry(locs) {
var entry = {
tryLoc: locs[0]
};
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
}
function resetTryEntry(entry) {
var record = entry.completion || {};
record.type = "normal", delete record.arg, entry.completion = record;
}
function Context(tryLocsList) {
this.tryEntries = [{
tryLoc: "root"
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
}
function values(iterable) {
if (iterable) {
var iteratorMethod = iterable[iteratorSymbol];
if (iteratorMethod) return iteratorMethod.call(iterable);
if ("function" == typeof iterable.next) return iterable;
if (!isNaN(iterable.length)) {
var i = -1,
next = function next() {
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
return next.value = undefined, next.done = !0, next;
};
return next.next = next;
}
}
return {
next: doneResult
};
}
function doneResult() {
return {
value: undefined,
done: !0
};
}
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
var ctor = "function" == typeof genFun && genFun.constructor;
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
}, exports.mark = function (genFun) {
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
}, exports.awrap = function (arg) {
return {
__await: arg
};
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
return this;
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
void 0 === PromiseImpl && (PromiseImpl = Promise);
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
return result.done ? result.value : iter.next();
});
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
return this;
}), define(Gp, "toString", function () {
return "[object Generator]";
}), exports.keys = function (object) {
var keys = [];
for (var key in object) keys.push(key);
return keys.reverse(), function next() {
for (; keys.length;) {
var key = keys.pop();
if (key in object) return next.value = key, next.done = !1, next;
}
return next.done = !0, next;
};
}, exports.values = values, Context.prototype = {
constructor: Context,
reset: function (skipTempReset) {
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
},
stop: function () {
this.done = !0;
var rootRecord = this.tryEntries[0].completion;
if ("throw" === rootRecord.type) throw rootRecord.arg;
return this.rval;
},
dispatchException: function (exception) {
if (this.done) throw exception;
var context = this;
function handle(loc, caught) {
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
}
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i],
record = entry.completion;
if ("root" === entry.tryLoc) return handle("end");
if (entry.tryLoc <= this.prev) {
var hasCatch = hasOwn.call(entry, "catchLoc"),
hasFinally = hasOwn.call(entry, "finallyLoc");
if (hasCatch && hasFinally) {
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
} else if (hasCatch) {
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
} else {
if (!hasFinally) throw new Error("try statement without catch or finally");
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
}
}
}
},
abrupt: function (type, arg) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
var finallyEntry = entry;
break;
}
}
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
var record = finallyEntry ? finallyEntry.completion : {};
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
},
complete: function (record, afterLoc) {
if ("throw" === record.type) throw record.arg;
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
},
finish: function (finallyLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
}
},
catch: function (tryLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc === tryLoc) {
var record = entry.completion;
if ("throw" === record.type) {
var thrown = record.arg;
resetTryEntry(entry);
}
return thrown;
}
}
throw new Error("illegal catch attempt");
},
delegateYield: function (iterable, resultName, nextLoc) {
return this.delegate = {
iterator: values(iterable),
resultName: resultName,
nextLoc: nextLoc
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
}
}, exports;
}
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
function _classCallCheck(instance, Constructor) {

@@ -30,5 +437,23 @@ if (!(instance instanceof Constructor)) {

if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';

@@ -76,3 +501,3 @@ var b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;

var version = "2.6.4";
var version = "2.7.0";

@@ -84,3 +509,2 @@ /**

*/
var encode64 = function encode64(obj) {

@@ -108,3 +532,80 @@ return btoa(JSON.stringify(obj));

};
var appendExtraData = function appendExtraData(formData, prop, value) {
if (formData instanceof FormData) {
formData.append(prop, value);
} else {
formData = Object.assign(formData, _defineProperty({}, prop, value));
}
};
var handleSCA = /*#__PURE__*/function () {
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
var stripePromise, response, responseData, payload, data, fetchImpl, request, url, stripeResult, resSubmitResponse, resSubmitData;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
stripePromise = _ref.stripePromise, response = _ref.response, responseData = _ref.responseData, payload = _ref.payload, data = _ref.data, fetchImpl = _ref.fetchImpl, request = _ref.request, url = _ref.url;
_context.next = 3;
return stripePromise.handleCardAction(responseData.stripe.paymentIntentClientSecret);
case 3:
stripeResult = _context.sent;
if (!stripeResult.error) {
_context.next = 8;
break;
}
return _context.abrupt("return", {
response: response,
body: {
errors: [{
code: 'STRIPE_CLIENT_ERROR',
message: 'Stripe SCA error',
field: 'paymentMethod'
}]
}
});
case 8:
if (!payload.paymentMethod.id) {
appendExtraData(data, 'paymentMethod', payload.paymentMethod.id);
}
appendExtraData(data, 'paymentIntent', stripeResult.paymentIntent.id);
appendExtraData(data, 'resubmitKey', responseData.resubmitKey); // Resubmit the form with the paymentIntent and resubmitKey
_context.next = 13;
return fetchImpl(url, _objectSpread2(_objectSpread2({}, request), {}, {
body: JSON.stringify({
paymentIntent: stripeResult.paymentIntent.id,
resubmitKey: responseData.resubmitKey
})
}));
case 13:
resSubmitResponse = _context.sent;
_context.next = 16;
return resSubmitResponse.json();
case 16:
resSubmitData = _context.sent;
return _context.abrupt("return", {
response: resSubmitResponse,
body: resSubmitData
});
case 18:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return function handleSCA(_x) {
return _ref2.apply(this, arguments);
};
}();
var webdriver = function webdriver() {

@@ -116,5 +617,3 @@ return navigator.webdriver || !!document.documentElement.getAttribute(atob('d2ViZHJpdmVy')) || // @ts-ignore

var Session =
/*#__PURE__*/
function () {
var Session = /*#__PURE__*/function () {
function Session() {

@@ -143,5 +642,3 @@ _classCallCheck(this, Session);

var Client =
/*#__PURE__*/
function () {
var Client = /*#__PURE__*/function () {
function Client() {

@@ -153,2 +650,3 @@ var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

this.project = config.project;
this.stripePromise = config.stripePromise;
if (typeof window !== 'undefined') this.startBrowserSession();

@@ -187,43 +685,145 @@ }

key: "submitForm",
value: function submitForm(formKey, data) {
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var endpoint = opts.endpoint || 'https://formspree.io';
var fetchImpl = opts.fetchImpl || fetchPonyfill({
Promise: Promise
}).fetch;
var url = this.project ? "".concat(endpoint, "/p/").concat(this.project, "/f/").concat(formKey) : "".concat(endpoint, "/f/").concat(formKey);
value: function () {
var _submitForm = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(formKey, data) {
var opts,
endpoint,
fetchImpl,
url,
serializeBody,
headers,
request,
payload,
response,
responseData,
_args = arguments;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
endpoint = opts.endpoint || 'https://formspree.io';
fetchImpl = opts.fetchImpl || fetchPonyfill({
Promise: PromisePolyfill
}).fetch;
url = this.project ? "".concat(endpoint, "/p/").concat(this.project, "/f/").concat(formKey) : "".concat(endpoint, "/f/").concat(formKey);
var serializeBody = function serializeBody(data) {
if (data instanceof FormData) return data;
return JSON.stringify(data);
};
serializeBody = function serializeBody(data) {
if (data instanceof FormData) return data;
return JSON.stringify(data);
};
var headers = {
Accept: 'application/json',
'Formspree-Client': clientHeader(opts.clientName)
};
headers = {
Accept: 'application/json',
'Formspree-Client': clientHeader(opts.clientName)
};
if (this.session) {
headers['Formspree-Session-Data'] = encode64(this.session.data());
}
if (this.session) {
headers['Formspree-Session-Data'] = encode64(this.session.data());
}
if (!(data instanceof FormData)) {
headers['Content-Type'] = 'application/json';
if (!(data instanceof FormData)) {
headers['Content-Type'] = 'application/json';
}
request = {
method: 'POST',
mode: 'cors',
body: serializeBody(data),
headers: headers
}; // first check if we need to add the stripe paymentMethod
if (!(this.stripePromise && opts.createPaymentMethod)) {
_context.next = 29;
break;
}
_context.next = 12;
return opts.createPaymentMethod();
case 12:
payload = _context.sent;
if (!payload.error) {
_context.next = 15;
break;
}
return _context.abrupt("return", {
response: null,
body: {
errors: [{
code: 'STRIPE_CLIENT_ERROR',
message: 'Error creating payment method',
field: 'paymentMethod'
}]
}
});
case 15:
// Add the paymentMethod to the data
appendExtraData(data, 'paymentMethod', payload.paymentMethod.id); // Send a request to Formspree server to handle the payment method
_context.next = 18;
return fetchImpl(url, _objectSpread2(_objectSpread2({}, request), {}, {
body: data
}));
case 18:
response = _context.sent;
_context.next = 21;
return response.json();
case 21:
responseData = _context.sent;
if (!(responseData && responseData.stripe && responseData.stripe.requiresAction && responseData.resubmitKey)) {
_context.next = 26;
break;
}
_context.next = 25;
return handleSCA({
stripePromise: this.stripePromise,
responseData: responseData,
response: response,
payload: payload,
data: data,
fetchImpl: fetchImpl,
request: request,
url: url
});
case 25:
return _context.abrupt("return", _context.sent);
case 26:
return _context.abrupt("return", {
response: response,
body: responseData
});
case 29:
return _context.abrupt("return", fetchImpl(url, request).then(function (response) {
return response.json().then(function (body) {
return {
body: body,
response: response
};
});
}));
case 30:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));
function submitForm(_x, _x2) {
return _submitForm.apply(this, arguments);
}
var request = {
method: 'POST',
mode: 'cors',
body: serializeBody(data),
headers: headers
};
return fetchImpl(url, request).then(function (response) {
return response.json().then(function (body) {
return {
body: body,
response: response
};
});
});
}
return submitForm;
}()
}]);

@@ -230,0 +830,0 @@

@@ -1,4 +0,411 @@

import Promise from 'promise-polyfill';
import PromisePolyfill from 'promise-polyfill';
import fetchPonyfill from 'fetch-ponyfill';
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
enumerableOnly && (symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
})), keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = null != arguments[i] ? arguments[i] : {};
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
_defineProperty(target, key, source[key]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
return target;
}
function _regeneratorRuntime() {
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
_regeneratorRuntime = function () {
return exports;
};
var exports = {},
Op = Object.prototype,
hasOwn = Op.hasOwnProperty,
$Symbol = "function" == typeof Symbol ? Symbol : {},
iteratorSymbol = $Symbol.iterator || "@@iterator",
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
function define(obj, key, value) {
return Object.defineProperty(obj, key, {
value: value,
enumerable: !0,
configurable: !0,
writable: !0
}), obj[key];
}
try {
define({}, "");
} catch (err) {
define = function (obj, key, value) {
return obj[key] = value;
};
}
function wrap(innerFn, outerFn, self, tryLocsList) {
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
generator = Object.create(protoGenerator.prototype),
context = new Context(tryLocsList || []);
return generator._invoke = function (innerFn, self, context) {
var state = "suspendedStart";
return function (method, arg) {
if ("executing" === state) throw new Error("Generator is already running");
if ("completed" === state) {
if ("throw" === method) throw arg;
return doneResult();
}
for (context.method = method, context.arg = arg;;) {
var delegate = context.delegate;
if (delegate) {
var delegateResult = maybeInvokeDelegate(delegate, context);
if (delegateResult) {
if (delegateResult === ContinueSentinel) continue;
return delegateResult;
}
}
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
if ("suspendedStart" === state) throw state = "completed", context.arg;
context.dispatchException(context.arg);
} else "return" === context.method && context.abrupt("return", context.arg);
state = "executing";
var record = tryCatch(innerFn, self, context);
if ("normal" === record.type) {
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
return {
value: record.arg,
done: context.done
};
}
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
}
};
}(innerFn, self, context), generator;
}
function tryCatch(fn, obj, arg) {
try {
return {
type: "normal",
arg: fn.call(obj, arg)
};
} catch (err) {
return {
type: "throw",
arg: err
};
}
}
exports.wrap = wrap;
var ContinueSentinel = {};
function Generator() {}
function GeneratorFunction() {}
function GeneratorFunctionPrototype() {}
var IteratorPrototype = {};
define(IteratorPrototype, iteratorSymbol, function () {
return this;
});
var getProto = Object.getPrototypeOf,
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
function defineIteratorMethods(prototype) {
["next", "throw", "return"].forEach(function (method) {
define(prototype, method, function (arg) {
return this._invoke(method, arg);
});
});
}
function AsyncIterator(generator, PromiseImpl) {
function invoke(method, arg, resolve, reject) {
var record = tryCatch(generator[method], generator, arg);
if ("throw" !== record.type) {
var result = record.arg,
value = result.value;
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
invoke("next", value, resolve, reject);
}, function (err) {
invoke("throw", err, resolve, reject);
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
result.value = unwrapped, resolve(result);
}, function (error) {
return invoke("throw", error, resolve, reject);
});
}
reject(record.arg);
}
var previousPromise;
this._invoke = function (method, arg) {
function callInvokeWithMethodAndArg() {
return new PromiseImpl(function (resolve, reject) {
invoke(method, arg, resolve, reject);
});
}
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
};
}
function maybeInvokeDelegate(delegate, context) {
var method = delegate.iterator[context.method];
if (undefined === method) {
if (context.delegate = null, "throw" === context.method) {
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
}
return ContinueSentinel;
}
var record = tryCatch(method, delegate.iterator, context.arg);
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
var info = record.arg;
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
}
function pushTryEntry(locs) {
var entry = {
tryLoc: locs[0]
};
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
}
function resetTryEntry(entry) {
var record = entry.completion || {};
record.type = "normal", delete record.arg, entry.completion = record;
}
function Context(tryLocsList) {
this.tryEntries = [{
tryLoc: "root"
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
}
function values(iterable) {
if (iterable) {
var iteratorMethod = iterable[iteratorSymbol];
if (iteratorMethod) return iteratorMethod.call(iterable);
if ("function" == typeof iterable.next) return iterable;
if (!isNaN(iterable.length)) {
var i = -1,
next = function next() {
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
return next.value = undefined, next.done = !0, next;
};
return next.next = next;
}
}
return {
next: doneResult
};
}
function doneResult() {
return {
value: undefined,
done: !0
};
}
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
var ctor = "function" == typeof genFun && genFun.constructor;
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
}, exports.mark = function (genFun) {
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
}, exports.awrap = function (arg) {
return {
__await: arg
};
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
return this;
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
void 0 === PromiseImpl && (PromiseImpl = Promise);
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
return result.done ? result.value : iter.next();
});
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
return this;
}), define(Gp, "toString", function () {
return "[object Generator]";
}), exports.keys = function (object) {
var keys = [];
for (var key in object) keys.push(key);
return keys.reverse(), function next() {
for (; keys.length;) {
var key = keys.pop();
if (key in object) return next.value = key, next.done = !1, next;
}
return next.done = !0, next;
};
}, exports.values = values, Context.prototype = {
constructor: Context,
reset: function (skipTempReset) {
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
},
stop: function () {
this.done = !0;
var rootRecord = this.tryEntries[0].completion;
if ("throw" === rootRecord.type) throw rootRecord.arg;
return this.rval;
},
dispatchException: function (exception) {
if (this.done) throw exception;
var context = this;
function handle(loc, caught) {
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
}
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i],
record = entry.completion;
if ("root" === entry.tryLoc) return handle("end");
if (entry.tryLoc <= this.prev) {
var hasCatch = hasOwn.call(entry, "catchLoc"),
hasFinally = hasOwn.call(entry, "finallyLoc");
if (hasCatch && hasFinally) {
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
} else if (hasCatch) {
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
} else {
if (!hasFinally) throw new Error("try statement without catch or finally");
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
}
}
}
},
abrupt: function (type, arg) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
var finallyEntry = entry;
break;
}
}
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
var record = finallyEntry ? finallyEntry.completion : {};
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
},
complete: function (record, afterLoc) {
if ("throw" === record.type) throw record.arg;
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
},
finish: function (finallyLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
}
},
catch: function (tryLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc === tryLoc) {
var record = entry.completion;
if ("throw" === record.type) {
var thrown = record.arg;
resetTryEntry(entry);
}
return thrown;
}
}
throw new Error("illegal catch attempt");
},
delegateYield: function (iterable, resultName, nextLoc) {
return this.delegate = {
iterator: values(iterable),
resultName: resultName,
nextLoc: nextLoc
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
}
}, exports;
}
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
function _classCallCheck(instance, Constructor) {

@@ -23,5 +430,23 @@ if (!(instance instanceof Constructor)) {

if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';

@@ -69,3 +494,3 @@ var b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;

var version = "2.6.4";
var version = "2.7.0";

@@ -77,3 +502,2 @@ /**

*/
var encode64 = function encode64(obj) {

@@ -101,3 +525,80 @@ return btoa(JSON.stringify(obj));

};
var appendExtraData = function appendExtraData(formData, prop, value) {
if (formData instanceof FormData) {
formData.append(prop, value);
} else {
formData = Object.assign(formData, _defineProperty({}, prop, value));
}
};
var handleSCA = /*#__PURE__*/function () {
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
var stripePromise, response, responseData, payload, data, fetchImpl, request, url, stripeResult, resSubmitResponse, resSubmitData;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
stripePromise = _ref.stripePromise, response = _ref.response, responseData = _ref.responseData, payload = _ref.payload, data = _ref.data, fetchImpl = _ref.fetchImpl, request = _ref.request, url = _ref.url;
_context.next = 3;
return stripePromise.handleCardAction(responseData.stripe.paymentIntentClientSecret);
case 3:
stripeResult = _context.sent;
if (!stripeResult.error) {
_context.next = 8;
break;
}
return _context.abrupt("return", {
response: response,
body: {
errors: [{
code: 'STRIPE_CLIENT_ERROR',
message: 'Stripe SCA error',
field: 'paymentMethod'
}]
}
});
case 8:
if (!payload.paymentMethod.id) {
appendExtraData(data, 'paymentMethod', payload.paymentMethod.id);
}
appendExtraData(data, 'paymentIntent', stripeResult.paymentIntent.id);
appendExtraData(data, 'resubmitKey', responseData.resubmitKey); // Resubmit the form with the paymentIntent and resubmitKey
_context.next = 13;
return fetchImpl(url, _objectSpread2(_objectSpread2({}, request), {}, {
body: JSON.stringify({
paymentIntent: stripeResult.paymentIntent.id,
resubmitKey: responseData.resubmitKey
})
}));
case 13:
resSubmitResponse = _context.sent;
_context.next = 16;
return resSubmitResponse.json();
case 16:
resSubmitData = _context.sent;
return _context.abrupt("return", {
response: resSubmitResponse,
body: resSubmitData
});
case 18:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return function handleSCA(_x) {
return _ref2.apply(this, arguments);
};
}();
var webdriver = function webdriver() {

@@ -109,5 +610,3 @@ return navigator.webdriver || !!document.documentElement.getAttribute(atob('d2ViZHJpdmVy')) || // @ts-ignore

var Session =
/*#__PURE__*/
function () {
var Session = /*#__PURE__*/function () {
function Session() {

@@ -136,5 +635,3 @@ _classCallCheck(this, Session);

var Client =
/*#__PURE__*/
function () {
var Client = /*#__PURE__*/function () {
function Client() {

@@ -146,2 +643,3 @@ var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

this.project = config.project;
this.stripePromise = config.stripePromise;
if (typeof window !== 'undefined') this.startBrowserSession();

@@ -180,43 +678,145 @@ }

key: "submitForm",
value: function submitForm(formKey, data) {
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var endpoint = opts.endpoint || 'https://formspree.io';
var fetchImpl = opts.fetchImpl || fetchPonyfill({
Promise: Promise
}).fetch;
var url = this.project ? "".concat(endpoint, "/p/").concat(this.project, "/f/").concat(formKey) : "".concat(endpoint, "/f/").concat(formKey);
value: function () {
var _submitForm = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(formKey, data) {
var opts,
endpoint,
fetchImpl,
url,
serializeBody,
headers,
request,
payload,
response,
responseData,
_args = arguments;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
endpoint = opts.endpoint || 'https://formspree.io';
fetchImpl = opts.fetchImpl || fetchPonyfill({
Promise: PromisePolyfill
}).fetch;
url = this.project ? "".concat(endpoint, "/p/").concat(this.project, "/f/").concat(formKey) : "".concat(endpoint, "/f/").concat(formKey);
var serializeBody = function serializeBody(data) {
if (data instanceof FormData) return data;
return JSON.stringify(data);
};
serializeBody = function serializeBody(data) {
if (data instanceof FormData) return data;
return JSON.stringify(data);
};
var headers = {
Accept: 'application/json',
'Formspree-Client': clientHeader(opts.clientName)
};
headers = {
Accept: 'application/json',
'Formspree-Client': clientHeader(opts.clientName)
};
if (this.session) {
headers['Formspree-Session-Data'] = encode64(this.session.data());
}
if (this.session) {
headers['Formspree-Session-Data'] = encode64(this.session.data());
}
if (!(data instanceof FormData)) {
headers['Content-Type'] = 'application/json';
if (!(data instanceof FormData)) {
headers['Content-Type'] = 'application/json';
}
request = {
method: 'POST',
mode: 'cors',
body: serializeBody(data),
headers: headers
}; // first check if we need to add the stripe paymentMethod
if (!(this.stripePromise && opts.createPaymentMethod)) {
_context.next = 29;
break;
}
_context.next = 12;
return opts.createPaymentMethod();
case 12:
payload = _context.sent;
if (!payload.error) {
_context.next = 15;
break;
}
return _context.abrupt("return", {
response: null,
body: {
errors: [{
code: 'STRIPE_CLIENT_ERROR',
message: 'Error creating payment method',
field: 'paymentMethod'
}]
}
});
case 15:
// Add the paymentMethod to the data
appendExtraData(data, 'paymentMethod', payload.paymentMethod.id); // Send a request to Formspree server to handle the payment method
_context.next = 18;
return fetchImpl(url, _objectSpread2(_objectSpread2({}, request), {}, {
body: data
}));
case 18:
response = _context.sent;
_context.next = 21;
return response.json();
case 21:
responseData = _context.sent;
if (!(responseData && responseData.stripe && responseData.stripe.requiresAction && responseData.resubmitKey)) {
_context.next = 26;
break;
}
_context.next = 25;
return handleSCA({
stripePromise: this.stripePromise,
responseData: responseData,
response: response,
payload: payload,
data: data,
fetchImpl: fetchImpl,
request: request,
url: url
});
case 25:
return _context.abrupt("return", _context.sent);
case 26:
return _context.abrupt("return", {
response: response,
body: responseData
});
case 29:
return _context.abrupt("return", fetchImpl(url, request).then(function (response) {
return response.json().then(function (body) {
return {
body: body,
response: response
};
});
}));
case 30:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));
function submitForm(_x, _x2) {
return _submitForm.apply(this, arguments);
}
var request = {
method: 'POST',
mode: 'cors',
body: serializeBody(data),
headers: headers
};
return fetchImpl(url, request).then(function (response) {
return response.json().then(function (body) {
return {
body: body,
response: response
};
});
});
}
return submitForm;
}()
}]);

@@ -223,0 +823,0 @@

4

dist/formspree.iife.js

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

var Formspree=function(t){"use strict";function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function n(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}var o=setTimeout;function i(t){return Boolean(t&&void 0!==t.length)}function s(){}function a(t){if(!(this instanceof a))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],l(t,this)}function u(t,e){for(;3===t._state;)t=t._value;0!==t._state?(t._handled=!0,a._immediateFn((function(){var r=1===t._state?e.onFulfilled:e.onRejected;if(null!==r){var n;try{n=r(t._value)}catch(t){return void c(e.promise,t)}f(e.promise,n)}else(1===t._state?f:c)(e.promise,t._value)}))):t._deferreds.push(e)}function f(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var r=e.then;if(e instanceof a)return t._state=3,t._value=e,void h(t);if("function"==typeof r)return void l((n=r,o=e,function(){n.apply(o,arguments)}),t)}t._state=1,t._value=e,h(t)}catch(e){c(t,e)}var n,o}function c(t,e){t._state=2,t._value=e,h(t)}function h(t){2===t._state&&0===t._deferreds.length&&a._immediateFn((function(){t._handled||a._unhandledRejectionFn(t._value)}));for(var e=0,r=t._deferreds.length;e<r;e++)u(t,t._deferreds[e]);t._deferreds=null}function d(t,e,r){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=r}function l(t,e){var r=!1;try{t((function(t){r||(r=!0,f(e,t))}),(function(t){r||(r=!0,c(e,t))}))}catch(t){if(r)return;r=!0,c(e,t)}}a.prototype.catch=function(t){return this.then(null,t)},a.prototype.then=function(t,e){var r=new this.constructor(s);return u(this,new d(t,e,r)),r},a.prototype.finally=function(t){var e=this.constructor;return this.then((function(r){return e.resolve(t()).then((function(){return r}))}),(function(r){return e.resolve(t()).then((function(){return e.reject(r)}))}))},a.all=function(t){return new a((function(e,r){if(!i(t))return r(new TypeError("Promise.all accepts an array"));var n=Array.prototype.slice.call(t);if(0===n.length)return e([]);var o=n.length;function s(t,i){try{if(i&&("object"==typeof i||"function"==typeof i)){var a=i.then;if("function"==typeof a)return void a.call(i,(function(e){s(t,e)}),r)}n[t]=i,0==--o&&e(n)}catch(t){r(t)}}for(var a=0;a<n.length;a++)s(a,n[a])}))},a.resolve=function(t){return t&&"object"==typeof t&&t.constructor===a?t:new a((function(e){e(t)}))},a.reject=function(t){return new a((function(e,r){r(t)}))},a.race=function(t){return new a((function(e,r){if(!i(t))return r(new TypeError("Promise.race accepts an array"));for(var n=0,o=t.length;n<o;n++)a.resolve(t[n]).then(e,r)}))},a._immediateFn="function"==typeof setImmediate&&function(t){setImmediate(t)}||function(t){o(t,0)},a._unhandledRejectionFn=function(t){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",t)};var p="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var y,b=(function(t,e){!function(e){t.exports=function(t){var r=t&&t.Promise||e.Promise,n=t&&t.XMLHttpRequest||e.XMLHttpRequest,o=e;return function(){var t=Object.create(o,{fetch:{value:void 0,writable:!0}});return function(t){if(!t.fetch){var e="URLSearchParams"in t,o="Symbol"in t&&"iterator"in Symbol,i="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),s="FormData"in t,a="ArrayBuffer"in t;if(a)var u=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],f=function(t){return t&&DataView.prototype.isPrototypeOf(t)},c=ArrayBuffer.isView||function(t){return t&&u.indexOf(Object.prototype.toString.call(t))>-1};b.prototype.append=function(t,e){t=l(t),e=p(e);var r=this.map[t];this.map[t]=r?r+","+e:e},b.prototype.delete=function(t){delete this.map[l(t)]},b.prototype.get=function(t){return t=l(t),this.has(t)?this.map[t]:null},b.prototype.has=function(t){return this.map.hasOwnProperty(l(t))},b.prototype.set=function(t,e){this.map[l(t)]=p(e)},b.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},b.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),y(t)},b.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),y(t)},b.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),y(t)},o&&(b.prototype[Symbol.iterator]=b.prototype.entries);var h=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];g.prototype.clone=function(){return new g(this,{body:this._bodyInit})},A.call(g.prototype),A.call(E.prototype),E.prototype.clone=function(){return new E(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new b(this.headers),url:this.url})},E.error=function(){var t=new E(null,{status:0,statusText:""});return t.type="error",t};var d=[301,302,303,307,308];E.redirect=function(t,e){if(-1===d.indexOf(e))throw new RangeError("Invalid status code");return new E(null,{status:e,headers:{location:t}})},t.Headers=b,t.Request=g,t.Response=E,t.fetch=function(t,e){return new r((function(r,o){var s=new g(t,e),a=new n;a.onload=function(){var t,e,n={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new b,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var r=t.split(":"),n=r.shift().trim();if(n){var o=r.join(":").trim();e.append(n,o)}})),e)};n.url="responseURL"in a?a.responseURL:n.headers.get("X-Request-URL");var o="response"in a?a.response:a.responseText;r(new E(o,n))},a.onerror=function(){o(new TypeError("Network request failed"))},a.ontimeout=function(){o(new TypeError("Network request failed"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&i&&(a.responseType="blob"),s.headers.forEach((function(t,e){a.setRequestHeader(e,t)})),a.send(void 0===s._bodyInit?null:s._bodyInit)}))},t.fetch.polyfill=!0}function l(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function p(t){return"string"!=typeof t&&(t=String(t)),t}function y(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return o&&(e[Symbol.iterator]=function(){return e}),e}function b(t){this.map={},t instanceof b?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function w(t){if(t.bodyUsed)return r.reject(new TypeError("Already read"));t.bodyUsed=!0}function v(t){return new r((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function m(t){var e=new FileReader,r=v(e);return e.readAsArrayBuffer(t),r}function _(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function A(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t,t)if("string"==typeof t)this._bodyText=t;else if(i&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(s&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(e&&URLSearchParams.prototype.isPrototypeOf(t))this._bodyText=t.toString();else if(a&&i&&f(t))this._bodyArrayBuffer=_(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!a||!ArrayBuffer.prototype.isPrototypeOf(t)&&!c(t))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=_(t)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):e&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var t=w(this);if(t)return t;if(this._bodyBlob)return r.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return r.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return r.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?w(this)||r.resolve(this._bodyArrayBuffer):this.blob().then(m)}),this.text=function(){var t,e,n,o=w(this);if(o)return o;if(this._bodyBlob)return t=this._bodyBlob,n=v(e=new FileReader),e.readAsText(t),n;if(this._bodyArrayBuffer)return r.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return r.resolve(this._bodyText)},s&&(this.formData=function(){return this.text().then(T)}),this.json=function(){return this.text().then(JSON.parse)},this}function g(t,e){var r,n,o=(e=e||{}).body;if(t instanceof g){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new b(t.headers)),this.method=t.method,this.mode=t.mode,o||null==t._bodyInit||(o=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"omit",!e.headers&&this.headers||(this.headers=new b(e.headers)),this.method=(n=(r=e.method||this.method||"GET").toUpperCase(),h.indexOf(n)>-1?n:r),this.mode=e.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(o)}function T(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(o))}})),e}function E(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new b(e.headers),this.url=e.url||"",this._initBody(t)}}(void 0!==t?t:this),{fetch:t.fetch,Headers:t.Headers,Request:t.Request,Response:t.Response}}()}}("undefined"!=typeof self?self:p)}(y={exports:{}},y.exports),y.exports),w="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",v=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;var m,_=function(t){return function(t){for(var e,r,n,o,i="",s=0,a=(t=String(t)).length%3;s<t.length;){if((r=t.charCodeAt(s++))>255||(n=t.charCodeAt(s++))>255||(o=t.charCodeAt(s++))>255)throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");i+=w.charAt((e=r<<16|n<<8|o)>>18&63)+w.charAt(e>>12&63)+w.charAt(e>>6&63)+w.charAt(63&e)}return a?i.slice(0,a-3)+"===".substring(a):i}(JSON.stringify(t))},A=function(t){var e="@formspree/core@".concat("2.6.4");return t?"".concat(t," ").concat(e):e},g=function(){return navigator.webdriver||!!document.documentElement.getAttribute(function(t){if(t=String(t).replace(/[\t\n\f\r ]+/g,""),!v.test(t))throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");t+="==".slice(2-(3&t.length));for(var e,r,n,o="",i=0;i<t.length;)e=w.indexOf(t.charAt(i++))<<18|w.indexOf(t.charAt(i++))<<12|(r=w.indexOf(t.charAt(i++)))<<6|(n=w.indexOf(t.charAt(i++))),o+=64===r?String.fromCharCode(e>>16&255):64===n?String.fromCharCode(e>>16&255,e>>8&255):String.fromCharCode(e>>16&255,e>>8&255,255&e);return o}("d2ViZHJpdmVy"))||!!window.callPhantom||!!window._phantom},T=function(){function t(){e(this,t),this.loadedAt=1*new Date,this.webdriver=g()}return n(t,[{key:"teardown",value:function(){}},{key:"data",value:function(){return{loadedAt:this.loadedAt,webdriver:this.webdriver}}}]),t}(),E=function(){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e(this,t),this.project=r.project,"undefined"!=typeof window&&this.startBrowserSession()}return n(t,[{key:"startBrowserSession",value:function(){this.session||(this.session=new T)}},{key:"teardown",value:function(){this.session&&this.session.teardown()}},{key:"submitForm",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.endpoint||"https://formspree.io",o=r.fetchImpl||b({Promise:a}).fetch,i=this.project?"".concat(n,"/p/").concat(this.project,"/f/").concat(t):"".concat(n,"/f/").concat(t),s=function(t){return t instanceof FormData?t:JSON.stringify(t)},u={Accept:"application/json","Formspree-Client":A(r.clientName)};this.session&&(u["Formspree-Session-Data"]=_(this.session.data())),e instanceof FormData||(u["Content-Type"]="application/json");var f={method:"POST",mode:"cors",body:s(e),headers:u};return o(i,f).then((function(t){return t.json().then((function(e){return{body:e,response:t}}))}))}}]),t}(),B=function(t){return new E(t)};return t.Client=E,t.createClient=B,t.getDefaultClient=function(){return m||(m=B()),m},t}({});
var Formspree=function(t){"use strict";function e(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function r(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?e(Object(n),!0).forEach((function(e){c(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function n(){
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
n=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",s=o.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof l?e:l,i=Object.create(o.prototype),a=new j(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return O()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=_(a,r);if(s){if(s===h)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=f(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var h={};function l(){}function d(){}function p(){}var y={};u(y,i,(function(){return this}));var v=Object.getPrototypeOf,m=v&&v(v(A([])));m&&m!==e&&r.call(m,i)&&(y=m);var b=p.prototype=l.prototype=Object.create(y);function w(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function g(t,e){function n(o,i,a,s){var u=f(t[o],t,i);if("throw"!==u.type){var c=u.arg,h=c.value;return h&&"object"==typeof h&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(h).then((function(t){c.value=t,a(c)}),(function(t){return n("throw",t,a,s)}))}s(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function _(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=f(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,h;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function x(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function A(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:O}}function O(){return{value:void 0,done:!0}}return d.prototype=p,u(b,"constructor",p),u(p,"constructor",d),d.displayName=u(p,s,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,u(t,s,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},w(g.prototype),u(g.prototype,a,(function(){return this})),t.AsyncIterator=g,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new g(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(b),u(b,s,"Generator"),u(b,i,(function(){return this})),u(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=A,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(s&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:A(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function o(t,e,r,n,o,i,a){try{var s=t[i](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,o)}function i(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var a=t.apply(e,r);function s(t){o(a,n,i,s,u,"next",t)}function u(t){o(a,n,i,s,u,"throw",t)}s(void 0)}))}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function u(t,e,r){return e&&s(t.prototype,e),r&&s(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function c(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var f=setTimeout;function h(t){return Boolean(t&&void 0!==t.length)}function l(){}function d(t){if(!(this instanceof d))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],w(t,this)}function p(t,e){for(;3===t._state;)t=t._value;0!==t._state?(t._handled=!0,d._immediateFn((function(){var r=1===t._state?e.onFulfilled:e.onRejected;if(null!==r){var n;try{n=r(t._value)}catch(t){return void v(e.promise,t)}y(e.promise,n)}else(1===t._state?y:v)(e.promise,t._value)}))):t._deferreds.push(e)}function y(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var r=e.then;if(e instanceof d)return t._state=3,t._value=e,void m(t);if("function"==typeof r)return void w((n=r,o=e,function(){n.apply(o,arguments)}),t)}t._state=1,t._value=e,m(t)}catch(e){v(t,e)}var n,o}function v(t,e){t._state=2,t._value=e,m(t)}function m(t){2===t._state&&0===t._deferreds.length&&d._immediateFn((function(){t._handled||d._unhandledRejectionFn(t._value)}));for(var e=0,r=t._deferreds.length;e<r;e++)p(t,t._deferreds[e]);t._deferreds=null}function b(t,e,r){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=r}function w(t,e){var r=!1;try{t((function(t){r||(r=!0,y(e,t))}),(function(t){r||(r=!0,v(e,t))}))}catch(t){if(r)return;r=!0,v(e,t)}}d.prototype.catch=function(t){return this.then(null,t)},d.prototype.then=function(t,e){var r=new this.constructor(l);return p(this,new b(t,e,r)),r},d.prototype.finally=function(t){var e=this.constructor;return this.then((function(r){return e.resolve(t()).then((function(){return r}))}),(function(r){return e.resolve(t()).then((function(){return e.reject(r)}))}))},d.all=function(t){return new d((function(e,r){if(!h(t))return r(new TypeError("Promise.all accepts an array"));var n=Array.prototype.slice.call(t);if(0===n.length)return e([]);var o=n.length;function i(t,a){try{if(a&&("object"==typeof a||"function"==typeof a)){var s=a.then;if("function"==typeof s)return void s.call(a,(function(e){i(t,e)}),r)}n[t]=a,0==--o&&e(n)}catch(t){r(t)}}for(var a=0;a<n.length;a++)i(a,n[a])}))},d.allSettled=function(t){return new this((function(e,r){if(!t||void 0===t.length)return r(new TypeError(typeof t+" "+t+" is not iterable(cannot read property Symbol(Symbol.iterator))"));var n=Array.prototype.slice.call(t);if(0===n.length)return e([]);var o=n.length;function i(t,r){if(r&&("object"==typeof r||"function"==typeof r)){var a=r.then;if("function"==typeof a)return void a.call(r,(function(e){i(t,e)}),(function(r){n[t]={status:"rejected",reason:r},0==--o&&e(n)}))}n[t]={status:"fulfilled",value:r},0==--o&&e(n)}for(var a=0;a<n.length;a++)i(a,n[a])}))},d.resolve=function(t){return t&&"object"==typeof t&&t.constructor===d?t:new d((function(e){e(t)}))},d.reject=function(t){return new d((function(e,r){r(t)}))},d.race=function(t){return new d((function(e,r){if(!h(t))return r(new TypeError("Promise.race accepts an array"));for(var n=0,o=t.length;n<o;n++)d.resolve(t[n]).then(e,r)}))},d._immediateFn="function"==typeof setImmediate&&function(t){setImmediate(t)}||function(t){f(t,0)},d._unhandledRejectionFn=function(t){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",t)};var g="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var _,x,E=(_=function(t,e){!function(e){t.exports=function(t){var r=t&&t.Promise||e.Promise,n=t&&t.XMLHttpRequest||e.XMLHttpRequest,o=e;return function(){var t=Object.create(o,{fetch:{value:void 0,writable:!0}});return function(t){if(!t.fetch){var e="URLSearchParams"in t,o="Symbol"in t&&"iterator"in Symbol,i="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),a="FormData"in t,s="ArrayBuffer"in t;if(s)var u=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],c=function(t){return t&&DataView.prototype.isPrototypeOf(t)},f=ArrayBuffer.isView||function(t){return t&&u.indexOf(Object.prototype.toString.call(t))>-1};v.prototype.append=function(t,e){t=d(t),e=p(e);var r=this.map[t];this.map[t]=r?r+","+e:e},v.prototype.delete=function(t){delete this.map[d(t)]},v.prototype.get=function(t){return t=d(t),this.has(t)?this.map[t]:null},v.prototype.has=function(t){return this.map.hasOwnProperty(d(t))},v.prototype.set=function(t,e){this.map[d(t)]=p(e)},v.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},v.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),y(t)},v.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),y(t)},v.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),y(t)},o&&(v.prototype[Symbol.iterator]=v.prototype.entries);var h=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];x.prototype.clone=function(){return new x(this,{body:this._bodyInit})},_.call(x.prototype),_.call(j.prototype),j.prototype.clone=function(){return new j(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new v(this.headers),url:this.url})},j.error=function(){var t=new j(null,{status:0,statusText:""});return t.type="error",t};var l=[301,302,303,307,308];j.redirect=function(t,e){if(-1===l.indexOf(e))throw new RangeError("Invalid status code");return new j(null,{status:e,headers:{location:t}})},t.Headers=v,t.Request=x,t.Response=j,t.fetch=function(t,e){return new r((function(r,o){var a=new x(t,e),s=new n;s.onload=function(){var t,e,n={status:s.status,statusText:s.statusText,headers:(t=s.getAllResponseHeaders()||"",e=new v,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var r=t.split(":"),n=r.shift().trim();if(n){var o=r.join(":").trim();e.append(n,o)}})),e)};n.url="responseURL"in s?s.responseURL:n.headers.get("X-Request-URL");var o="response"in s?s.response:s.responseText;r(new j(o,n))},s.onerror=function(){o(new TypeError("Network request failed"))},s.ontimeout=function(){o(new TypeError("Network request failed"))},s.open(a.method,a.url,!0),"include"===a.credentials?s.withCredentials=!0:"omit"===a.credentials&&(s.withCredentials=!1),"responseType"in s&&i&&(s.responseType="blob"),a.headers.forEach((function(t,e){s.setRequestHeader(e,t)})),s.send(void 0===a._bodyInit?null:a._bodyInit)}))},t.fetch.polyfill=!0}function d(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function p(t){return"string"!=typeof t&&(t=String(t)),t}function y(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return o&&(e[Symbol.iterator]=function(){return e}),e}function v(t){this.map={},t instanceof v?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function m(t){if(t.bodyUsed)return r.reject(new TypeError("Already read"));t.bodyUsed=!0}function b(t){return new r((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function w(t){var e=new FileReader,r=b(e);return e.readAsArrayBuffer(t),r}function g(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function _(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t,t)if("string"==typeof t)this._bodyText=t;else if(i&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(a&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(e&&URLSearchParams.prototype.isPrototypeOf(t))this._bodyText=t.toString();else if(s&&i&&c(t))this._bodyArrayBuffer=g(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!s||!ArrayBuffer.prototype.isPrototypeOf(t)&&!f(t))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=g(t)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):e&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var t=m(this);if(t)return t;if(this._bodyBlob)return r.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return r.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return r.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?m(this)||r.resolve(this._bodyArrayBuffer):this.blob().then(w)}),this.text=function(){var t,e,n,o=m(this);if(o)return o;if(this._bodyBlob)return t=this._bodyBlob,n=b(e=new FileReader),e.readAsText(t),n;if(this._bodyArrayBuffer)return r.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return r.resolve(this._bodyText)},a&&(this.formData=function(){return this.text().then(E)}),this.json=function(){return this.text().then(JSON.parse)},this}function x(t,e){var r,n,o=(e=e||{}).body;if(t instanceof x){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new v(t.headers)),this.method=t.method,this.mode=t.mode,o||null==t._bodyInit||(o=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"omit",!e.headers&&this.headers||(this.headers=new v(e.headers)),this.method=(n=(r=e.method||this.method||"GET").toUpperCase(),h.indexOf(n)>-1?n:r),this.mode=e.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(o)}function E(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(o))}})),e}function j(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new v(e.headers),this.url=e.url||"",this._initBody(t)}}(void 0!==t?t:this),{fetch:t.fetch,Headers:t.Headers,Request:t.Request,Response:t.Response}}()}}("undefined"!=typeof self?self:g)},_(x={exports:{}},x.exports),x.exports),j="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",A=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;var O,T=function(t){return function(t){for(var e,r,n,o,i="",a=0,s=(t=String(t)).length%3;a<t.length;){if((r=t.charCodeAt(a++))>255||(n=t.charCodeAt(a++))>255||(o=t.charCodeAt(a++))>255)throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");i+=j.charAt((e=r<<16|n<<8|o)>>18&63)+j.charAt(e>>12&63)+j.charAt(e>>6&63)+j.charAt(63&e)}return s?i.slice(0,s-3)+"===".substring(s):i}(JSON.stringify(t))},P=function(t){var e="@formspree/core@".concat("2.7.0");return t?"".concat(t," ").concat(e):e},S=function(t,e,r){t instanceof FormData?t.append(e,r):t=Object.assign(t,c({},e,r))},L=function(){var t=i(n().mark((function t(e){var o,i,a,s,u,c,f,h,l,d,p;return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=e.stripePromise,i=e.response,a=e.responseData,s=e.payload,u=e.data,c=e.fetchImpl,f=e.request,h=e.url,t.next=3,o.handleCardAction(a.stripe.paymentIntentClientSecret);case 3:if(!(l=t.sent).error){t.next=8;break}return t.abrupt("return",{response:i,body:{errors:[{code:"STRIPE_CLIENT_ERROR",message:"Stripe SCA error",field:"paymentMethod"}]}});case 8:return s.paymentMethod.id||S(u,"paymentMethod",s.paymentMethod.id),S(u,"paymentIntent",l.paymentIntent.id),S(u,"resubmitKey",a.resubmitKey),t.next=13,c(h,r(r({},f),{},{body:JSON.stringify({paymentIntent:l.paymentIntent.id,resubmitKey:a.resubmitKey})}));case 13:return d=t.sent,t.next=16,d.json();case 16:return p=t.sent,t.abrupt("return",{response:d,body:p});case 18:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),B=function(){return navigator.webdriver||!!document.documentElement.getAttribute(function(t){if(t=String(t).replace(/[\t\n\f\r ]+/g,""),!A.test(t))throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");t+="==".slice(2-(3&t.length));for(var e,r,n,o="",i=0;i<t.length;)e=j.indexOf(t.charAt(i++))<<18|j.indexOf(t.charAt(i++))<<12|(r=j.indexOf(t.charAt(i++)))<<6|(n=j.indexOf(t.charAt(i++))),o+=64===r?String.fromCharCode(e>>16&255):64===n?String.fromCharCode(e>>16&255,e>>8&255):String.fromCharCode(e>>16&255,e>>8&255,255&e);return o}("d2ViZHJpdmVy"))||!!window.callPhantom||!!window._phantom},F=function(){function t(){a(this,t),this.loadedAt=1*new Date,this.webdriver=B()}return u(t,[{key:"teardown",value:function(){}},{key:"data",value:function(){return{loadedAt:this.loadedAt,webdriver:this.webdriver}}}]),t}(),R=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,t),this.project=e.project,this.stripePromise=e.stripePromise,"undefined"!=typeof window&&this.startBrowserSession()}var e;return u(t,[{key:"startBrowserSession",value:function(){this.session||(this.session=new F)}},{key:"teardown",value:function(){this.session&&this.session.teardown()}},{key:"submitForm",value:(e=i(n().mark((function t(e,o){var i,a,s,u,c,f,h,l,p,y,v=arguments;return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=v.length>2&&void 0!==v[2]?v[2]:{},a=i.endpoint||"https://formspree.io",s=i.fetchImpl||E({Promise:d}).fetch,u=this.project?"".concat(a,"/p/").concat(this.project,"/f/").concat(e):"".concat(a,"/f/").concat(e),c=function(t){return t instanceof FormData?t:JSON.stringify(t)},f={Accept:"application/json","Formspree-Client":P(i.clientName)},this.session&&(f["Formspree-Session-Data"]=T(this.session.data())),o instanceof FormData||(f["Content-Type"]="application/json"),h={method:"POST",mode:"cors",body:c(o),headers:f},!this.stripePromise||!i.createPaymentMethod){t.next=29;break}return t.next=12,i.createPaymentMethod();case 12:if(!(l=t.sent).error){t.next=15;break}return t.abrupt("return",{response:null,body:{errors:[{code:"STRIPE_CLIENT_ERROR",message:"Error creating payment method",field:"paymentMethod"}]}});case 15:return S(o,"paymentMethod",l.paymentMethod.id),t.next=18,s(u,r(r({},h),{},{body:o}));case 18:return p=t.sent,t.next=21,p.json();case 21:if(!((y=t.sent)&&y.stripe&&y.stripe.requiresAction&&y.resubmitKey)){t.next=26;break}return t.next=25,L({stripePromise:this.stripePromise,responseData:y,response:p,payload:l,data:o,fetchImpl:s,request:h,url:u});case 25:return t.abrupt("return",t.sent);case 26:return t.abrupt("return",{response:p,body:y});case 29:return t.abrupt("return",s(u,h).then((function(t){return t.json().then((function(e){return{body:e,response:t}}))})));case 30:case"end":return t.stop()}}),t,this)}))),function(t,r){return e.apply(this,arguments)})}]),t}(),I=function(t){return new R(t)};return t.Client=R,t.createClient=I,t.getDefaultClient=function(){return O||(O=I()),O},t}({});

@@ -1,2 +0,3 @@

export declare type SubmissionData = FormData | object;
import { PaymentMethodResult } from '@stripe/stripe-js';
export declare type SubmissionData = FormData | any;
export interface SubmissionOptions {

@@ -6,2 +7,3 @@ endpoint?: string;

fetchImpl?: typeof fetch;
createPaymentMethod?: () => Promise<PaymentMethodResult>;
}

@@ -16,3 +18,5 @@ declare enum FormErrorCodeEnum {

TOO_MANY_FILES = "TOO_MANY_FILES",
FILES_TOO_BIG = "FILES_TOO_BIG"
FILES_TOO_BIG = "FILES_TOO_BIG",
STRIPE_CLIENT_ERROR = "STRIPE_CLIENT_ERROR",
STRIPE_SCA_ERROR = "STRIPE_SCA_ERROR"
}

@@ -32,2 +36,5 @@ declare enum FieldErrorCodeEnum {

message: string;
details?: {
stripeCode?: string;
};
}

@@ -56,4 +63,4 @@ export interface FieldError extends FormError {

body: SubmissionBody;
response: Response;
response: Response | null;
}
export {};

@@ -1,8 +0,10 @@

/// <reference types="promise-polyfill" />
import { Stripe } from '@stripe/stripe-js';
import { SubmissionData, SubmissionOptions, SubmissionResponse } from './forms';
export interface Config {
project?: string;
stripePromise?: Stripe;
}
export declare class Client {
project: string | undefined;
stripePromise: Stripe | undefined;
private session;

@@ -30,3 +32,3 @@ constructor(config?: Config);

*/
export declare const createClient: (config?: Config | undefined) => Client;
export declare const createClient: (config?: Config) => Client;
/**

@@ -33,0 +35,0 @@ * Fetches the global default client.

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

import { SubmissionResponse } from './forms';
import { PaymentMethod, Stripe } from '@stripe/stripe-js';
/**

@@ -44,1 +46,24 @@ * Base-64 encodes a (JSON-castable) object.

export declare const now: () => number;
export declare const appendExtraData: (formData: FormData | object, prop: string, value: string) => void;
declare type HandleSCAargs = {
stripePromise: Stripe;
response: Response;
responseData: any;
payload: {
paymentMethod: PaymentMethod;
error?: undefined;
};
data: FormData | object;
fetchImpl: (input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>;
request: {
method: string;
mode: 'cors';
body: string | FormData;
headers: {
[key: string]: string;
};
};
url: string;
};
export declare const handleSCA: ({ stripePromise, response, responseData, payload, data, fetchImpl, request, url }: HandleSCAargs) => Promise<SubmissionResponse>;
export {};
{
"name": "@formspree/core",
"version": "2.6.4",
"version": "2.7.0",
"description": "The core library for Formspree",

@@ -15,2 +15,5 @@ "homepage": "https://formspree.io",

"author": "Derrick Reimer",
"main": "dist/formspree.cjs.js",
"module": "dist/formspree.esm.js",
"types": "dist/types/src/index.d.ts",
"files": [

@@ -20,15 +23,12 @@ "dist/**/*.{js,ts}",

],
"main": "dist/formspree.cjs.js",
"module": "dist/formspree.esm.js",
"types": "dist/types/src/index.d.ts",
"scripts": {
"build": "rm -rf dist && npm run build:types && npm run build:js",
"build": "rm -rf dist && yarn run build:types && yarn run build:js",
"build:js": "rollup -c",
"build:types": "tsc --emitDeclarationOnly",
"format": "npx prettier --write 'src/**/*.{js,ts}'",
"prepare": "npm run build",
"prepare": "yarn build",
"release": "np",
"test": "jest",
"type-check": "tsc --noEmit",
"type-check:watch": "npm run type-check -- --watch"
"type-check:watch": "yarn run type-check -- --watch"
},

@@ -51,2 +51,3 @@ "husky": {

"dependencies": {
"@stripe/stripe-js": "^1.29.0",
"@types/promise-polyfill": "^6.0.3",

@@ -64,3 +65,3 @@ "fetch-ponyfill": "^6.1.0",

"lint-staged": "^9.5.0",
"np": "^6.4.0",
"np": "^3.0.4",
"prettier": "^1.19.1",

@@ -75,6 +76,7 @@ "rollup": "^1.28.0",

"tslib": "^1.10.0",
"typescript": "^3.7.4"
"typescript": "^4.7.4"
},
"publishConfig": {
"access": "public"
"access": "public",
"registry": "https://registry.npmjs.org"
},

@@ -81,0 +83,0 @@ "np": {

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