@dintero/checkout-web-sdk 0.5.7 → 0.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,16 +10,16 @@ jobs:
10
10
  runs-on: ubuntu-latest
11
11
 
12
12
  steps:
13
- - uses: actions/checkout@v2
13
+ - uses: actions/checkout@v3
14
14
  with:
15
15
  fetch-depth: 0
16
- - uses: actions/setup-node@v2
16
+ - uses: actions/setup-node@v3
17
17
  with:
18
18
  node-version: 'lts/*'
19
19
  cache: npm
20
20
 
21
- - name: npm install, build and test
21
+ - name: yarn install, build and test
22
22
  run: |
23
- npm install
24
- npm run test
25
- npm run build
23
+ yarn install
24
+ yarn run test
25
+ yarn run build
@@ -18,22 +18,22 @@ jobs:
18
18
 
19
19
  steps:
20
20
  - name: Checkout
21
- uses: actions/checkout@v2
21
+ uses: actions/checkout@v3
22
22
  with:
23
23
  fetch-depth: 5
24
24
 
25
25
  - name: Setup Node.js
26
- uses: actions/setup-node@v2
26
+ uses: actions/setup-node@v3
27
27
  with:
28
28
  node-version: 'lts/*'
29
29
 
30
- - name: Install dependencies
30
+ - name: Install dependencies and test
31
31
  run: |
32
- npm install
33
- npm run test
32
+ yarn install
33
+ yarn run test
34
34
 
35
35
  - name: Release
36
36
  env:
37
37
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38
38
  NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
39
- run: npm run semantic-release
39
+ run: yarn run semantic-release
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Dintero Checkout JavaScript SDK for frontend applications [![Actions Status](https://github.com/Dintero/Dintero.Checkout.Web.SDK/workflows/CI/badge.svg?branch=master)](https://github.com/Dintero/Dintero.Checkout.Web.SDK/actions?query=branch%3Amaster+workflow%3ACI+)
1
+ # Dintero Checkout JavaScript SDK for frontend applications [![Actions Status](https://github.com/Dintero/Dintero.Checkout.Web.SDK/workflows/CI/badge.svg?branch=master)](https://github.com/Dintero/Dintero.Checkout.Web.SDK/actions?query=branch%3Amaster+workflow%3ACI+) [![npm latest version](https://img.shields.io/npm/v/@dintero/checkout-web-sdk/latest.svg)](https://www.npmjs.com/package/@dintero/checkout-web-sdk)
2
2
 
3
3
  Use this SDK in your frontend application to
4
4
 
@@ -293,8 +293,8 @@ The SDK includes a [polyfill for promises](https://github.com/getify/native-prom
293
293
  ## Building from source
294
294
 
295
295
  ```bash
296
- npm install
297
- npm run build
296
+ yarn install
297
+ yarn run build
298
298
  ```
299
299
 
300
300
  The Dintero Checkout SDK is built with [microbundle](https://github.com/developit/microbundle).
@@ -370,7 +370,7 @@ export type SessionEvent =
370
370
  <div class='footer quiet pad2 space-top1 center small'>
371
371
  Code coverage generated by
372
372
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
373
- at Wed Jul 05 2023 14:14:06 GMT+0000 (Coordinated Universal Time)
373
+ at Sun Jul 16 2023 22:59:55 GMT+0000 (Coordinated Universal Time)
374
374
  </div>
375
375
  </div>
376
376
  <script src="prettify.js"></script>
@@ -247,7 +247,7 @@ export const createIframeAsync = (
247
247
  <div class='footer quiet pad2 space-top1 center small'>
248
248
  Code coverage generated by
249
249
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
250
- at Wed Jul 05 2023 14:14:06 GMT+0000 (Coordinated Universal Time)
250
+ at Sun Jul 16 2023 22:59:55 GMT+0000 (Coordinated Universal Time)
251
251
  </div>
252
252
  </div>
253
253
  <script src="prettify.js"></script>
@@ -155,7 +155,7 @@
155
155
  <div class='footer quiet pad2 space-top1 center small'>
156
156
  Code coverage generated by
157
157
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
158
- at Wed Jul 05 2023 14:14:06 GMT+0000 (Coordinated Universal Time)
158
+ at Sun Jul 16 2023 22:59:55 GMT+0000 (Coordinated Universal Time)
159
159
  </div>
160
160
  </div>
161
161
  <script src="prettify.js"></script>
@@ -1372,7 +1372,7 @@ export type {
1372
1372
  <div class='footer quiet pad2 space-top1 center small'>
1373
1373
  Code coverage generated by
1374
1374
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
1375
- at Wed Jul 05 2023 14:14:06 GMT+0000 (Coordinated Universal Time)
1375
+ at Sun Jul 16 2023 22:59:55 GMT+0000 (Coordinated Universal Time)
1376
1376
  </div>
1377
1377
  </div>
1378
1378
  <script src="prettify.js"></script>
@@ -427,7 +427,7 @@ export const subscribe = (options: SubscriptionOptions): Subscription =&gt; {
427
427
  <div class='footer quiet pad2 space-top1 center small'>
428
428
  Code coverage generated by
429
429
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
430
- at Wed Jul 05 2023 14:14:06 GMT+0000 (Coordinated Universal Time)
430
+ at Sun Jul 16 2023 22:59:55 GMT+0000 (Coordinated Universal Time)
431
431
  </div>
432
432
  </div>
433
433
  <script src="prettify.js"></script>
@@ -169,7 +169,7 @@ export const getSessionUrl = (options: SessionUrlOptions): string =&gt; {
169
169
  <div class='footer quiet pad2 space-top1 center small'>
170
170
  Code coverage generated by
171
171
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
172
- at Wed Jul 05 2023 14:14:06 GMT+0000 (Coordinated Universal Time)
172
+ at Sun Jul 16 2023 22:59:55 GMT+0000 (Coordinated Universal Time)
173
173
  </div>
174
174
  </div>
175
175
  <script src="prettify.js"></script>
@@ -6,7 +6,7 @@ require('native-promise-only');
6
6
 
7
7
  var pkg = {
8
8
  name: "@dintero/checkout-web-sdk",
9
- version: "0.5.7",
9
+ version: "0.5.8",
10
10
  description: "Dintero Checkout SDK for web frontends",
11
11
  main: "dist/dintero-checkout-web-sdk.cjs.js",
12
12
  module: "dist/dintero-checkout-web-sdk.esm.js",
@@ -18,9 +18,9 @@ var pkg = {
18
18
  },
19
19
  scripts: {
20
20
  build: "preconstruct build",
21
- test: "karma start",
21
+ test: "$(yarn bin)/karma start",
22
22
  "semantic-release": "semantic-release",
23
- prepublishOnly: "npm run build"
23
+ prepublishOnly: "yarn run build"
24
24
  },
25
25
  "private": false,
26
26
  repository: {
@@ -39,7 +39,7 @@ var pkg = {
39
39
  "@preconstruct/cli": "^2.1.5",
40
40
  "@semantic-release/git": "^10.0.1",
41
41
  chai: "^4.2.0",
42
- karma: "^6.3.14",
42
+ karma: "^6.4.2",
43
43
  "karma-chai": "^0.1.0",
44
44
  "karma-chrome-launcher": "^3.1.0",
45
45
  "karma-mocha": "^2.0.1",
@@ -6,7 +6,7 @@ require('native-promise-only');
6
6
 
7
7
  var pkg = {
8
8
  name: "@dintero/checkout-web-sdk",
9
- version: "0.5.7",
9
+ version: "0.5.8",
10
10
  description: "Dintero Checkout SDK for web frontends",
11
11
  main: "dist/dintero-checkout-web-sdk.cjs.js",
12
12
  module: "dist/dintero-checkout-web-sdk.esm.js",
@@ -18,9 +18,9 @@ var pkg = {
18
18
  },
19
19
  scripts: {
20
20
  build: "preconstruct build",
21
- test: "karma start",
21
+ test: "$(yarn bin)/karma start",
22
22
  "semantic-release": "semantic-release",
23
- prepublishOnly: "npm run build"
23
+ prepublishOnly: "yarn run build"
24
24
  },
25
25
  "private": false,
26
26
  repository: {
@@ -39,7 +39,7 @@ var pkg = {
39
39
  "@preconstruct/cli": "^2.1.5",
40
40
  "@semantic-release/git": "^10.0.1",
41
41
  chai: "^4.2.0",
42
- karma: "^6.3.14",
42
+ karma: "^6.4.2",
43
43
  "karma-chai": "^0.1.0",
44
44
  "karma-chrome-launcher": "^3.1.0",
45
45
  "karma-mocha": "^2.0.1",
@@ -2,7 +2,7 @@ import 'native-promise-only';
2
2
 
3
3
  var pkg = {
4
4
  name: "@dintero/checkout-web-sdk",
5
- version: "0.5.7",
5
+ version: "0.5.8",
6
6
  description: "Dintero Checkout SDK for web frontends",
7
7
  main: "dist/dintero-checkout-web-sdk.cjs.js",
8
8
  module: "dist/dintero-checkout-web-sdk.esm.js",
@@ -14,9 +14,9 @@ var pkg = {
14
14
  },
15
15
  scripts: {
16
16
  build: "preconstruct build",
17
- test: "karma start",
17
+ test: "$(yarn bin)/karma start",
18
18
  "semantic-release": "semantic-release",
19
- prepublishOnly: "npm run build"
19
+ prepublishOnly: "yarn run build"
20
20
  },
21
21
  "private": false,
22
22
  repository: {
@@ -35,7 +35,7 @@ var pkg = {
35
35
  "@preconstruct/cli": "^2.1.5",
36
36
  "@semantic-release/git": "^10.0.1",
37
37
  chai: "^4.2.0",
38
- karma: "^6.3.14",
38
+ karma: "^6.4.2",
39
39
  "karma-chai": "^0.1.0",
40
40
  "karma-chrome-launcher": "^3.1.0",
41
41
  "karma-mocha": "^2.0.1",
@@ -3,5 +3,5 @@
3
3
  v0.8.1 (c) Kyle Simpson
4
4
  MIT License: http://getify.mit-license.org
5
5
  */
6
- var t,o,i;i=function(){var e,n,t,o=Object.prototype.toString,i="undefined"!=typeof setImmediate?function(e){return setImmediate(e)}:setTimeout;try{Object.defineProperty({},"x",{}),e=function(e,n,t,o){return Object.defineProperty(e,n,{value:t,writable:!0,configurable:!1!==o})}}catch(n){e=function(e,n,t){return e[n]=t,e}}function r(e,o){t.add(e,o),n||(n=i(t.drain))}function s(e){var n,t=typeof e;return null==e||"object"!=t&&"function"!=t||(n=e.then),"function"==typeof n&&n}function a(){for(var e=0;e<this.chain.length;e++)c(this,1===this.state?this.chain[e].success:this.chain[e].failure,this.chain[e]);this.chain.length=0}function c(e,n,t){var o,i;try{!1===n?t.reject(e.msg):(o=!0===n?e.msg:n.call(void 0,e.msg))===t.promise?t.reject(TypeError("Promise-chain cycle")):(i=s(o))?i.call(o,t.resolve,t.reject):t.resolve(o)}catch(e){t.reject(e)}}function d(e){var n,t=this;if(!t.triggered){t.triggered=!0,t.def&&(t=t.def);try{(n=s(e))?r((function(){var o=new f(t);try{n.call(e,(function(){d.apply(o,arguments)}),(function(){u.apply(o,arguments)}))}catch(e){u.call(o,e)}})):(t.msg=e,t.state=1,t.chain.length>0&&r(a,t))}catch(e){u.call(new f(t),e)}}}function u(e){var n=this;n.triggered||(n.triggered=!0,n.def&&(n=n.def),n.msg=e,n.state=2,n.chain.length>0&&r(a,n))}function l(e,n,t,o){for(var i=0;i<n.length;i++)!function(i){e.resolve(n[i]).then((function(e){t(i,e)}),o)}(i)}function f(e){this.def=e,this.triggered=!1}function h(e){this.promise=e,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function p(e){if("function"!=typeof e)throw TypeError("Not a function");if(0!==this.__NPO__)throw TypeError("Not a promise");this.__NPO__=1;var n=new h(this);this.then=function(e,t){var o={success:"function"!=typeof e||e,failure:"function"==typeof t&&t};return o.promise=new this.constructor((function(e,n){if("function"!=typeof e||"function"!=typeof n)throw TypeError("Not a function");o.resolve=e,o.reject=n})),n.chain.push(o),0!==n.state&&r(a,n),o.promise},this.catch=function(e){return this.then(void 0,e)};try{e.call(void 0,(function(e){d.call(n,e)}),(function(e){u.call(n,e)}))}catch(e){u.call(n,e)}}t=function(){var e,t,o;function i(e,n){this.fn=e,this.self=n,this.next=void 0}return{add:function(n,r){o=new i(n,r),t?t.next=o:e=o,t=o,o=void 0},drain:function(){var o=e;for(e=t=n=void 0;o;)o.fn.call(o.self),o=o.next}}}();var y=e({},"constructor",p,!1);return p.prototype=y,e(y,"__NPO__",0,!1),e(p,"resolve",(function(e){return e&&"object"==typeof e&&1===e.__NPO__?e:new this((function(n,t){if("function"!=typeof n||"function"!=typeof t)throw TypeError("Not a function");n(e)}))})),e(p,"reject",(function(e){return new this((function(n,t){if("function"!=typeof n||"function"!=typeof t)throw TypeError("Not a function");t(e)}))})),e(p,"all",(function(e){var n=this;return"[object Array]"!=o.call(e)?n.reject(TypeError("Not an array")):0===e.length?n.resolve([]):new n((function(t,o){if("function"!=typeof t||"function"!=typeof o)throw TypeError("Not a function");var i=e.length,r=Array(i),s=0;l(n,e,(function(e,n){r[e]=n,++s===i&&t(r)}),o)}))})),e(p,"race",(function(e){var n=this;return"[object Array]"!=o.call(e)?n.reject(TypeError("Not an array")):new n((function(t,o){if("function"!=typeof t||"function"!=typeof o)throw TypeError("Not a function");l(n,e,(function(e,n){t(n)}),o)}))})),p},(o=n)[t="Promise"]=o[t]||i(),e.exports&&(e.exports=o[t])}));var t="0.5.7";let o,i;!function(e){e.SessionNotFound="SessionNotFound",e.SessionLoaded="SessionLoaded",e.SessionUpdated="SessionUpdated",e.SessionCancel="SessionCancel",e.SessionPaymentOnHold="SessionPaymentOnHold",e.SessionPaymentAuthorized="SessionPaymentAuthorized",e.SessionPaymentError="SessionPaymentError",e.SessionLocked="SessionLocked",e.SessionLockFailed="SessionLockFailed",e.ActivePaymentProductType="ActivePaymentProductType",e.ValidateSession="ValidateSession"}(o||(o={})),function(e){e.HeightChanged="HeightChanged",e.LanguageChanged="LanguageChanged",e.ScrollToTop="ScrollToTop"}(i||(i={}));const r=e=>{window.location.assign(e)},s=e=>{const{sid:n,endpoint:o,language:i,ui:r,shouldCallValidateSession:s}=e;if(!o)throw new Error("Invalid endpoint");const a=[i?`language=${i}`:"",r?`ui=${r}`:"",`sdk=${t}`,s?"client_side_validation=true":void 0].filter((e=>e)).join("&");return`${o}/v1/view/${n}${a?"?"+a:""}`},a=e=>{const{sid:n,endpoint:t,handler:o,eventTypes:i,checkout:r}=e,s=e=>{const s=e.origin===t,a=e.source===r.iframe.contentWindow,c=e.data&&e.data.sid===n,d=-1!==i.indexOf(e.data&&e.data.type);s&&a&&c&&d&&(((e,n)=>{n.data.mid&&e.contentWindow&&e.contentWindow.postMessage({ack:n.data.mid},n.origin||"*")})(r.iframe,e),o(e.data,r))};window.addEventListener("message",s,!1);return{unsubscribe:()=>{window.removeEventListener("message",s,!1)}}},c=e=>{e.href&&r(e.href)},d=(e,n)=>{(e.height||0===e.height)&&n.iframe.setAttribute("style",`width:100%; height:${e.height}px;`)},u=(e,n)=>{try{n.iframe.scrollIntoView({block:"start",behavior:"smooth"})}catch(e){console.error(e)}},l=(e,n)=>{e.language&&(n.language=e.language)},f=(e,n,i)=>(e,r)=>{const s=["sid","merchant_reference","transaction_id","error"].map((n=>[n,e[n]]));e.type!==o.SessionCancel||e.error||s.push(["error","cancelled"]),s.push(["language",r.language]),s.push(["sdk",t]);const a=s.filter((([e,n])=>n)).map((([e,n])=>`${e}=${n}`)).join("&");r.iframe.setAttribute("src",`${n}/embedResult/?${a}`),i(e,r)};e.embed=async e=>{const{container:n,sid:t,language:r,endpoint:h="https://checkout.dintero.com",onSession:p,onSessionCancel:y,onPayment:g,onPaymentAuthorized:m,onPaymentError:v,onSessionNotFound:w,onSessionLocked:S,onSessionLockFailed:T,onActivePaymentType:b,onValidateSession:P}=e;let E;const _=[],{iframe:k,initiate:A}=((e,n,t)=>{if(!e||!e.appendChild)throw new Error("Invalid container");const o=document.createElement("iframe");return o.setAttribute("frameborder","0"),o.setAttribute("allowTransparency","true"),o.setAttribute("style","width:100%; height:0;"),o.setAttribute("sandbox","allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox"),o.setAttribute("allow","payment"),o.setAttribute("importance","high"),o.setAttribute("src",t),{iframe:o,initiate:async()=>new Promise(((n,t)=>{o.onload=()=>n(),o.onerror=()=>t(),e.appendChild(o)}))}})(n,0,s({sid:t,endpoint:h,language:r,ui:"inline",shouldCallValidateSession:void 0!==P})),j=(e,n,o)=>{if(!E)throw new Error("Unable to create action promise: checkout is undefined");return new Promise(((i,r)=>{const s=[];s.push(a({sid:t,endpoint:h,handler:e=>{s.forEach((e=>e.unsubscribe())),i(e)},eventTypes:[n],checkout:E})),s.push(a({sid:t,endpoint:h,handler:()=>{s.forEach((e=>e.unsubscribe())),r(`Received unexpected event: ${o}`)},eventTypes:[o],checkout:E})),e()}))},L=()=>j((()=>{((e,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"RefreshSession",sid:n},"*")})(k,t)}),o.SessionUpdated,o.SessionNotFound),N=e=>{((e,n,t)=>{e.contentWindow&&e.contentWindow.postMessage({type:"ValidationResult",sid:n,...t},"*")})(k,t,e)};return E={destroy:()=>{k&&(_.forEach((e=>e.unsubscribe())),k.parentElement&&n.removeChild(k))},iframe:k,language:r,lockSession:()=>j((()=>{((e,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"LockSession",sid:n},"*")})(k,t)}),o.SessionLocked,o.SessionLockFailed),refreshSession:L,setActivePaymentProductType:e=>{((e,n,t)=>{e.contentWindow&&e.contentWindow.postMessage({type:"SetActivePaymentProductType",sid:n,payment_product_type:t},"*")})(k,t,e)},submitValidationResult:N},[{handler:l,eventTypes:[i.LanguageChanged]},{handler:d,eventTypes:[i.HeightChanged]},{handler:u,eventTypes:[i.ScrollToTop]},{handler:p,eventTypes:[o.SessionLoaded,o.SessionUpdated]},{eventTypes:[o.SessionPaymentOnHold],handler:g?f(0,h,g):c},{eventTypes:[o.SessionPaymentAuthorized],handler:m||g?f(0,h,m||g):c},{handler:y?f(0,h,y):c,eventTypes:[o.SessionCancel]},{handler:v?f(0,h,v):c,eventTypes:[o.SessionPaymentError]},{handler:w,eventTypes:[o.SessionNotFound]},{handler:(e,n)=>{S&&S(e,n,L)},eventTypes:[o.SessionLocked]},{handler:T,eventTypes:[o.SessionLockFailed]},{handler:b,eventTypes:[o.ActivePaymentProductType]},{handler:b,eventTypes:[o.ActivePaymentProductType]},{handler:(e,n)=>{P&&P(e,n,N)},eventTypes:[o.ValidateSession]}].forEach((({handler:e,eventTypes:n})=>{e&&_.push(a({sid:t,endpoint:h,handler:e,eventTypes:n,checkout:E}))})),await A(),E},e.redirect=e=>{const{sid:n,language:t,endpoint:o="https://checkout.dintero.com"}=e;r(s({sid:n,endpoint:o,language:t,shouldCallValidateSession:!1}))},Object.defineProperty(e,"__esModule",{value:!0})}));
6
+ var t,o,i;i=function(){var e,n,t,o=Object.prototype.toString,i="undefined"!=typeof setImmediate?function(e){return setImmediate(e)}:setTimeout;try{Object.defineProperty({},"x",{}),e=function(e,n,t,o){return Object.defineProperty(e,n,{value:t,writable:!0,configurable:!1!==o})}}catch(n){e=function(e,n,t){return e[n]=t,e}}function r(e,o){t.add(e,o),n||(n=i(t.drain))}function s(e){var n,t=typeof e;return null==e||"object"!=t&&"function"!=t||(n=e.then),"function"==typeof n&&n}function a(){for(var e=0;e<this.chain.length;e++)c(this,1===this.state?this.chain[e].success:this.chain[e].failure,this.chain[e]);this.chain.length=0}function c(e,n,t){var o,i;try{!1===n?t.reject(e.msg):(o=!0===n?e.msg:n.call(void 0,e.msg))===t.promise?t.reject(TypeError("Promise-chain cycle")):(i=s(o))?i.call(o,t.resolve,t.reject):t.resolve(o)}catch(e){t.reject(e)}}function d(e){var n,t=this;if(!t.triggered){t.triggered=!0,t.def&&(t=t.def);try{(n=s(e))?r((function(){var o=new f(t);try{n.call(e,(function(){d.apply(o,arguments)}),(function(){u.apply(o,arguments)}))}catch(e){u.call(o,e)}})):(t.msg=e,t.state=1,t.chain.length>0&&r(a,t))}catch(e){u.call(new f(t),e)}}}function u(e){var n=this;n.triggered||(n.triggered=!0,n.def&&(n=n.def),n.msg=e,n.state=2,n.chain.length>0&&r(a,n))}function l(e,n,t,o){for(var i=0;i<n.length;i++)!function(i){e.resolve(n[i]).then((function(e){t(i,e)}),o)}(i)}function f(e){this.def=e,this.triggered=!1}function h(e){this.promise=e,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function p(e){if("function"!=typeof e)throw TypeError("Not a function");if(0!==this.__NPO__)throw TypeError("Not a promise");this.__NPO__=1;var n=new h(this);this.then=function(e,t){var o={success:"function"!=typeof e||e,failure:"function"==typeof t&&t};return o.promise=new this.constructor((function(e,n){if("function"!=typeof e||"function"!=typeof n)throw TypeError("Not a function");o.resolve=e,o.reject=n})),n.chain.push(o),0!==n.state&&r(a,n),o.promise},this.catch=function(e){return this.then(void 0,e)};try{e.call(void 0,(function(e){d.call(n,e)}),(function(e){u.call(n,e)}))}catch(e){u.call(n,e)}}t=function(){var e,t,o;function i(e,n){this.fn=e,this.self=n,this.next=void 0}return{add:function(n,r){o=new i(n,r),t?t.next=o:e=o,t=o,o=void 0},drain:function(){var o=e;for(e=t=n=void 0;o;)o.fn.call(o.self),o=o.next}}}();var y=e({},"constructor",p,!1);return p.prototype=y,e(y,"__NPO__",0,!1),e(p,"resolve",(function(e){return e&&"object"==typeof e&&1===e.__NPO__?e:new this((function(n,t){if("function"!=typeof n||"function"!=typeof t)throw TypeError("Not a function");n(e)}))})),e(p,"reject",(function(e){return new this((function(n,t){if("function"!=typeof n||"function"!=typeof t)throw TypeError("Not a function");t(e)}))})),e(p,"all",(function(e){var n=this;return"[object Array]"!=o.call(e)?n.reject(TypeError("Not an array")):0===e.length?n.resolve([]):new n((function(t,o){if("function"!=typeof t||"function"!=typeof o)throw TypeError("Not a function");var i=e.length,r=Array(i),s=0;l(n,e,(function(e,n){r[e]=n,++s===i&&t(r)}),o)}))})),e(p,"race",(function(e){var n=this;return"[object Array]"!=o.call(e)?n.reject(TypeError("Not an array")):new n((function(t,o){if("function"!=typeof t||"function"!=typeof o)throw TypeError("Not a function");l(n,e,(function(e,n){t(n)}),o)}))})),p},(o=n)[t="Promise"]=o[t]||i(),e.exports&&(e.exports=o[t])}));var t="0.5.8";let o,i;!function(e){e.SessionNotFound="SessionNotFound",e.SessionLoaded="SessionLoaded",e.SessionUpdated="SessionUpdated",e.SessionCancel="SessionCancel",e.SessionPaymentOnHold="SessionPaymentOnHold",e.SessionPaymentAuthorized="SessionPaymentAuthorized",e.SessionPaymentError="SessionPaymentError",e.SessionLocked="SessionLocked",e.SessionLockFailed="SessionLockFailed",e.ActivePaymentProductType="ActivePaymentProductType",e.ValidateSession="ValidateSession"}(o||(o={})),function(e){e.HeightChanged="HeightChanged",e.LanguageChanged="LanguageChanged",e.ScrollToTop="ScrollToTop"}(i||(i={}));const r=e=>{window.location.assign(e)},s=e=>{const{sid:n,endpoint:o,language:i,ui:r,shouldCallValidateSession:s}=e;if(!o)throw new Error("Invalid endpoint");const a=[i?`language=${i}`:"",r?`ui=${r}`:"",`sdk=${t}`,s?"client_side_validation=true":void 0].filter((e=>e)).join("&");return`${o}/v1/view/${n}${a?"?"+a:""}`},a=e=>{const{sid:n,endpoint:t,handler:o,eventTypes:i,checkout:r}=e,s=e=>{const s=e.origin===t,a=e.source===r.iframe.contentWindow,c=e.data&&e.data.sid===n,d=-1!==i.indexOf(e.data&&e.data.type);s&&a&&c&&d&&(((e,n)=>{n.data.mid&&e.contentWindow&&e.contentWindow.postMessage({ack:n.data.mid},n.origin||"*")})(r.iframe,e),o(e.data,r))};window.addEventListener("message",s,!1);return{unsubscribe:()=>{window.removeEventListener("message",s,!1)}}},c=e=>{e.href&&r(e.href)},d=(e,n)=>{(e.height||0===e.height)&&n.iframe.setAttribute("style",`width:100%; height:${e.height}px;`)},u=(e,n)=>{try{n.iframe.scrollIntoView({block:"start",behavior:"smooth"})}catch(e){console.error(e)}},l=(e,n)=>{e.language&&(n.language=e.language)},f=(e,n,i)=>(e,r)=>{const s=["sid","merchant_reference","transaction_id","error"].map((n=>[n,e[n]]));e.type!==o.SessionCancel||e.error||s.push(["error","cancelled"]),s.push(["language",r.language]),s.push(["sdk",t]);const a=s.filter((([e,n])=>n)).map((([e,n])=>`${e}=${n}`)).join("&");r.iframe.setAttribute("src",`${n}/embedResult/?${a}`),i(e,r)};e.embed=async e=>{const{container:n,sid:t,language:r,endpoint:h="https://checkout.dintero.com",onSession:p,onSessionCancel:y,onPayment:g,onPaymentAuthorized:m,onPaymentError:v,onSessionNotFound:w,onSessionLocked:S,onSessionLockFailed:T,onActivePaymentType:b,onValidateSession:P}=e;let E;const _=[],{iframe:k,initiate:A}=((e,n,t)=>{if(!e||!e.appendChild)throw new Error("Invalid container");const o=document.createElement("iframe");return o.setAttribute("frameborder","0"),o.setAttribute("allowTransparency","true"),o.setAttribute("style","width:100%; height:0;"),o.setAttribute("sandbox","allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox"),o.setAttribute("allow","payment"),o.setAttribute("importance","high"),o.setAttribute("src",t),{iframe:o,initiate:async()=>new Promise(((n,t)=>{o.onload=()=>n(),o.onerror=()=>t(),e.appendChild(o)}))}})(n,0,s({sid:t,endpoint:h,language:r,ui:"inline",shouldCallValidateSession:void 0!==P})),j=(e,n,o)=>{if(!E)throw new Error("Unable to create action promise: checkout is undefined");return new Promise(((i,r)=>{const s=[];s.push(a({sid:t,endpoint:h,handler:e=>{s.forEach((e=>e.unsubscribe())),i(e)},eventTypes:[n],checkout:E})),s.push(a({sid:t,endpoint:h,handler:()=>{s.forEach((e=>e.unsubscribe())),r(`Received unexpected event: ${o}`)},eventTypes:[o],checkout:E})),e()}))},L=()=>j((()=>{((e,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"RefreshSession",sid:n},"*")})(k,t)}),o.SessionUpdated,o.SessionNotFound),N=e=>{((e,n,t)=>{e.contentWindow&&e.contentWindow.postMessage({type:"ValidationResult",sid:n,...t},"*")})(k,t,e)};return E={destroy:()=>{k&&(_.forEach((e=>e.unsubscribe())),k.parentElement&&n.removeChild(k))},iframe:k,language:r,lockSession:()=>j((()=>{((e,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"LockSession",sid:n},"*")})(k,t)}),o.SessionLocked,o.SessionLockFailed),refreshSession:L,setActivePaymentProductType:e=>{((e,n,t)=>{e.contentWindow&&e.contentWindow.postMessage({type:"SetActivePaymentProductType",sid:n,payment_product_type:t},"*")})(k,t,e)},submitValidationResult:N},[{handler:l,eventTypes:[i.LanguageChanged]},{handler:d,eventTypes:[i.HeightChanged]},{handler:u,eventTypes:[i.ScrollToTop]},{handler:p,eventTypes:[o.SessionLoaded,o.SessionUpdated]},{eventTypes:[o.SessionPaymentOnHold],handler:g?f(0,h,g):c},{eventTypes:[o.SessionPaymentAuthorized],handler:m||g?f(0,h,m||g):c},{handler:y?f(0,h,y):c,eventTypes:[o.SessionCancel]},{handler:v?f(0,h,v):c,eventTypes:[o.SessionPaymentError]},{handler:w,eventTypes:[o.SessionNotFound]},{handler:(e,n)=>{S&&S(e,n,L)},eventTypes:[o.SessionLocked]},{handler:T,eventTypes:[o.SessionLockFailed]},{handler:b,eventTypes:[o.ActivePaymentProductType]},{handler:b,eventTypes:[o.ActivePaymentProductType]},{handler:(e,n)=>{P&&P(e,n,N)},eventTypes:[o.ValidateSession]}].forEach((({handler:e,eventTypes:n})=>{e&&_.push(a({sid:t,endpoint:h,handler:e,eventTypes:n,checkout:E}))})),await A(),E},e.redirect=e=>{const{sid:n,language:t,endpoint:o="https://checkout.dintero.com"}=e;r(s({sid:n,endpoint:o,language:t,shouldCallValidateSession:!1}))},Object.defineProperty(e,"__esModule",{value:!0})}));
7
7
  //# sourceMappingURL=dintero-checkout-web-sdk.umd.min.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dintero/checkout-web-sdk",
3
- "version": "0.5.7",
3
+ "version": "0.5.8",
4
4
  "description": "Dintero Checkout SDK for web frontends",
5
5
  "main": "dist/dintero-checkout-web-sdk.cjs.js",
6
6
  "module": "dist/dintero-checkout-web-sdk.esm.js",
@@ -12,9 +12,9 @@
12
12
  },
13
13
  "scripts": {
14
14
  "build": "preconstruct build",
15
- "test": "karma start",
15
+ "test": "$(yarn bin)/karma start",
16
16
  "semantic-release": "semantic-release",
17
- "prepublishOnly": "npm run build"
17
+ "prepublishOnly": "yarn run build"
18
18
  },
19
19
  "private": false,
20
20
  "repository": {
@@ -33,7 +33,7 @@
33
33
  "@preconstruct/cli": "^2.1.5",
34
34
  "@semantic-release/git": "^10.0.1",
35
35
  "chai": "^4.2.0",
36
- "karma": "^6.3.14",
36
+ "karma": "^6.4.2",
37
37
  "karma-chai": "^0.1.0",
38
38
  "karma-chrome-launcher": "^3.1.0",
39
39
  "karma-mocha": "^2.0.1",