New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@stripe/react-stripe-js

Package Overview
Dependencies
Maintainers
20
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stripe/react-stripe-js - npm Package Compare versions

Comparing version

to
3.1.1

4

dist/react-stripe.js

@@ -332,3 +332,3 @@ 'use strict';

name: 'react-stripe-js',
version: "3.0.0"
version: "3.1.0"
});

@@ -338,3 +338,3 @@

name: 'react-stripe-js',
version: "3.0.0",
version: "3.1.0",
url: 'https://stripe.com/docs/stripe-js/react'

@@ -341,0 +341,0 @@ });

@@ -441,3 +441,3 @@ (function (global, factory) {

name: 'react-stripe-js',
version: "3.0.0"
version: "3.1.0"
});

@@ -447,3 +447,3 @@

name: 'react-stripe-js',
version: "3.0.0",
version: "3.1.0",
url: 'https://stripe.com/docs/stripe-js/react'

@@ -450,0 +450,0 @@ });

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactStripe={},e.React)}(this,(function(e,t){"use strict";function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function r(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach((function(t){c(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},c=Object.keys(e);for(r=0;r<c.length;r++)n=c[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(r=0;r<c.length;r++)n=c[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==n)return;var r,o,c=[],u=!0,i=!1;try{for(n=n.call(e);!(u=(r=n.next()).done)&&(c.push(r.value),!t||c.length!==t);u=!0);}catch(e){i=!0,o=e}finally{try{u||null==n.return||n.return()}finally{if(i)throw o}}return c}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return a(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function s(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var l,p,f,d,h={exports:{}};h.exports=function(){if(d)return f;d=1;var e=p?l:(p=1,l="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");function t(){}function n(){}return n.resetWarningCache=t,f=function(){function r(t,n,r,o,c,u){if(u!==e){var i=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw i.name="Invariant Violation",i}}function o(){return r}r.isRequired=r;var c={array:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:o,element:r,elementType:r,instanceOf:o,node:r,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:t};return c.PropTypes=c,c}}()();var m=s(h.exports),y=function(e,n,r){var o=!!r,c=t.useRef(r);t.useEffect((function(){c.current=r}),[r]),t.useEffect((function(){if(!o||!e)return function(){};var t=function(){c.current&&c.current.apply(c,arguments)};return e.on(n,t),function(){e.off(n,t)}}),[o,n,e,c])},v=function(e){var n=t.useRef(e);return t.useEffect((function(){n.current=e}),[e]),n.current},g=function(e){return null!==e&&"object"===o(e)},C="[object Object]",E=function e(t,n){if(!g(t)||!g(n))return t===n;var r=Array.isArray(t);if(r!==Array.isArray(n))return!1;var o=Object.prototype.toString.call(t)===C;if(o!==(Object.prototype.toString.call(n)===C))return!1;if(!o&&!r)return t===n;var c=Object.keys(t),u=Object.keys(n);if(c.length!==u.length)return!1;for(var i={},a=0;a<c.length;a+=1)i[c[a]]=!0;for(var s=0;s<u.length;s+=1)i[u[s]]=!0;var l=Object.keys(i);if(l.length!==c.length)return!1;var p=t,f=n;return l.every((function(t){return e(p[t],f[t])}))},b=function(e,t,n){return g(e)?Object.keys(e).reduce((function(o,u){var i=!g(t)||!E(e[u],t[u]);return n.includes(u)?(i&&console.warn("Unsupported prop change: options.".concat(u," is not a mutable property.")),o):i?r(r({},o||{}),{},c({},u,e[u])):o}),null):null},k="Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",S=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k;if(null===e||g(t=e)&&"function"==typeof t.elements&&"function"==typeof t.createToken&&"function"==typeof t.createPaymentMethod&&"function"==typeof t.confirmCardPayment)return e;throw new Error(n)},P=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k;if(function(e){return g(e)&&"function"==typeof e.then}(e))return{tag:"async",stripePromise:Promise.resolve(e).then((function(e){return S(e,t)}))};var n=S(e,t);return null===n?{tag:"empty"}:{tag:"sync",stripe:n}},w=function(e){e&&e._registerWrapper&&e.registerAppInfo&&(e._registerWrapper({name:"react-stripe-js",version:"3.0.0"}),e.registerAppInfo({name:"react-stripe-js",version:"3.0.0",url:"https://stripe.com/docs/stripe-js/react"}))},O=t.createContext(null);O.displayName="ElementsContext";var j=function(e,t){if(!e)throw new Error("Could not find Elements context; You need to wrap the part of your app that ".concat(t," in an <Elements> provider."));return e},x=function(e){var n=e.stripe,r=e.options,o=e.children,c=t.useMemo((function(){return P(n)}),[n]),u=i(t.useState((function(){return{stripe:"sync"===c.tag?c.stripe:null,elements:"sync"===c.tag?c.stripe.elements(r):null}})),2),a=u[0],s=u[1];t.useEffect((function(){var e=!0,t=function(e){s((function(t){return t.stripe?t:{stripe:e,elements:e.elements(r)}}))};return"async"!==c.tag||a.stripe?"sync"!==c.tag||a.stripe||t(c.stripe):c.stripePromise.then((function(n){n&&e&&t(n)})),function(){e=!1}}),[c,a,r]);var l=v(n);t.useEffect((function(){null!==l&&l!==n&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.")}),[l,n]);var p=v(r);return t.useEffect((function(){if(a.elements){var e=b(r,p,["clientSecret","fonts"]);e&&a.elements.update(e)}}),[r,p,a.elements]),t.useEffect((function(){w(a.stripe)}),[a.stripe]),t.createElement(O.Provider,{value:a},o)};x.propTypes={stripe:m.any,options:m.object};var A=function(e){var n=t.useContext(O);return j(n,e)},R=function(e){return(0,e.children)(A("mounts <ElementsConsumer>"))};R.propTypes={children:m.func.isRequired};var I=["on","session"],N=t.createContext(null);N.displayName="CheckoutSdkContext";var T=function(e,t){if(!e)throw new Error("Could not find CheckoutProvider context; You need to wrap the part of your app that ".concat(t," in an <CheckoutProvider> provider."));return e},U=t.createContext(null);U.displayName="CheckoutContext";var B=function(e){var n=e.stripe,o=e.options,c=e.children,a=t.useMemo((function(){return P(n,"Invalid prop `stripe` supplied to `CheckoutProvider`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.")}),[n]),s=i(t.useState(null),2),l=s[0],p=s[1],f=i(t.useState((function(){return{stripe:"sync"===a.tag?a.stripe:null,checkoutSdk:null}})),2),d=f[0],h=f[1],m=function(e,t){h((function(n){return n.stripe&&n.checkoutSdk?n:{stripe:e,checkoutSdk:t}}))},y=t.useRef(!1);t.useEffect((function(){var e=!0;return"async"!==a.tag||d.stripe?"sync"===a.tag&&a.stripe&&!y.current&&(y.current=!0,a.stripe.initCheckout(o).then((function(e){e&&(m(a.stripe,e),e.on("change",p))}))):a.stripePromise.then((function(t){t&&e&&!y.current&&(y.current=!0,t.initCheckout(o).then((function(e){e&&(m(t,e),e.on("change",p))})))})),function(){e=!1}}),[a,d,o,p]);var C=v(n);t.useEffect((function(){null!==C&&C!==n&&console.warn("Unsupported prop change on CheckoutProvider: You cannot change the `stripe` prop after setting it.")}),[C,n]);var b=v(o);t.useEffect((function(){var e,t;if(d.checkoutSdk){!o.clientSecret||g(b)||E(o.clientSecret,b.clientSecret)||console.warn("Unsupported prop change: options.clientSecret is not a mutable property.");var n=null==b||null===(e=b.elementsOptions)||void 0===e?void 0:e.appearance,r=null==o||null===(t=o.elementsOptions)||void 0===t?void 0:t.appearance;r&&!E(r,n)&&d.checkoutSdk.changeAppearance(r)}}),[o,b,d.checkoutSdk]),t.useEffect((function(){w(d.stripe)}),[d.stripe]);var k=t.useMemo((function(){return e=d.checkoutSdk,t=l,e?(e.on,e.session,r(r({},u(e,I)),t||e.session())):null;var e,t}),[d.checkoutSdk,l]);return d.checkoutSdk?t.createElement(N.Provider,{value:d},t.createElement(U.Provider,{value:k},c)):null};B.propTypes={stripe:m.any,options:m.shape({clientSecret:m.string.isRequired,elementsOptions:m.object}).isRequired};var M=function(e){var n=t.useContext(N),r=t.useContext(O);if(n&&r)throw new Error("You cannot wrap the part of your app that ".concat(e," in both <CheckoutProvider> and <Elements> providers."));return n?T(n,e):j(r,e)},Y=function(e,n){var r,o="".concat((r=e).charAt(0).toUpperCase()+r.slice(1),"Element"),c=n?function(e){M("mounts <".concat(o,">"));var n=e.id,r=e.className;return t.createElement("div",{id:n,className:r})}:function(n){var r,c=n.id,u=n.className,a=n.options,s=void 0===a?{}:a,l=n.onBlur,p=n.onFocus,f=n.onReady,d=n.onChange,h=n.onEscape,m=n.onClick,g=n.onLoadError,C=n.onLoaderStart,E=n.onNetworksChange,k=n.onConfirm,S=n.onCancel,P=n.onShippingAddressChange,w=n.onShippingRateChange,O=M("mounts <".concat(o,">")),j="elements"in O?O.elements:null,x="checkoutSdk"in O?O.checkoutSdk:null,A=i(t.useState(null),2),R=A[0],I=A[1],N=t.useRef(null),T=t.useRef(null);y(R,"blur",l),y(R,"focus",p),y(R,"escape",h),y(R,"click",m),y(R,"loaderror",g),y(R,"loaderstart",C),y(R,"networkschange",E),y(R,"confirm",k),y(R,"cancel",S),y(R,"shippingaddresschange",P),y(R,"shippingratechange",w),y(R,"change",d),f&&(r="expressCheckout"===e?f:function(){f(R)}),y(R,"ready",r),t.useLayoutEffect((function(){if(null===N.current&&null!==T.current&&(j||x)){var t=null;x?t=x.createElement(e,s):j&&(t=j.create(e,s)),N.current=t,I(t),t&&t.mount(T.current)}}),[j,x,s]);var U=v(s);return t.useEffect((function(){if(N.current){var e=b(s,U,["paymentRequest"]);e&&"update"in N.current&&N.current.update(e)}}),[s,U]),t.useLayoutEffect((function(){return function(){if(N.current&&"function"==typeof N.current.destroy)try{N.current.destroy(),N.current=null}catch(e){}}}),[]),t.createElement("div",{id:c,className:u,ref:T})};return c.propTypes={id:m.string,className:m.string,onChange:m.func,onBlur:m.func,onFocus:m.func,onReady:m.func,onEscape:m.func,onClick:m.func,onLoadError:m.func,onLoaderStart:m.func,onNetworksChange:m.func,onConfirm:m.func,onCancel:m.func,onShippingAddressChange:m.func,onShippingRateChange:m.func,options:m.object},c.displayName=o,c.__elementType=e,c},_="undefined"==typeof window,L=t.createContext(null);L.displayName="EmbeddedCheckoutProviderContext";var D=function(){var e=t.useContext(L);if(!e)throw new Error("<EmbeddedCheckout> must be used within <EmbeddedCheckoutProvider>");return e},q=_?function(e){var n=e.id,r=e.className;return D(),t.createElement("div",{id:n,className:r})}:function(e){var n=e.id,r=e.className,o=D().embeddedCheckout,c=t.useRef(!1),u=t.useRef(null);return t.useLayoutEffect((function(){return!c.current&&o&&null!==u.current&&(o.mount(u.current),c.current=!0),function(){if(c.current&&o)try{o.unmount(),c.current=!1}catch(e){}}}),[o]),t.createElement("div",{ref:u,id:n,className:r})},W=Y("auBankAccount",_),F=Y("card",_),H=Y("cardNumber",_),V=Y("cardExpiry",_),$=Y("cardCvc",_),z=Y("fpxBank",_),G=Y("iban",_),J=Y("idealBank",_),K=Y("p24Bank",_),Q=Y("epsBank",_),X=Y("payment",_),Z=Y("expressCheckout",_),ee=Y("currencySelector",_),te=Y("paymentRequestButton",_),ne=Y("linkAuthentication",_),re=Y("address",_),oe=Y("shippingAddress",_),ce=Y("paymentMethodMessaging",_),ue=Y("affirmMessage",_),ie=Y("afterpayClearpayMessage",_);e.AddressElement=re,e.AffirmMessageElement=ue,e.AfterpayClearpayMessageElement=ie,e.AuBankAccountElement=W,e.CardCvcElement=$,e.CardElement=F,e.CardExpiryElement=V,e.CardNumberElement=H,e.CheckoutProvider=B,e.CurrencySelectorElement=ee,e.Elements=x,e.ElementsConsumer=R,e.EmbeddedCheckout=q,e.EmbeddedCheckoutProvider=function(e){var n=e.stripe,r=e.options,o=e.children,c=t.useMemo((function(){return P(n,"Invalid prop `stripe` supplied to `EmbeddedCheckoutProvider`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.")}),[n]),u=t.useRef(null),a=t.useRef(null),s=i(t.useState({embeddedCheckout:null}),2),l=s[0],p=s[1];t.useEffect((function(){if(!a.current&&!u.current){var e=function(e){a.current||u.current||(a.current=e,u.current=a.current.initEmbeddedCheckout(r).then((function(e){p({embeddedCheckout:e})})))};"async"!==c.tag||a.current||!r.clientSecret&&!r.fetchClientSecret?"sync"!==c.tag||a.current||!r.clientSecret&&!r.fetchClientSecret||e(c.stripe):c.stripePromise.then((function(t){t&&e(t)}))}}),[c,r,l,a]),t.useEffect((function(){return function(){l.embeddedCheckout?(u.current=null,l.embeddedCheckout.destroy()):u.current&&u.current.then((function(){u.current=null,l.embeddedCheckout&&l.embeddedCheckout.destroy()}))}}),[l.embeddedCheckout]),t.useEffect((function(){w(a)}),[a]);var f=v(n);t.useEffect((function(){null!==f&&f!==n&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the `stripe` prop after setting it.")}),[f,n]);var d=v(r);return t.useEffect((function(){null!=d&&(null!=r?(void 0===r.clientSecret&&void 0===r.fetchClientSecret&&console.warn("Invalid props passed to EmbeddedCheckoutProvider: You must provide one of either `options.fetchClientSecret` or `options.clientSecret`."),null!=d.clientSecret&&r.clientSecret!==d.clientSecret&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the client secret after setting it. Unmount and create a new instance of EmbeddedCheckoutProvider instead."),null!=d.fetchClientSecret&&r.fetchClientSecret!==d.fetchClientSecret&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change fetchClientSecret after setting it. Unmount and create a new instance of EmbeddedCheckoutProvider instead."),null!=d.onComplete&&r.onComplete!==d.onComplete&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onComplete option after setting it."),null!=d.onShippingDetailsChange&&r.onShippingDetailsChange!==d.onShippingDetailsChange&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onShippingDetailsChange option after setting it."),null!=d.onLineItemsChange&&r.onLineItemsChange!==d.onLineItemsChange&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onLineItemsChange option after setting it.")):console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot unset options after setting them."))}),[d,r]),t.createElement(L.Provider,{value:l},o)},e.EpsBankElement=Q,e.ExpressCheckoutElement=Z,e.FpxBankElement=z,e.IbanElement=G,e.IdealBankElement=J,e.LinkAuthenticationElement=ne,e.P24BankElement=K,e.PaymentElement=X,e.PaymentMethodMessagingElement=ce,e.PaymentRequestButtonElement=te,e.ShippingAddressElement=oe,e.useCheckout=function(){!function(e){var n=t.useContext(N);T(n,e)}("calls useCheckout()");var e=t.useContext(U);if(!e)throw new Error("Could not find Checkout Context; You need to wrap the part of your app that calls useCheckout() in an <CheckoutProvider> provider.");return e},e.useElements=function(){return A("calls useElements()").elements},e.useStripe=function(){return M("calls useStripe()").stripe}}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactStripe={},e.React)}(this,(function(e,t){"use strict";function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function r(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach((function(t){c(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},c=Object.keys(e);for(r=0;r<c.length;r++)n=c[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(r=0;r<c.length;r++)n=c[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==n)return;var r,o,c=[],u=!0,i=!1;try{for(n=n.call(e);!(u=(r=n.next()).done)&&(c.push(r.value),!t||c.length!==t);u=!0);}catch(e){i=!0,o=e}finally{try{u||null==n.return||n.return()}finally{if(i)throw o}}return c}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return a(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function s(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var l,p,f,d,h={exports:{}};h.exports=function(){if(d)return f;d=1;var e=p?l:(p=1,l="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");function t(){}function n(){}return n.resetWarningCache=t,f=function(){function r(t,n,r,o,c,u){if(u!==e){var i=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw i.name="Invariant Violation",i}}function o(){return r}r.isRequired=r;var c={array:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:o,element:r,elementType:r,instanceOf:o,node:r,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:t};return c.PropTypes=c,c}}()();var m=s(h.exports),y=function(e,n,r){var o=!!r,c=t.useRef(r);t.useEffect((function(){c.current=r}),[r]),t.useEffect((function(){if(!o||!e)return function(){};var t=function(){c.current&&c.current.apply(c,arguments)};return e.on(n,t),function(){e.off(n,t)}}),[o,n,e,c])},v=function(e){var n=t.useRef(e);return t.useEffect((function(){n.current=e}),[e]),n.current},g=function(e){return null!==e&&"object"===o(e)},C="[object Object]",E=function e(t,n){if(!g(t)||!g(n))return t===n;var r=Array.isArray(t);if(r!==Array.isArray(n))return!1;var o=Object.prototype.toString.call(t)===C;if(o!==(Object.prototype.toString.call(n)===C))return!1;if(!o&&!r)return t===n;var c=Object.keys(t),u=Object.keys(n);if(c.length!==u.length)return!1;for(var i={},a=0;a<c.length;a+=1)i[c[a]]=!0;for(var s=0;s<u.length;s+=1)i[u[s]]=!0;var l=Object.keys(i);if(l.length!==c.length)return!1;var p=t,f=n;return l.every((function(t){return e(p[t],f[t])}))},b=function(e,t,n){return g(e)?Object.keys(e).reduce((function(o,u){var i=!g(t)||!E(e[u],t[u]);return n.includes(u)?(i&&console.warn("Unsupported prop change: options.".concat(u," is not a mutable property.")),o):i?r(r({},o||{}),{},c({},u,e[u])):o}),null):null},k="Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",S=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k;if(null===e||g(t=e)&&"function"==typeof t.elements&&"function"==typeof t.createToken&&"function"==typeof t.createPaymentMethod&&"function"==typeof t.confirmCardPayment)return e;throw new Error(n)},P=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k;if(function(e){return g(e)&&"function"==typeof e.then}(e))return{tag:"async",stripePromise:Promise.resolve(e).then((function(e){return S(e,t)}))};var n=S(e,t);return null===n?{tag:"empty"}:{tag:"sync",stripe:n}},w=function(e){e&&e._registerWrapper&&e.registerAppInfo&&(e._registerWrapper({name:"react-stripe-js",version:"3.1.0"}),e.registerAppInfo({name:"react-stripe-js",version:"3.1.0",url:"https://stripe.com/docs/stripe-js/react"}))},O=t.createContext(null);O.displayName="ElementsContext";var j=function(e,t){if(!e)throw new Error("Could not find Elements context; You need to wrap the part of your app that ".concat(t," in an <Elements> provider."));return e},x=function(e){var n=e.stripe,r=e.options,o=e.children,c=t.useMemo((function(){return P(n)}),[n]),u=i(t.useState((function(){return{stripe:"sync"===c.tag?c.stripe:null,elements:"sync"===c.tag?c.stripe.elements(r):null}})),2),a=u[0],s=u[1];t.useEffect((function(){var e=!0,t=function(e){s((function(t){return t.stripe?t:{stripe:e,elements:e.elements(r)}}))};return"async"!==c.tag||a.stripe?"sync"!==c.tag||a.stripe||t(c.stripe):c.stripePromise.then((function(n){n&&e&&t(n)})),function(){e=!1}}),[c,a,r]);var l=v(n);t.useEffect((function(){null!==l&&l!==n&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.")}),[l,n]);var p=v(r);return t.useEffect((function(){if(a.elements){var e=b(r,p,["clientSecret","fonts"]);e&&a.elements.update(e)}}),[r,p,a.elements]),t.useEffect((function(){w(a.stripe)}),[a.stripe]),t.createElement(O.Provider,{value:a},o)};x.propTypes={stripe:m.any,options:m.object};var A=function(e){var n=t.useContext(O);return j(n,e)},R=function(e){return(0,e.children)(A("mounts <ElementsConsumer>"))};R.propTypes={children:m.func.isRequired};var I=["on","session"],N=t.createContext(null);N.displayName="CheckoutSdkContext";var T=function(e,t){if(!e)throw new Error("Could not find CheckoutProvider context; You need to wrap the part of your app that ".concat(t," in an <CheckoutProvider> provider."));return e},U=t.createContext(null);U.displayName="CheckoutContext";var B=function(e){var n=e.stripe,o=e.options,c=e.children,a=t.useMemo((function(){return P(n,"Invalid prop `stripe` supplied to `CheckoutProvider`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.")}),[n]),s=i(t.useState(null),2),l=s[0],p=s[1],f=i(t.useState((function(){return{stripe:"sync"===a.tag?a.stripe:null,checkoutSdk:null}})),2),d=f[0],h=f[1],m=function(e,t){h((function(n){return n.stripe&&n.checkoutSdk?n:{stripe:e,checkoutSdk:t}}))},y=t.useRef(!1);t.useEffect((function(){var e=!0;return"async"!==a.tag||d.stripe?"sync"===a.tag&&a.stripe&&!y.current&&(y.current=!0,a.stripe.initCheckout(o).then((function(e){e&&(m(a.stripe,e),e.on("change",p))}))):a.stripePromise.then((function(t){t&&e&&!y.current&&(y.current=!0,t.initCheckout(o).then((function(e){e&&(m(t,e),e.on("change",p))})))})),function(){e=!1}}),[a,d,o,p]);var C=v(n);t.useEffect((function(){null!==C&&C!==n&&console.warn("Unsupported prop change on CheckoutProvider: You cannot change the `stripe` prop after setting it.")}),[C,n]);var b=v(o);t.useEffect((function(){var e,t;if(d.checkoutSdk){!o.clientSecret||g(b)||E(o.clientSecret,b.clientSecret)||console.warn("Unsupported prop change: options.clientSecret is not a mutable property.");var n=null==b||null===(e=b.elementsOptions)||void 0===e?void 0:e.appearance,r=null==o||null===(t=o.elementsOptions)||void 0===t?void 0:t.appearance;r&&!E(r,n)&&d.checkoutSdk.changeAppearance(r)}}),[o,b,d.checkoutSdk]),t.useEffect((function(){w(d.stripe)}),[d.stripe]);var k=t.useMemo((function(){return e=d.checkoutSdk,t=l,e?(e.on,e.session,r(r({},u(e,I)),t||e.session())):null;var e,t}),[d.checkoutSdk,l]);return d.checkoutSdk?t.createElement(N.Provider,{value:d},t.createElement(U.Provider,{value:k},c)):null};B.propTypes={stripe:m.any,options:m.shape({clientSecret:m.string.isRequired,elementsOptions:m.object}).isRequired};var M=function(e){var n=t.useContext(N),r=t.useContext(O);if(n&&r)throw new Error("You cannot wrap the part of your app that ".concat(e," in both <CheckoutProvider> and <Elements> providers."));return n?T(n,e):j(r,e)},Y=function(e,n){var r,o="".concat((r=e).charAt(0).toUpperCase()+r.slice(1),"Element"),c=n?function(e){M("mounts <".concat(o,">"));var n=e.id,r=e.className;return t.createElement("div",{id:n,className:r})}:function(n){var r,c=n.id,u=n.className,a=n.options,s=void 0===a?{}:a,l=n.onBlur,p=n.onFocus,f=n.onReady,d=n.onChange,h=n.onEscape,m=n.onClick,g=n.onLoadError,C=n.onLoaderStart,E=n.onNetworksChange,k=n.onConfirm,S=n.onCancel,P=n.onShippingAddressChange,w=n.onShippingRateChange,O=M("mounts <".concat(o,">")),j="elements"in O?O.elements:null,x="checkoutSdk"in O?O.checkoutSdk:null,A=i(t.useState(null),2),R=A[0],I=A[1],N=t.useRef(null),T=t.useRef(null);y(R,"blur",l),y(R,"focus",p),y(R,"escape",h),y(R,"click",m),y(R,"loaderror",g),y(R,"loaderstart",C),y(R,"networkschange",E),y(R,"confirm",k),y(R,"cancel",S),y(R,"shippingaddresschange",P),y(R,"shippingratechange",w),y(R,"change",d),f&&(r="expressCheckout"===e?f:function(){f(R)}),y(R,"ready",r),t.useLayoutEffect((function(){if(null===N.current&&null!==T.current&&(j||x)){var t=null;x?t=x.createElement(e,s):j&&(t=j.create(e,s)),N.current=t,I(t),t&&t.mount(T.current)}}),[j,x,s]);var U=v(s);return t.useEffect((function(){if(N.current){var e=b(s,U,["paymentRequest"]);e&&"update"in N.current&&N.current.update(e)}}),[s,U]),t.useLayoutEffect((function(){return function(){if(N.current&&"function"==typeof N.current.destroy)try{N.current.destroy(),N.current=null}catch(e){}}}),[]),t.createElement("div",{id:c,className:u,ref:T})};return c.propTypes={id:m.string,className:m.string,onChange:m.func,onBlur:m.func,onFocus:m.func,onReady:m.func,onEscape:m.func,onClick:m.func,onLoadError:m.func,onLoaderStart:m.func,onNetworksChange:m.func,onConfirm:m.func,onCancel:m.func,onShippingAddressChange:m.func,onShippingRateChange:m.func,options:m.object},c.displayName=o,c.__elementType=e,c},_="undefined"==typeof window,L=t.createContext(null);L.displayName="EmbeddedCheckoutProviderContext";var D=function(){var e=t.useContext(L);if(!e)throw new Error("<EmbeddedCheckout> must be used within <EmbeddedCheckoutProvider>");return e},q=_?function(e){var n=e.id,r=e.className;return D(),t.createElement("div",{id:n,className:r})}:function(e){var n=e.id,r=e.className,o=D().embeddedCheckout,c=t.useRef(!1),u=t.useRef(null);return t.useLayoutEffect((function(){return!c.current&&o&&null!==u.current&&(o.mount(u.current),c.current=!0),function(){if(c.current&&o)try{o.unmount(),c.current=!1}catch(e){}}}),[o]),t.createElement("div",{ref:u,id:n,className:r})},W=Y("auBankAccount",_),F=Y("card",_),H=Y("cardNumber",_),V=Y("cardExpiry",_),$=Y("cardCvc",_),z=Y("fpxBank",_),G=Y("iban",_),J=Y("idealBank",_),K=Y("p24Bank",_),Q=Y("epsBank",_),X=Y("payment",_),Z=Y("expressCheckout",_),ee=Y("currencySelector",_),te=Y("paymentRequestButton",_),ne=Y("linkAuthentication",_),re=Y("address",_),oe=Y("shippingAddress",_),ce=Y("paymentMethodMessaging",_),ue=Y("affirmMessage",_),ie=Y("afterpayClearpayMessage",_);e.AddressElement=re,e.AffirmMessageElement=ue,e.AfterpayClearpayMessageElement=ie,e.AuBankAccountElement=W,e.CardCvcElement=$,e.CardElement=F,e.CardExpiryElement=V,e.CardNumberElement=H,e.CheckoutProvider=B,e.CurrencySelectorElement=ee,e.Elements=x,e.ElementsConsumer=R,e.EmbeddedCheckout=q,e.EmbeddedCheckoutProvider=function(e){var n=e.stripe,r=e.options,o=e.children,c=t.useMemo((function(){return P(n,"Invalid prop `stripe` supplied to `EmbeddedCheckoutProvider`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.")}),[n]),u=t.useRef(null),a=t.useRef(null),s=i(t.useState({embeddedCheckout:null}),2),l=s[0],p=s[1];t.useEffect((function(){if(!a.current&&!u.current){var e=function(e){a.current||u.current||(a.current=e,u.current=a.current.initEmbeddedCheckout(r).then((function(e){p({embeddedCheckout:e})})))};"async"!==c.tag||a.current||!r.clientSecret&&!r.fetchClientSecret?"sync"!==c.tag||a.current||!r.clientSecret&&!r.fetchClientSecret||e(c.stripe):c.stripePromise.then((function(t){t&&e(t)}))}}),[c,r,l,a]),t.useEffect((function(){return function(){l.embeddedCheckout?(u.current=null,l.embeddedCheckout.destroy()):u.current&&u.current.then((function(){u.current=null,l.embeddedCheckout&&l.embeddedCheckout.destroy()}))}}),[l.embeddedCheckout]),t.useEffect((function(){w(a)}),[a]);var f=v(n);t.useEffect((function(){null!==f&&f!==n&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the `stripe` prop after setting it.")}),[f,n]);var d=v(r);return t.useEffect((function(){null!=d&&(null!=r?(void 0===r.clientSecret&&void 0===r.fetchClientSecret&&console.warn("Invalid props passed to EmbeddedCheckoutProvider: You must provide one of either `options.fetchClientSecret` or `options.clientSecret`."),null!=d.clientSecret&&r.clientSecret!==d.clientSecret&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the client secret after setting it. Unmount and create a new instance of EmbeddedCheckoutProvider instead."),null!=d.fetchClientSecret&&r.fetchClientSecret!==d.fetchClientSecret&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change fetchClientSecret after setting it. Unmount and create a new instance of EmbeddedCheckoutProvider instead."),null!=d.onComplete&&r.onComplete!==d.onComplete&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onComplete option after setting it."),null!=d.onShippingDetailsChange&&r.onShippingDetailsChange!==d.onShippingDetailsChange&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onShippingDetailsChange option after setting it."),null!=d.onLineItemsChange&&r.onLineItemsChange!==d.onLineItemsChange&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onLineItemsChange option after setting it.")):console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot unset options after setting them."))}),[d,r]),t.createElement(L.Provider,{value:l},o)},e.EpsBankElement=Q,e.ExpressCheckoutElement=Z,e.FpxBankElement=z,e.IbanElement=G,e.IdealBankElement=J,e.LinkAuthenticationElement=ne,e.P24BankElement=K,e.PaymentElement=X,e.PaymentMethodMessagingElement=ce,e.PaymentRequestButtonElement=te,e.ShippingAddressElement=oe,e.useCheckout=function(){!function(e){var n=t.useContext(N);T(n,e)}("calls useCheckout()");var e=t.useContext(U);if(!e)throw new Error("Could not find Checkout Context; You need to wrap the part of your app that calls useCheckout() in an <CheckoutProvider> provider.");return e},e.useElements=function(){return A("calls useElements()").elements},e.useStripe=function(){return M("calls useStripe()").stripe}}));
{
"name": "@stripe/react-stripe-js",
"version": "3.1.0",
"version": "3.1.1",
"description": "React components for Stripe.js and Stripe Elements",

@@ -112,5 +112,5 @@ "main": "dist/react-stripe.js",

"@stripe/stripe-js": "^1.44.1 || ^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0",
"react": ">=16.8.0 && <=^19.0.0",
"react-dom": ">=16.8.0 && <=^19.0.0"
"react": ">=16.8.0 <20.0.0",
"react-dom": ">=16.8.0 <20.0.0"
}
}

Sorry, the diff of this file is not supported yet