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

@dintero/discounts-web-sdk

Package Overview
Dependencies
Maintainers
4
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dintero/discounts-web-sdk - npm Package Compare versions

Comparing version 0.2.8 to 0.2.9

8

dist/dintero-discounts-web-sdk.cjs.dev.js

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

name: "@dintero/discounts-web-sdk",
version: "0.2.8",
version: "0.2.9",
description: "Dintero Discounts SDK for web frontends",

@@ -606,6 +606,6 @@ main: "dist/dintero-discounts-web-sdk.cjs.js",

"@semantic-release/git": "10.0.1",
"happy-dom": "14.4.0",
"happy-dom": "14.7.1",
prettier: "3.2.5",
"semantic-release": "23.0.7",
typescript: "5.4.3",
"semantic-release": "23.0.8",
typescript: "5.4.4",
vitest: "1.4.0"

@@ -612,0 +612,0 @@ }

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

name: "@dintero/discounts-web-sdk",
version: "0.2.8",
version: "0.2.9",
description: "Dintero Discounts SDK for web frontends",

@@ -606,6 +606,6 @@ main: "dist/dintero-discounts-web-sdk.cjs.js",

"@semantic-release/git": "10.0.1",
"happy-dom": "14.4.0",
"happy-dom": "14.7.1",
prettier: "3.2.5",
"semantic-release": "23.0.7",
typescript: "5.4.3",
"semantic-release": "23.0.8",
typescript: "5.4.4",
vitest: "1.4.0"

@@ -612,0 +612,0 @@ }

@@ -567,3 +567,3 @@ const createElement = options => {

name: "@dintero/discounts-web-sdk",
version: "0.2.8",
version: "0.2.9",
description: "Dintero Discounts SDK for web frontends",

@@ -602,6 +602,6 @@ main: "dist/dintero-discounts-web-sdk.cjs.js",

"@semantic-release/git": "10.0.1",
"happy-dom": "14.4.0",
"happy-dom": "14.7.1",
prettier: "3.2.5",
"semantic-release": "23.0.7",
typescript: "5.4.3",
"semantic-release": "23.0.8",
typescript: "5.4.4",
vitest: "1.4.0"

@@ -608,0 +608,0 @@ }

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

!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((n="undefined"!=typeof globalThis?globalThis:n||self).discounts={})}(this,(function(n){"use strict";const e=n=>{const e=document.createElement(n.tag);return n.attributes&&r(e,n.attributes),n.handlers&&i(e,n.handlers),n.styles&&t(e,n.styles,n.theme),n.innerHTML&&(e.innerHTML=n.innerHTML),e},t=(n,e,t)=>{e.forEach((e=>{const r="dintero-deals-"+(n=>{let e=0;for(var t=0;t<n.length;t++)e=(e<<5)-e+n.charCodeAt(t),e&=e;return e.toString(36)})(e("dintero-deals",t));((n,e)=>{n.className.split(" ").includes(e)||(n.className=n.className+" "+e)})(n,r);if(!document.querySelector(`[data-css-hash=${r}]`)){const n=document.createElement("style");n.innerHTML=e(r,t),n.setAttribute("data-css-hash",r),document.head.appendChild(n)}}))},r=(n,e)=>{Object.keys(e).forEach((t=>{n.setAttribute(t,e[t])}))},i=(n,e)=>{Object.keys(e).forEach((t=>{n.addEventListener(t,e[t])}))},a={no:{rewards:{discount_item_quantity:{three_for_two:"3 for 2",generic:"Kjøp {{require}} betal for {{payFor}}"},discount_amount:"{{monetaryAmount}} rabatt"},limitations:{discount_reward_usage:"Antall: <strong>{{discount_reward_usage}}</strong>",discount_repeat_usage:"Maks kjøp: <strong>{{discount_repeat_usage}}</strong>"},requirements:{purchase_from:"Tilbudet starter <strong>{{purchase_from}}</strong>",purchase_to:"Tilbudet utgår <strong>{{purchase_to}}</strong>"},errors:{fetch:"⚠️ <br/>En feil oppstod under lasting av tilbud..."}}},o=/(\{\{)[^}]*(\}\})/g,s=(n,e)=>{const t=n.match(o)||[],r=e||{};return t.reduce(((n,e)=>{const t=e.replace("{{","").replace("}}",""),i=r[t]||"";return n.replace(e,i)}),n)},d=(n,e,t)=>{const r=t||{},i=n.toString(),a=i.length-e.currency.exponent,o=i.slice(0,a)||"0",s=i.slice(a),d="00"!=s||r.decimal?o+"."+s:o;return"short"===r.variant&&"00"===s?o+",-":r.currency?"prefix"===e.currency.position?e.currency.value+" "+d:d+" "+e.currency.value:d},c=n=>n<10?`0${n}`:n.toString(),u=(n,e)=>{try{const t=new Date(n);if("no"===e.language){const n=c(t.getDate()),e=c(t.getMonth()+1);return[n,e,t.getFullYear()].join(".")}return(new Intl.DateTimeFormat).format(t)}catch(e){return n.substr(0,10)}},p=n=>`\n.${n} {\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n outline: none;\n border: none;\n box-shadow: none;\n line-height: auto;\n background: transparent;\n opacity: 1;\n border-radius: 0;\n display: block;\n position: relative;\n font-weight: normal;\n}\n`,l=n=>n.links&&n.links.find((n=>n.rel&&"webshop"===n.rel)),m=(n,e)=>`\n@keyframes appear {\n from {\n transform: scaleY(0%);\n height: 0;\n opacity: 0;\n }\n \n to {\n transform: scaleY(100%);\n height: auto;\n opacity: 1;\n }\n }\n.${n} {\n box-shadow: rgb(212, 212, 213) 0px 1px 3px 0px, rgb(212, 212, 213) 0px 0px 0px 1px;\n border-radius: ${e.borderRadius};\n text-align: center;\n padding-top: 5px;\n padding-bottom: 105px;\n padding-left: 5px;\n padding-right: 5px;\n max-width: 300px;\n width: 250px;\n font-size: 1em;\n margin: 5px 20px;\n background: ${e.background};\n animation-duration: 0.2s;\n animation-name: appear;\n animation-timing-function: ease-in;\n transform-origin: top center;\n color: inherit;\n text-decoration: none;\n}\n\n@media screen and (max-width: 679px) {\n .${n} {\n width: 100%;\n max-width: 100%;\n } \n }\n`,h=n=>`\n.${n} {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 300px;\n width: 100%,\n}`,g=n=>`\n.${n} {\n max-width: 100%;\n max-height: 100%;\n text-align: center;\n display: inline-block;\n}`,f=(n,e)=>`\n.${n} {\n position: absolute;\n bottom: 60px;\n left: -20px;\n color: #fff;\n z-index: 9;\n width: 80%;\n font-size: 1.3em;\n border-radius: 0 ${e.borderRadius} ${e.borderRadius} 0;\n padding: 5px 0;\n background: ${e?.secondary};\n}\n.${n}:after {\n position: absolute;\n content: "";\n bottom: -10px;\n left: 0;\n border-color: transparent;\n border-style: solid;\n border-width: 0 20px 10px 0;\n border-right-color: ${e.secondary};\n width: 0;\n height: 0;\n opacity: 0.5;\n}\n`,b=(n,e)=>`\n.${n} {\n position: absolute;\n right: -20px;\n bottom: 15px;\n color: #fff;\n z-index: 9;\n width: 80%;\n font-size: 1.3em;\n border-radius: ${e.borderRadius} 0 0 ${e.borderRadius};\n padding: 5px 0;\n background: ${e?.primary};\n}\n.${n}:after {\n position: absolute;\n content: "";\n right: 0;\n bottom: -10px;\n border-color: transparent;\n border-style: solid;\n border-width: 10px 20px 0 0;\n border-top-color: ${e.primary};\n width: 0;\n height: 0;\n opacity: 0.5;\n}\n`,y=n=>`\n.${n} {\n margin-bottom: 0;\n font-size: 1em;\n margin-bottom: 2px;\n font-size: 1.3em;\n font-weight: 700;\n}`,x=n=>`\n.${n} {\n margin-top: 0;\n}`,w=n=>`\n.${n} {\n font-size: 0.75em;\n}\n.${n} > span{\n display: block;\n}\n`,_=(n,t)=>{const r=((n,e)=>{const t=a[e.language];if("discount_item_new_price"===n.reward.type)return d(n.reward.value,e,{variant:"short"});if("discount_percent"===n.reward.type)return n.reward.value+"%";if("discount_item_quantity"===n.reward.type){if(3===n.requirement.item.quantity&&1===n.reward.value)return t.rewards.discount_item_quantity.three_for_two;{const e=n.requirement.item.quantity,r=n.requirement.item.quantity-n.reward.value;return s(t.rewards.discount_item_quantity.generic,{require:e,payFor:r})}}if("discount_amount"===n.reward.type){const r=d(n.reward.value,e,{decimal:!1});return s(t.rewards.discount_amount,{monetaryAmount:r})}return"discount_item_percent"===n.reward.type?n.reward.value+"%":""})(n,t);return r&&e({tag:"div",innerHTML:r,theme:t.theme,styles:[b]})},$=(n,t)=>{const r=e({tag:l(n)?"a":"div",styles:[p,m],theme:t.theme}),i=((n,t)=>{const r=(n=>n&&n.metadata&&n.metadata.label||void 0)(n);return r&&e({tag:"div",innerHTML:r,theme:t.theme,styles:[f]})})(n,t),o=_(n,t),d=(n=>{const t=e({tag:"div",styles:[p,h]}),r=n.links.find((n=>["medium_discount_image","thumbnail_discount_image".includes(n.rel)])),i=r&&e({tag:"img",attributes:{src:r.href,alt:n.name,loading:"lazy"},styles:[p,g]});return i&&t.appendChild(i),t})(n),c=n?.name&&e({tag:"h4",innerHTML:n.name,styles:[y]}),b=n?.metadata?.subtitle&&e({tag:"p",innerHTML:n.metadata.subtitle,styles:[x]}),$=n.description&&e({tag:"p",innerHTML:n.description}),v=((n,t)=>{const r=a[t.language],i=e({tag:"small",styles:[p,w]});return[n.limitation.discount_reward_usage&&-1!==n.limitation.discount_reward_usage&&e({tag:"span",innerHTML:s(r.limitations.discount_reward_usage,{discount_reward_usage:n.limitation.discount_reward_usage})}),n.limitation.discount_repeat_usage&&-1!==n.limitation.discount_repeat_usage&&e({tag:"span",innerHTML:s(r.limitations.discount_repeat_usage,{discount_repeat_usage:n.limitation.discount_repeat_usage})}),new Date(n.requirement.purchase_from||0)>new Date&&e({tag:"span",innerHTML:s(r.requirements.purchase_from,{purchase_from:u(n.requirement.purchase_from,t)})}),new Date(n.requirement.purchase_to||0)>new Date&&e({tag:"span",innerHTML:s(r.requirements.purchase_to,{purchase_to:u(n.requirement.purchase_to,t)})})].filter((n=>n)).forEach((n=>i.appendChild(n))),i})(n,t);return[i,o,d,c,b,$,v].filter((n=>n)).forEach((n=>r.appendChild(n))),r},v=(n,e)=>{const t=new Headers;return Object.entries({...n,"Dintero-System-Name":"deals-web-sdk","Dintero-System-Version":e.version}).forEach((([n,e])=>{t.append(n,e)})),t},k=n=>(n=>{if(!n.api)throw new Error("Authentication configuration missing");const e=window.btoa(`${n.api.key}:${n.api.secret}`),t=v({Authorization:`Basic ${e}`,"content-type":"application/json"},n),r=JSON.stringify({grant_type:"client_credentials",audience:`${n.api.url}/v1/accounts/${n.api.account}`});return window.fetch(`${n.api.url}/v1/accounts/${n.api.account}/auth/token`,{method:"POST",headers:t,body:r}).then((n=>{if(200===n.status)return n.json();throw new Error("Authentication failed")}))})(n).then((e=>{const t=v({Authorization:`${e.token_type} ${e.access_token}`},n);return n.api.discountId?window.fetch(`${n.api.url}/v1/accounts/${n.api.account}/discounts/public/rules/${n.api.discountId}`,{headers:t}).then((n=>{if(200===n.status)return n.json().then((n=>[n]));throw new Error("Authentication failed")})):window.fetch(`${n.api.url}/v1/accounts/${n.api.account}/discounts/public/rules?limit=${n.api.limit}`,{headers:t}).then((n=>{if(200===n.status)return n.json();throw new Error("Authentication failed")}))})),T=(n,e)=>`\n@keyframes appear {\n from {\n transform: scaleY(0%);\n height: 0;\n opacity: 0;\n }\n \n to {\n transform: scaleY(100%);\n height: auto;\n opacity: 1;\n }\n }\n.${n} {\n box-shadow: rgb(212, 212, 213) 0px 1px 3px 0px, rgb(212, 212, 213) 0px 0px 0px 1px;\n border-radius: 3px;\n text-align: center;\n padding-top: 65px;\n padding-bottom: 70px;\n padding-left: 5px;\n padding-right: 5px;\n max-width: 300px;\n width: 250px;\n font-size: 14px;\n margin: 5px auto;\n background: ${e.background};\n animation-duration: 0.2s;\n animation-name: appear;\n animation-timing-function: ease-in;\n transform-origin: top center;\n}\n`,q=(n,e)=>`\n.${n} {\n margin: 10px auto;\n display: block;\n width: 80px;\n height: 80px;\n}\n\n.${n}:after {\n content: " ";\n display: block;\n width: 64px;\n height: 64px;\n margin: 8px;\n border-radius: 50%;\n border: 6px solid #000;\n border-color: rgba(0,0,0,0.2) transparent rgba(0,0,0,0.2) transparent;\n animation: loading 0.6s linear infinite;\n}\n\n@keyframes loading {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n`;const M={language:"no",version:"0.2.8",linkTarget:"_self",currency:{value:"Kr",position:"suffix",exponent:2},theme:{background:"#fff",primary:"#333",secondary:"#333",color:"inherit",borderRadius:"2px",fontSize:"inherit"},api:{account:"",key:"",secret:"",url:"https://api.dintero.com",limit:50}},z=(n,e)=>`\n.${n} {\n display: flex;\n flex-flow: wrap;\n align-items: stretch;\n justify-content: center;\n position: relative;\n font-weight: normal;\n width: 100%;\n font-size: ${e.fontSize};\n color: ${e.color};\n}`,E=(n,t)=>{const r=e({tag:"div",styles:[p,z],theme:n.theme});return t.forEach((e=>{const t=$(e,n),i=l(e);i&&(t.setAttribute("target",n?.linkTarget||"_self"),t.setAttribute("href",i.href)),r.appendChild(t)})),n.container.appendChild(r),{destroy:()=>{n.container.removeChild(r)}}};n.embed=async n=>{const t=(r=M,i=n,{...r,...i,currency:{...r.currency,...i.currency},theme:{...r.theme,...i.theme},api:{...r.api,...i.api}});var r,i;if(!t.container||!t.container.appendChild)throw console.error("Invalid configuration"),new Error("Invalid configuration");if(t.discounts)return E(t,t.discounts);{const r=(n=>e({tag:"div",styles:[p,q],theme:n.theme}))(t);try{n.container.appendChild(r);const e=await k(t);return t.container.removeChild(r),E(t,e)}catch(i){n.container.removeChild(r);const o=(n=>{const t=a[n.language];return e({tag:"div",styles:[p,T],theme:n.theme,innerHTML:t.errors.fetch})})(t);return t.container.appendChild(o),{destroy:()=>{n.container.removeChild(o)}}}}},Object.defineProperty(n,"__esModule",{value:!0})}));
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((n="undefined"!=typeof globalThis?globalThis:n||self).discounts={})}(this,(function(n){"use strict";const e=n=>{const e=document.createElement(n.tag);return n.attributes&&r(e,n.attributes),n.handlers&&i(e,n.handlers),n.styles&&t(e,n.styles,n.theme),n.innerHTML&&(e.innerHTML=n.innerHTML),e},t=(n,e,t)=>{e.forEach((e=>{const r="dintero-deals-"+(n=>{let e=0;for(var t=0;t<n.length;t++)e=(e<<5)-e+n.charCodeAt(t),e&=e;return e.toString(36)})(e("dintero-deals",t));((n,e)=>{n.className.split(" ").includes(e)||(n.className=n.className+" "+e)})(n,r);if(!document.querySelector(`[data-css-hash=${r}]`)){const n=document.createElement("style");n.innerHTML=e(r,t),n.setAttribute("data-css-hash",r),document.head.appendChild(n)}}))},r=(n,e)=>{Object.keys(e).forEach((t=>{n.setAttribute(t,e[t])}))},i=(n,e)=>{Object.keys(e).forEach((t=>{n.addEventListener(t,e[t])}))},a={no:{rewards:{discount_item_quantity:{three_for_two:"3 for 2",generic:"Kjøp {{require}} betal for {{payFor}}"},discount_amount:"{{monetaryAmount}} rabatt"},limitations:{discount_reward_usage:"Antall: <strong>{{discount_reward_usage}}</strong>",discount_repeat_usage:"Maks kjøp: <strong>{{discount_repeat_usage}}</strong>"},requirements:{purchase_from:"Tilbudet starter <strong>{{purchase_from}}</strong>",purchase_to:"Tilbudet utgår <strong>{{purchase_to}}</strong>"},errors:{fetch:"⚠️ <br/>En feil oppstod under lasting av tilbud..."}}},o=/(\{\{)[^}]*(\}\})/g,s=(n,e)=>{const t=n.match(o)||[],r=e||{};return t.reduce(((n,e)=>{const t=e.replace("{{","").replace("}}",""),i=r[t]||"";return n.replace(e,i)}),n)},d=(n,e,t)=>{const r=t||{},i=n.toString(),a=i.length-e.currency.exponent,o=i.slice(0,a)||"0",s=i.slice(a),d="00"!=s||r.decimal?o+"."+s:o;return"short"===r.variant&&"00"===s?o+",-":r.currency?"prefix"===e.currency.position?e.currency.value+" "+d:d+" "+e.currency.value:d},c=n=>n<10?`0${n}`:n.toString(),u=(n,e)=>{try{const t=new Date(n);if("no"===e.language){const n=c(t.getDate()),e=c(t.getMonth()+1);return[n,e,t.getFullYear()].join(".")}return(new Intl.DateTimeFormat).format(t)}catch(e){return n.substr(0,10)}},p=n=>`\n.${n} {\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n outline: none;\n border: none;\n box-shadow: none;\n line-height: auto;\n background: transparent;\n opacity: 1;\n border-radius: 0;\n display: block;\n position: relative;\n font-weight: normal;\n}\n`,l=n=>n.links&&n.links.find((n=>n.rel&&"webshop"===n.rel)),m=(n,e)=>`\n@keyframes appear {\n from {\n transform: scaleY(0%);\n height: 0;\n opacity: 0;\n }\n \n to {\n transform: scaleY(100%);\n height: auto;\n opacity: 1;\n }\n }\n.${n} {\n box-shadow: rgb(212, 212, 213) 0px 1px 3px 0px, rgb(212, 212, 213) 0px 0px 0px 1px;\n border-radius: ${e.borderRadius};\n text-align: center;\n padding-top: 5px;\n padding-bottom: 105px;\n padding-left: 5px;\n padding-right: 5px;\n max-width: 300px;\n width: 250px;\n font-size: 1em;\n margin: 5px 20px;\n background: ${e.background};\n animation-duration: 0.2s;\n animation-name: appear;\n animation-timing-function: ease-in;\n transform-origin: top center;\n color: inherit;\n text-decoration: none;\n}\n\n@media screen and (max-width: 679px) {\n .${n} {\n width: 100%;\n max-width: 100%;\n } \n }\n`,h=n=>`\n.${n} {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 300px;\n width: 100%,\n}`,g=n=>`\n.${n} {\n max-width: 100%;\n max-height: 100%;\n text-align: center;\n display: inline-block;\n}`,f=(n,e)=>`\n.${n} {\n position: absolute;\n bottom: 60px;\n left: -20px;\n color: #fff;\n z-index: 9;\n width: 80%;\n font-size: 1.3em;\n border-radius: 0 ${e.borderRadius} ${e.borderRadius} 0;\n padding: 5px 0;\n background: ${e?.secondary};\n}\n.${n}:after {\n position: absolute;\n content: "";\n bottom: -10px;\n left: 0;\n border-color: transparent;\n border-style: solid;\n border-width: 0 20px 10px 0;\n border-right-color: ${e.secondary};\n width: 0;\n height: 0;\n opacity: 0.5;\n}\n`,b=(n,e)=>`\n.${n} {\n position: absolute;\n right: -20px;\n bottom: 15px;\n color: #fff;\n z-index: 9;\n width: 80%;\n font-size: 1.3em;\n border-radius: ${e.borderRadius} 0 0 ${e.borderRadius};\n padding: 5px 0;\n background: ${e?.primary};\n}\n.${n}:after {\n position: absolute;\n content: "";\n right: 0;\n bottom: -10px;\n border-color: transparent;\n border-style: solid;\n border-width: 10px 20px 0 0;\n border-top-color: ${e.primary};\n width: 0;\n height: 0;\n opacity: 0.5;\n}\n`,y=n=>`\n.${n} {\n margin-bottom: 0;\n font-size: 1em;\n margin-bottom: 2px;\n font-size: 1.3em;\n font-weight: 700;\n}`,x=n=>`\n.${n} {\n margin-top: 0;\n}`,w=n=>`\n.${n} {\n font-size: 0.75em;\n}\n.${n} > span{\n display: block;\n}\n`,_=(n,t)=>{const r=((n,e)=>{const t=a[e.language];if("discount_item_new_price"===n.reward.type)return d(n.reward.value,e,{variant:"short"});if("discount_percent"===n.reward.type)return n.reward.value+"%";if("discount_item_quantity"===n.reward.type){if(3===n.requirement.item.quantity&&1===n.reward.value)return t.rewards.discount_item_quantity.three_for_two;{const e=n.requirement.item.quantity,r=n.requirement.item.quantity-n.reward.value;return s(t.rewards.discount_item_quantity.generic,{require:e,payFor:r})}}if("discount_amount"===n.reward.type){const r=d(n.reward.value,e,{decimal:!1});return s(t.rewards.discount_amount,{monetaryAmount:r})}return"discount_item_percent"===n.reward.type?n.reward.value+"%":""})(n,t);return r&&e({tag:"div",innerHTML:r,theme:t.theme,styles:[b]})},$=(n,t)=>{const r=e({tag:l(n)?"a":"div",styles:[p,m],theme:t.theme}),i=((n,t)=>{const r=(n=>n&&n.metadata&&n.metadata.label||void 0)(n);return r&&e({tag:"div",innerHTML:r,theme:t.theme,styles:[f]})})(n,t),o=_(n,t),d=(n=>{const t=e({tag:"div",styles:[p,h]}),r=n.links.find((n=>["medium_discount_image","thumbnail_discount_image".includes(n.rel)])),i=r&&e({tag:"img",attributes:{src:r.href,alt:n.name,loading:"lazy"},styles:[p,g]});return i&&t.appendChild(i),t})(n),c=n?.name&&e({tag:"h4",innerHTML:n.name,styles:[y]}),b=n?.metadata?.subtitle&&e({tag:"p",innerHTML:n.metadata.subtitle,styles:[x]}),$=n.description&&e({tag:"p",innerHTML:n.description}),v=((n,t)=>{const r=a[t.language],i=e({tag:"small",styles:[p,w]});return[n.limitation.discount_reward_usage&&-1!==n.limitation.discount_reward_usage&&e({tag:"span",innerHTML:s(r.limitations.discount_reward_usage,{discount_reward_usage:n.limitation.discount_reward_usage})}),n.limitation.discount_repeat_usage&&-1!==n.limitation.discount_repeat_usage&&e({tag:"span",innerHTML:s(r.limitations.discount_repeat_usage,{discount_repeat_usage:n.limitation.discount_repeat_usage})}),new Date(n.requirement.purchase_from||0)>new Date&&e({tag:"span",innerHTML:s(r.requirements.purchase_from,{purchase_from:u(n.requirement.purchase_from,t)})}),new Date(n.requirement.purchase_to||0)>new Date&&e({tag:"span",innerHTML:s(r.requirements.purchase_to,{purchase_to:u(n.requirement.purchase_to,t)})})].filter((n=>n)).forEach((n=>i.appendChild(n))),i})(n,t);return[i,o,d,c,b,$,v].filter((n=>n)).forEach((n=>r.appendChild(n))),r},v=(n,e)=>{const t=new Headers;return Object.entries({...n,"Dintero-System-Name":"deals-web-sdk","Dintero-System-Version":e.version}).forEach((([n,e])=>{t.append(n,e)})),t},k=n=>(n=>{if(!n.api)throw new Error("Authentication configuration missing");const e=window.btoa(`${n.api.key}:${n.api.secret}`),t=v({Authorization:`Basic ${e}`,"content-type":"application/json"},n),r=JSON.stringify({grant_type:"client_credentials",audience:`${n.api.url}/v1/accounts/${n.api.account}`});return window.fetch(`${n.api.url}/v1/accounts/${n.api.account}/auth/token`,{method:"POST",headers:t,body:r}).then((n=>{if(200===n.status)return n.json();throw new Error("Authentication failed")}))})(n).then((e=>{const t=v({Authorization:`${e.token_type} ${e.access_token}`},n);return n.api.discountId?window.fetch(`${n.api.url}/v1/accounts/${n.api.account}/discounts/public/rules/${n.api.discountId}`,{headers:t}).then((n=>{if(200===n.status)return n.json().then((n=>[n]));throw new Error("Authentication failed")})):window.fetch(`${n.api.url}/v1/accounts/${n.api.account}/discounts/public/rules?limit=${n.api.limit}`,{headers:t}).then((n=>{if(200===n.status)return n.json();throw new Error("Authentication failed")}))})),T=(n,e)=>`\n@keyframes appear {\n from {\n transform: scaleY(0%);\n height: 0;\n opacity: 0;\n }\n \n to {\n transform: scaleY(100%);\n height: auto;\n opacity: 1;\n }\n }\n.${n} {\n box-shadow: rgb(212, 212, 213) 0px 1px 3px 0px, rgb(212, 212, 213) 0px 0px 0px 1px;\n border-radius: 3px;\n text-align: center;\n padding-top: 65px;\n padding-bottom: 70px;\n padding-left: 5px;\n padding-right: 5px;\n max-width: 300px;\n width: 250px;\n font-size: 14px;\n margin: 5px auto;\n background: ${e.background};\n animation-duration: 0.2s;\n animation-name: appear;\n animation-timing-function: ease-in;\n transform-origin: top center;\n}\n`,q=(n,e)=>`\n.${n} {\n margin: 10px auto;\n display: block;\n width: 80px;\n height: 80px;\n}\n\n.${n}:after {\n content: " ";\n display: block;\n width: 64px;\n height: 64px;\n margin: 8px;\n border-radius: 50%;\n border: 6px solid #000;\n border-color: rgba(0,0,0,0.2) transparent rgba(0,0,0,0.2) transparent;\n animation: loading 0.6s linear infinite;\n}\n\n@keyframes loading {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n`;const M={language:"no",version:"0.2.9",linkTarget:"_self",currency:{value:"Kr",position:"suffix",exponent:2},theme:{background:"#fff",primary:"#333",secondary:"#333",color:"inherit",borderRadius:"2px",fontSize:"inherit"},api:{account:"",key:"",secret:"",url:"https://api.dintero.com",limit:50}},z=(n,e)=>`\n.${n} {\n display: flex;\n flex-flow: wrap;\n align-items: stretch;\n justify-content: center;\n position: relative;\n font-weight: normal;\n width: 100%;\n font-size: ${e.fontSize};\n color: ${e.color};\n}`,E=(n,t)=>{const r=e({tag:"div",styles:[p,z],theme:n.theme});return t.forEach((e=>{const t=$(e,n),i=l(e);i&&(t.setAttribute("target",n?.linkTarget||"_self"),t.setAttribute("href",i.href)),r.appendChild(t)})),n.container.appendChild(r),{destroy:()=>{n.container.removeChild(r)}}};n.embed=async n=>{const t=(r=M,i=n,{...r,...i,currency:{...r.currency,...i.currency},theme:{...r.theme,...i.theme},api:{...r.api,...i.api}});var r,i;if(!t.container||!t.container.appendChild)throw console.error("Invalid configuration"),new Error("Invalid configuration");if(t.discounts)return E(t,t.discounts);{const r=(n=>e({tag:"div",styles:[p,q],theme:n.theme}))(t);try{n.container.appendChild(r);const e=await k(t);return t.container.removeChild(r),E(t,e)}catch(i){n.container.removeChild(r);const o=(n=>{const t=a[n.language];return e({tag:"div",styles:[p,T],theme:n.theme,innerHTML:t.errors.fetch})})(t);return t.container.appendChild(o),{destroy:()=>{n.container.removeChild(o)}}}}},Object.defineProperty(n,"__esModule",{value:!0})}));
//# sourceMappingURL=dintero-discounts-web-sdk.umd.min.js.map
{
"name": "@dintero/discounts-web-sdk",
"version": "0.2.8",
"version": "0.2.9",
"description": "Dintero Discounts SDK for web frontends",

@@ -37,8 +37,8 @@ "main": "dist/dintero-discounts-web-sdk.cjs.js",

"@semantic-release/git": "10.0.1",
"happy-dom": "14.4.0",
"happy-dom": "14.7.1",
"prettier": "3.2.5",
"semantic-release": "23.0.7",
"typescript": "5.4.3",
"semantic-release": "23.0.8",
"typescript": "5.4.4",
"vitest": "1.4.0"
}
}
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