Socket
Socket
Sign inDemoInstall

@commercetools/checkout-browser-sdk

Package Overview
Dependencies
2
Maintainers
12
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.2.0

5

browser/sdk.js

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

!function(){function t(t){if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function e(t,n){return(e=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,n)}function n(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}function o(t,r,c){return(o=n()?Reflect.construct:function(t,n,o){var r=[null];r.push.apply(r,n);var c=new(Function.bind.apply(t,r));return o&&e(c,o.prototype),c}).apply(null,arguments)}function r(t){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function c(t){var n="function"==typeof Map?new Map:void 0;return(c=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(t))return n.get(t);n.set(t,c)}function c(){return o(t,arguments,r(this).constructor)}return c.prototype=Object.create(t.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),e(c,t)})(t)}var i,a={},l=function(o){"use strict";!function(t,n){if("function"!=typeof n&&null!==n)throw TypeError("Super expression must either be null or a function");t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),n&&e(t,n)}(a,o);var c,i=(c=n(),function(){var e,n,o=r(a);if(c){var i=r(this).constructor;n=Reflect.construct(o,arguments,i)}else n=o.apply(this,arguments);return(e=n)&&("object"==(e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)||"function"==typeof e)?e:t(this)});function a(e){var n;return function(t,e){if(!(t instanceof e))throw TypeError("Cannot call a class as a function")}(this,a),Object.setPrototypeOf(t(n=i.call(this,"Missing field in the configuration: ".concat(e))),a.prototype),n}return a}(c(Error)),u=function(){if(!a.host)throw new l("host");return a.host},s=function(){return a},f=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e&&(a={}),a={accessToken:"accessToken"in t?t.accessToken:a.accessToken,applicationId:"applicationId"in t?t.applicationId:a.applicationId,callbackUrl:"callbackUrl"in t?t.callbackUrl:a.callbackUrl,cartId:"cartId"in t?t.cartId:a.cartId,locale:"locale"in t?t.locale:a.locale,sellerId:"sellerId"in t?t.sellerId:a.sellerId,storeKey:"storeKey"in t?t.storeKey:a.storeKey,host:"host"in t?t.host:a.host,skipShipping:"skipShipping"in t?t.skipShipping:a.skipShipping,styles:"styles"in t?t.styles:a.styles,languageOverrides:"languageOverrides"in t?t.languageOverrides:a.languageOverrides}},d="ctc-wrapper";(i||(i={})).InitCheckout="init_checkout";var p=function(t){var e=document.body.style.top;window.scrollTo({left:0,top:-1*parseInt(e||"0",10),behavior:"instant"}),document.body.style.overflow="visible";var n=document.getElementById(d);n&&n.remove(),window.removeEventListener("message",t)},y=function(t){var e=function(n){var o=n.origin,r=n.data;if(o===u()){if((null==r?void 0:r.code)==="checkout_cancelled"&&p(e),(null==r?void 0:r.code)==="checkout_loaded"){document.body.style.overflow="hidden",document.body.style.top="-".concat(window.scrollY,"px");var c=Object.assign({},s());delete c.callbackUrl,t.contentWindow.postMessage({code:i.InitCheckout,payload:c},u())}if((null==r?void 0:r.code)==="checkout_completed"){p(e);var a,l=((null==r?void 0:null===(a=r.payload)||void 0===a?void 0:a.order)||{}).id,f=s().callbackUrl;f&&(window.location.href="".concat(f,"?orderId=").concat(l))}}};window.addEventListener("message",e)},h=function(){var t=document.createElement("iframe");return y(t),t.src=u(),t.title="Checkout",t.setAttribute("id",d),t.setAttribute("style","display: none; top: 0; position: fixed; height: 100vh; width: 100vw; z-index: 100000;"),t.onload=function(){t.scrollIntoView({behavior:"smooth",block:"center"})},document.body.appendChild(t),t},v=function(t){return function(e){if(!t||!e)return!1;if("*"===t||e===t)return!0;var n=t.split(":"),o=e.split(":");return!!o[0]&&n[0]===o[0]&&v(n.slice(1).join(":"))(o.slice(1).join(":"))}},w={},b=function(t,e){var n="".concat(t,"_").concat(Math.round(1e15*Math.random())),o=function(n){var o=n.origin,r=n.data;if(o===u()){var c=r||{};v(t)(c.type)&&e(c)}};return window.addEventListener("message",o),w[n]=o,n},g=function(t){return window.removeEventListener("message",w[t])},m={},k=function(t){[["info","onInfo"],["warn","onWarn"],["error","onError"]].forEach(function(e){var n=e[0],o=e[1];"function"==typeof t[o]&&(m[o]&&g(m[o]),m[o]=b("".concat(n,":*"),t[o]))})},I=function(t){[["info","logInfo"],["warn","logWarn"],["error","logError"]].forEach(function(e){var n=e[0],o=e[1];!0===t[o]&&(m[o]&&g(m[o]),m[o]=b("".concat(n,":*"),function(t){console[n]("[ctc]",t.type,t.code,t.payload||{})}))})},E={checkout:function(t){f(t),(document.getElementById(d)||h()).style.display="block"},init:function(t){if("object"!=typeof t)throw Error("Bad config, please review docs");"object"==typeof t.checkoutConfig&&f(t.checkoutConfig),k(t),I(t)},subscribe:b,unsubscribe:g};function O(t){return E[t]&&E[t].apply(null,Array.prototype.slice.call(arguments,1))}window.ctc&&Array.isArray(window.ctc.queue)&&window.ctc.queue.forEach(function(t){return O.apply(null,t)}),window.ctc&&Array.isArray(window.ctc.q)&&window.ctc.q.forEach(function(t){return O.apply(null,t)}),window.ctc=O}();
!function(){function t(t){if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function e(t,n){return(e=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,n)}function n(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}function o(t,r,c){return(o=n()?Reflect.construct:function(t,n,o){var r=[null];r.push.apply(r,n);var c=new(Function.bind.apply(t,r));return o&&e(c,o.prototype),c}).apply(null,arguments)}function r(t){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function c(t){var n="function"==typeof Map?new Map:void 0;return(c=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(t))return n.get(t);n.set(t,c)}function c(){return o(t,arguments,r(this).constructor)}return c.prototype=Object.create(t.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),e(c,t)})(t)}var i,a={},l=/*#__PURE__*/function(o){!function(t,n){if("function"!=typeof n&&null!==n)throw TypeError("Super expression must either be null or a function");t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),n&&e(t,n)}(a,o);var c,i=(c=n(),function(){var e,n,o=r(a);if(c){var i=r(this).constructor;n=Reflect.construct(o,arguments,i)}else n=o.apply(this,arguments);return(e=n)&&("object"==(e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)||"function"==typeof e)?e:t(this)});function a(e){var n;return!function(t,e){if(!(t instanceof e))throw TypeError("Cannot call a class as a function")}(this,a),Object.setPrototypeOf(t(n=i.call(this,"Missing field in the configuration: ".concat(e))),a.prototype),n}return a}(c(Error)),u=function(){if(!a.host)throw new l("host");return a.host},s=function(){return a},f=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e&&(a={}),a={accessToken:"accessToken"in t?t.accessToken:a.accessToken,applicationId:"applicationId"in t?t.applicationId:a.applicationId,callbackUrl:"callbackUrl"in t?t.callbackUrl:a.callbackUrl,cartId:"cartId"in t?t.cartId:a.cartId,locale:"locale"in t?t.locale:a.locale,sellerId:"sellerId"in t?t.sellerId:a.sellerId,storeKey:"storeKey"in t?t.storeKey:a.storeKey,host:"host"in t?t.host:a.host,skipShipping:"skipShipping"in t?t.skipShipping:a.skipShipping,styles:"styles"in t?t.styles:a.styles,languageOverrides:"languageOverrides"in t?t.languageOverrides:a.languageOverrides,forms:"forms"in t?t.forms:a.forms,currencyLocale:"currencyLocale"in t?t.currencyLocale:a.currencyLocale}},d="ctc-wrapper";(i||(i={})).InitCheckout="init_checkout";var p=function(t){var e=document.body.style.top;window.scrollTo({left:0,top:-1*parseInt(e||"0",10),behavior:"instant"}),document.body.style.overflow="visible";var n=document.getElementById(d);n&&n.remove(),window.removeEventListener("message",t)},y=function(t){var e=function(n){var o=n.origin,r=n.data;if(o===u()){if((null==r?void 0:r.code)==="checkout_cancelled"&&p(e),(null==r?void 0:r.code)==="checkout_loaded"){document.body.style.overflow="hidden",document.body.style.top="-".concat(window.scrollY,"px");var c=Object.assign({},s());delete c.callbackUrl,t.contentWindow.postMessage({code:i.InitCheckout,payload:c},u())}if((null==r?void 0:r.code)==="checkout_completed"){p(e);var a,l=((null==r?void 0:null===(a=r.payload)||void 0===a?void 0:a.order)||{}).id,f=s().callbackUrl;f&&(window.location.href="".concat(f,"?orderId=").concat(l))}}};window.addEventListener("message",e)},h=function(){// create the iframe and append to the document body
var t=document.createElement("iframe");return y(t),t.src=u(),t.title="Checkout",t.setAttribute("id",d),t.setAttribute("style","display: none; top: 0; position: fixed; height: 100%; width: 100%; z-index: 100000;"),t.onload=function(){// scroll to the iframe
t.scrollIntoView({behavior:"smooth",block:"center"})},document.body.appendChild(t),t},v=function(t){return function(e){if(!t||!e)return!1;if("*"===t||e===t)return!0;var n=t.split(":"),o=e.split(":");return!!o[0]&&n[0]===o[0]&&v(n.slice(1).join(":"))(o.slice(1).join(":"))}},w={},b=function(t,e){var n="".concat(t,"_").concat(Math.round(1e15*Math.random())),o=function(n){var o=n.origin,r=n.data;if(o===u()){var c=r||{};v(t)(c.type)&&e(c)}};return window.addEventListener("message",o),w[n]=o,n},g=function(t){return window.removeEventListener("message",w[t])},m={},k=function(t){[["info","onInfo"],["warn","onWarn"],["error","onError"]].forEach(function(e){var n=e[0],o=e[1];"function"==typeof t[o]&&(m[o]&&g(m[o]),m[o]=b("".concat(n,":*"),t[o]))})},I=function(t){[["info","logInfo"],["warn","logWarn"],["error","logError"]].forEach(function(e){var n=e[0],o=e[1];!0===t[o]&&(m[o]&&g(m[o]),m[o]=b("".concat(n,":*"),function(t){console[n]("[ctc]",t.type,t.code,t.payload||{})}))})},E={checkout:function(t){f(t),(document.getElementById(d)||h()).style.display="block"},init:function(t){if("object"!=typeof t)throw Error("Bad config, please review docs");"object"==typeof t.checkoutConfig&&f(t.checkoutConfig),k(t),I(t)},subscribe:b,unsubscribe:g};function O(t){// eslint-disable-next-line prefer-rest-params
return E[t]&&E[t].apply(null,Array.prototype.slice.call(arguments,1))}window.ctc&&Array.isArray(window.ctc.queue)&&window.ctc.queue.forEach(function(t){return O.apply(null,t)}),window.ctc&&Array.isArray(window.ctc.q)&&window.ctc.q.forEach(function(t){return O.apply(null,t)}),window.ctc=O}();
# @commercetools/checkout-browser-sdk
## 0.2.0
### Minor Changes
- c0aa703b7: We now allow to override the locale that is used to format prices
- eb5264d48: Sellers can now customise the address form validations
## 0.1.0

@@ -4,0 +11,0 @@

2

dist/checkout.js

@@ -6,3 +6,3 @@ "use strict";

const MODAL_ID = 'ctc-wrapper';
const IFRAME_STYLES = 'display: none; top: 0; position: fixed; height: 100vh; width: 100vw; z-index: 100000;';
const IFRAME_STYLES = 'display: none; top: 0; position: fixed; height: 100%; width: 100%; z-index: 100000;';
var PostMessageCodes;

@@ -9,0 +9,0 @@ (function (PostMessageCodes) {

type Definitions = Record<string, string> | {
[key: string]: Definitions;
};
type Validation = {
disableDefault?: boolean;
required?: {
deactivate?: boolean;
value?: boolean;
message?: string;
};
pattern?: {
deactivate?: boolean;
value?: RegExp;
message?: string;
};
custom?: {
deactivate?: boolean;
message?: string;
};
minLength?: {
deactivate?: boolean;
value?: number;
message?: string;
};
maxLength?: {
deactivate?: boolean;
value?: number;
message?: string;
};
};
type Field = {
label?: string;
validation: Validation;
};
type Forms = {
default: {
address?: {
disableDefaultValidations?: boolean;
fields: {
firstName?: Field;
lastName?: Field;
email?: Field;
country?: Field;
streetName?: Field;
postalCode?: Field;
city?: Field;
phone?: Field;
state?: Field;
};
};
};
};
export type CheckoutData = {

@@ -16,2 +65,4 @@ accessToken?: string;

languageOverrides?: Definitions;
forms?: Forms;
currencyLocale?: string;
};

@@ -18,0 +69,0 @@ export declare class MissingConfigurationField extends Error {

@@ -38,2 +38,4 @@ "use strict";

: checkoutConfig.languageOverrides,
forms: 'forms' in newConfig ? newConfig.forms : checkoutConfig.forms,
currencyLocale: 'currencyLocale' in newConfig ? newConfig.currencyLocale : checkoutConfig.currencyLocale,
};

@@ -40,0 +42,0 @@ return checkoutConfig;

{
"private": false,
"name": "@commercetools/checkout-browser-sdk",
"version": "0.1.0",
"version": "0.2.0",
"main": "dist/index.js",

@@ -6,0 +6,0 @@ "types": "dist/index.d.ts",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc