Socket
Socket
Sign inDemoInstall

@commercetools/checkout-browser-sdk

Package Overview
Dependencies
Maintainers
12
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@commercetools/checkout-browser-sdk - npm Package Compare versions

Comparing version 0.7.0-next.1 to 0.7.0

browser/sdk.js.br

2

browser/sdk.js

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

(function(o){typeof define=="function"&&define.amd?define(o):o()})(function(){"use strict";let o={};class p extends Error{constructor(c){super(`Missing field in the configuration: ${c}`),Object.setPrototypeOf(this,p.prototype)}}const M=()=>{if(!o.region&&!o.host)throw new p("region");return o.region&&o.region.startsWith("http")?o.region:o.region?`https://app.checkout.${o.region}.commercetools.com`:o.host},b=()=>o,d=(e,c=!1)=>(c&&(o={}),o={skipConfirmationPages:"skipConfirmationPages"in e?e.skipConfirmationPages:o.skipConfirmationPages,accessToken:"accessToken"in e?e.accessToken:o.accessToken,applicationId:"applicationId"in e?e.applicationId:o.applicationId,applicationKey:"applicationKey"in e?e.applicationKey:o.applicationKey,callbackUrl:"callbackUrl"in e?e.callbackUrl:o.callbackUrl,returnUrl:"returnUrl"in e?e.returnUrl:o.returnUrl,sellerId:"sellerId"in e?e.sellerId:o.sellerId,cartId:"cartId"in e?e.cartId:o.cartId,host:"host"in e?e.host:o.host,paymentReference:"paymentReference"in e?e.paymentReference:o.paymentReference,locale:"locale"in e?e.locale:o.locale,projectKey:"projectKey"in e?e.projectKey:o.projectKey,storeKey:"storeKey"in e?e.storeKey:o.storeKey,styles:"styles"in e?e.styles:o.styles,languageOverrides:"languageOverrides"in e?e.languageOverrides:o.languageOverrides,forms:"forms"in e?e.forms:o.forms,currencyLocale:"currencyLocale"in e?e.currencyLocale:o.currencyLocale,showTaxes:"showTaxes"in e?e.showTaxes:o.showTaxes,sessionId:"sessionId"in e?e.sessionId:o.sessionId,region:"region"in e?e.region:o.region,browserSdkVersion:"0.7.0-next.1"},o),v=e=>c=>{if(!e||!c)return!1;if(e==="*"||c===e)return!0;const t=e.split(":"),s=c.split(":");return!s[0]||t[0]!==s[0]?!1:v(t.slice(1).join(":"))(s.slice(1).join(":"))},E={},m=(e,c)=>{const t=`${e}_${Math.round(Math.random()*1e15)}`,s=({origin:r,data:i})=>{if(r!==window.location.origin||i.source!=="commercetoolsCheckout")return;const a=i||{};v(e)(a.type)&&c(a)};return window.addEventListener("message",s),E[t]=s,t},l=e=>window.removeEventListener("message",E[e]),n={},h=(e,c)=>{[["info","onInfo"],["warn","onWarn"],["error","onError"]].forEach(t=>{const s=t[0],r=t[1];c&&n[r]&&l(n[r]),typeof e[r]=="function"&&(n[r]&&l(n[r]),n[r]=m(`${s}:*`,e[r]))})},y=(e,c)=>{[["info","logInfo"],["warn","logWarn"],["error","logError"]].forEach(t=>{const s=t[0],r=t[1];c&&n[r]&&l(n[r]),e[r]===!0&&(n[r]&&l(n[r]),n[r]=m(`${s}:*`,function(i){i.payload!==void 0?console[s]("[ctc]",i.code,i.payload):console[s]("[ctc]",i.code)}))})},K=e=>{if(typeof e!="object")throw new Error("Bad config, please review docs");typeof e.checkoutConfig=="object"&&d(e.checkoutConfig),h(e),y(e)},I="commercetools-checkout",U="data-ctc";let u;const $=document.body.style.overflow,j=()=>{const e=document.querySelectorAll(`[${U}]`);return e.length>0&&(e[0]instanceof HTMLDivElement||e[0]instanceof HTMLSpanElement)?e[0]:null},f=()=>{if(window.commercetoolsCheckout&&window.commercetoolsCheckout.root&&window.commercetoolsCheckout.root.unmount)window.commercetoolsCheckout.root.unmount();else{const t=j();t&&(t.innerHTML="")}const c=document.getElementById(I);c&&(document.body.style.overflow=$,c.remove()),u&&window.removeEventListener("message",u)},A=e=>{u=({origin:c,data:t})=>{var s;if(c===window.location.origin){if((t==null?void 0:t.code)==="checkout_cancelled"&&f(),(t==null?void 0:t.code)==="checkout_loaded"){const r=Object.assign({},b());window.postMessage({code:"init_checkout",payload:{...r,checkoutMode:e}},window.location.origin)}if((t==null?void 0:t.code)==="checkout_completed"){f();const{id:r}=((s=t==null?void 0:t.payload)==null?void 0:s.order)||{},{callbackUrl:i,returnUrl:a}=b();a?window.location.href=`${a}?orderId=${r}`:i&&(window.location.href=`${i}?orderId=${r}`)}}},window.addEventListener("message",u)},k=async(e="complete-flow")=>{if(f(),A(e),!j()){const c=document.createElement("div");c.setAttribute("id",I),document.body.appendChild(c),document.body.style.overflow="hidden"}if(typeof window.commercetoolsCheckout=="object"&&typeof window.commercetoolsCheckout.render=="function")window.commercetoolsCheckout.render();else{const c=document.createElement("script");c.src=`${M()}/main.js`,document.head.appendChild(c)}},L={checkout:e=>{d(e),k()},checkoutFlow:e=>{if(typeof e!="object")throw new Error("Bad config, please review docs");d(e,!0),h(e,!0),y(e,!0),k()},init:K,paymentFlow:e=>{if(typeof e!="object")throw new Error("Bad config, please review docs");d(e,!0),h(e,!0),y(e,!0),k("payment-only")},subscribe:m,unsubscribe:l};function w(e){return L[e]&&L[e].apply(null,Array.prototype.slice.call(arguments,1))}window.ctc&&Array.isArray(window.ctc.queue)&&window.ctc.queue.forEach(e=>w.apply(null,e)),window.ctc&&Array.isArray(window.ctc.q)&&window.ctc.q.forEach(e=>w.apply(null,e)),window.ctc=w});
(function(o){typeof define=="function"&&define.amd?define(o):o()})(function(){"use strict";let o={};class p extends Error{constructor(c){super(`Missing field in the configuration: ${c}`),Object.setPrototypeOf(this,p.prototype)}}const M=()=>{if(!o.region&&!o.host)throw new p("region");return o.region&&o.region.startsWith("http")?o.region:o.region?`https://app.checkout.${o.region}.commercetools.com`:o.host},b=()=>o,d=(e,c=!1)=>(c&&(o={}),o={skipConfirmationPages:"skipConfirmationPages"in e?e.skipConfirmationPages:o.skipConfirmationPages,accessToken:"accessToken"in e?e.accessToken:o.accessToken,applicationId:"applicationId"in e?e.applicationId:o.applicationId,applicationKey:"applicationKey"in e?e.applicationKey:o.applicationKey,callbackUrl:"callbackUrl"in e?e.callbackUrl:o.callbackUrl,returnUrl:"returnUrl"in e?e.returnUrl:o.returnUrl,sellerId:"sellerId"in e?e.sellerId:o.sellerId,cartId:"cartId"in e?e.cartId:o.cartId,host:"host"in e?e.host:o.host,paymentReference:"paymentReference"in e?e.paymentReference:o.paymentReference,locale:"locale"in e?e.locale:o.locale,projectKey:"projectKey"in e?e.projectKey:o.projectKey,storeKey:"storeKey"in e?e.storeKey:o.storeKey,styles:"styles"in e?e.styles:o.styles,languageOverrides:"languageOverrides"in e?e.languageOverrides:o.languageOverrides,forms:"forms"in e?e.forms:o.forms,currencyLocale:"currencyLocale"in e?e.currencyLocale:o.currencyLocale,showTaxes:"showTaxes"in e?e.showTaxes:o.showTaxes,sessionId:"sessionId"in e?e.sessionId:o.sessionId,region:"region"in e?e.region:o.region,browserSdkVersion:"0.7.0"},o),E=e=>c=>{if(!e||!c)return!1;if(e==="*"||c===e)return!0;const t=e.split(":"),s=c.split(":");return!s[0]||t[0]!==s[0]?!1:E(t.slice(1).join(":"))(s.slice(1).join(":"))},v={},m=(e,c)=>{const t=`${e}_${Math.round(Math.random()*1e15)}`,s=({origin:r,data:i})=>{if(r!==window.location.origin||i.source!=="commercetoolsCheckout")return;const a=i||{};E(e)(a.type)&&c(a)};return window.addEventListener("message",s),v[t]=s,t},l=e=>window.removeEventListener("message",v[e]),n={},h=(e,c)=>{[["info","onInfo"],["warn","onWarn"],["error","onError"]].forEach(t=>{const s=t[0],r=t[1];c&&n[r]&&l(n[r]),typeof e[r]=="function"&&(n[r]&&l(n[r]),n[r]=m(`${s}:*`,e[r]))})},y=(e,c)=>{[["info","logInfo"],["warn","logWarn"],["error","logError"]].forEach(t=>{const s=t[0],r=t[1];c&&n[r]&&l(n[r]),e[r]===!0&&(n[r]&&l(n[r]),n[r]=m(`${s}:*`,function(i){i.payload!==void 0?console[s]("[ctc]",i.code,i.payload):console[s]("[ctc]",i.code)}))})},$=e=>{if(typeof e!="object")throw new Error("Bad config, please review docs");typeof e.checkoutConfig=="object"&&d(e.checkoutConfig),h(e),y(e)},I="commercetools-checkout",K="data-ctc";let u;const U=document.body.style.overflow,j=()=>{const e=document.querySelectorAll(`[${K}]`);return e.length>0&&(e[0]instanceof HTMLDivElement||e[0]instanceof HTMLSpanElement)?e[0]:null},f=()=>{if(window.commercetoolsCheckout&&window.commercetoolsCheckout.root&&window.commercetoolsCheckout.root.unmount)window.commercetoolsCheckout.root.unmount();else{const t=j();t&&(t.innerHTML="")}const c=document.getElementById(I);c&&(document.body.style.overflow=U,c.remove()),u&&window.removeEventListener("message",u)},A=e=>{u=({origin:c,data:t})=>{var s;if(c===window.location.origin){if((t==null?void 0:t.code)==="checkout_cancelled"&&f(),(t==null?void 0:t.code)==="checkout_loaded"){const r=Object.assign({},b());window.postMessage({code:"init_checkout",payload:{...r,checkoutMode:e}},window.location.origin)}if((t==null?void 0:t.code)==="checkout_completed"){f();const{id:r}=((s=t==null?void 0:t.payload)==null?void 0:s.order)||{},{callbackUrl:i,returnUrl:a}=b();a?window.location.href=`${a}?orderId=${r}`:i&&(window.location.href=`${i}?orderId=${r}`)}}},window.addEventListener("message",u)},k=async(e="complete-flow")=>{if(f(),A(e),!j()){const c=document.createElement("div");c.setAttribute("id",I),document.body.appendChild(c),document.body.style.overflow="hidden"}if(typeof window.commercetoolsCheckout=="object"&&typeof window.commercetoolsCheckout.render=="function")window.commercetoolsCheckout.render();else{const c=document.createElement("script");c.src=`${M()}/main.js`,c.onerror=()=>console.log(`[ctc] Error loading checkout script on ${c.src}`),document.head.appendChild(c)}},L={checkout:e=>{d(e),k()},checkoutFlow:e=>{if(typeof e!="object")throw new Error("Bad config, please review docs");d(e,!0),h(e,!0),y(e,!0),k()},init:$,paymentFlow:e=>{if(typeof e!="object")throw new Error("Bad config, please review docs");d(e,!0),h(e,!0),y(e,!0),k("payment-only")},subscribe:m,unsubscribe:l};function w(e){return L[e]&&L[e].apply(null,Array.prototype.slice.call(arguments,1))}window.ctc&&Array.isArray(window.ctc.queue)&&window.ctc.queue.forEach(e=>w.apply(null,e)),window.ctc&&Array.isArray(window.ctc.q)&&window.ctc.q.forEach(e=>w.apply(null,e)),window.ctc=w});

@@ -95,2 +95,3 @@ "use strict";

script.src = `${(0, config_1.getAppHost)()}/main.js`;
script.onerror = () => console.log(`[ctc] Error loading checkout script on ${script.src}`);
document.head.appendChild(script);

@@ -97,0 +98,0 @@ }

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

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

@@ -18,3 +18,3 @@ import { resolve } from 'path';

outDir: resolve(__dirname, `browser/${currentVersion ? currentVersion + '/' : ''}`),
sourcemap: currentVersion ? true : false,
sourcemap: true,
lib: {

@@ -21,0 +21,0 @@ entry: resolve(__dirname, `src/browser/sdk.ts`),

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc