@gr4vy/secure-fields 1.11.2 → 1.12.0
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.
- package/CHANGELOG.md +17 -0
- package/lib/index.js +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
# v1.12.0 (Thu Aug 03 2023)
|
|
2
|
+
|
|
3
|
+
#### 🐛 Bug Fix
|
|
4
|
+
|
|
5
|
+
- fix: SecureFields.version returns undefined on CDN builds [#380](https://github.com/gr4vy/secure-fields/pull/380) ([@theturboboy](https://github.com/theturboboy))
|
|
6
|
+
|
|
7
|
+
#### 🏠 Internal
|
|
8
|
+
|
|
9
|
+
- chore(dev-deps): update dependency typedoc-plugin-missing-exports to ^2.0.1 [#397](https://github.com/gr4vy/secure-fields/pull/397) ([@renovate[bot]](https://github.com/renovate[bot]))
|
|
10
|
+
|
|
11
|
+
#### Authors: 2
|
|
12
|
+
|
|
13
|
+
- [@renovate[bot]](https://github.com/renovate[bot])
|
|
14
|
+
- Andrei Haidukevich ([@theturboboy](https://github.com/theturboboy))
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
1
18
|
# v1.11.2 (Thu Jul 06 2023)
|
|
2
19
|
|
|
3
20
|
#### 🐛 Bug Fix
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(this,(function(){return function(){"use strict";var e={d:function(t,r){for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{SecureFields:function(){return S},SecureInput:function(){return v}});var r,n,o="@gr4vy-secure-fields-debug";!function(e){e.CARD_VAULT_SUCCESS="card-vault-success",e.CARD_VAULT_FAILURE="card-vault-failure",e.FORM_CHANGE="form-change",e.READY="ready"}(r||(r={})),function(e){e.FOCUSED="data-secure-fields-focused",e.INVALID="data-secure-fields-invalid",e.AUTOFILLED="data-secure-fields-autofilled"}(n||(n={}));var i="secure-fields";function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function s(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){s=!0,o=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return a(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,t):void 0}}(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.")}()}var c=new class{subscribe(e,t){this.subscribers.push([e,t])}unsubscribe(e,t){this.subscribers=this.subscribers.filter((r=>{var n=s(r,2),o=n[0],i=n[1];return o!==e||i.toString()!==t.toString()}))}publish(e,t){this.subscribers.forEach((r=>{var n=s(r,2),o=n[0],i=n[1];return setTimeout((()=>o===e?i(t):null),0)}))}constructor(){var e,t;t=void 0,(e="subscribers")in this?Object.defineProperty(this,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):this[e]=t,this.subscribers=[]}},l=["accesskey","autocapitalize","autocomplete","autofocus","aria-.","class","contenteditable","data-.","dir","draggable","enterkeyhint","hidden","id","inert","inputmode","is","itemid","itemprop","itemref","itemscope","itemtype","lang","nonce","onabort","onautocomplete","onautocompleteerror","onblur","oncancel","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextmenu","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onmousewheel","onpause","onplay","onplaying","onprogress","onratechange","onreset","onresize","onscroll","onseeked","onseeking","onselect","onshow","onsort","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","onvolumechange","onwaiting","popover","role","slot","spellcheck","style","tabindex","title","translate"];function u(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var d={debug:!1,level:"log"},p=(e,t,r)=>{var n=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){u(e,t,r[t])}))}return e}({},d,r),i=n.debug,a=n.level;(i||"true"===localStorage.getItem(o))&&console[a]("Gr4vy - Secure Fields - ".concat(e),t||{})},f=e=>(e!=e.toLowerCase()&&(e=e.replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))),e);function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var y=function(){var e=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(t).reduce(((n,o)=>{var i,a,s=(a=2,function(e){if(Array.isArray(e))return e}(i=o)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){s=!0,o=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw o}}return i}}(i,a)||function(e,t){if(e){if("string"==typeof e)return h(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?h(e,t):void 0}}(i,a)||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.")}()),c=s[0],l=s[1];return(e=>"[object Object]"===Object.prototype.toString.call(e))(l)?n.push(...e(t[c],"".concat((r+c).match(/[a-zA-Z0-9]+/g).join("-"),"-"))):(c=f(c).replace(/^-/,""),n.push(["--".concat(r).concat(c),l])),n}),[])};return e(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})};function b(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function m(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){b(e,t,r[t])}))}return e}function g(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}class v{_postMessage(e){this.frame.contentWindow.postMessage(m({channel:i},e),this.frameUrl)}update(e){this.options=m({},this.options,e);var t=y(m({},this.options.styles,e.styles)),r=g(m({},this.options,e),{styles:t});this._postMessage({type:"update",data:g(m({},r),{styles:t})}),p("Updated field",this.options)}setPlaceholder(e){this.update({placeholder:e})}setStyles(e){this.update({styles:e})}constructor(e){b(this,"frameUrl",void 0),b(this,"parentOrigin",void 0),b(this,"frame",void 0),b(this,"type",void 0),b(this,"options",void 0),b(this,"addEventListener",void 0),b(this,"removeEventListener",void 0);var t=e.frameUrl,r=e.parentOrigin,n=e.font,o=e.options.type,i=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(e.options,["type"]);this.frameUrl=t,this.parentOrigin=r,this.type=o,this.options=i;var a=y(i.styles);this.frame=document.createElement("iframe"),this.frame.id=o,this.frame.src="".concat(t,"/input.html?parentOrigin=").concat(r,"&type=").concat(this.type),this.frame.style.display="block",this.frame.style.height="100%",this.frame.style.border="none",this.frame.style.width="100%",n&&(this.frame.src+="&font=".concat(n)),this.frame.onload=()=>{this._postMessage({type:"update",data:g(m({},this.options),{styles:a})}),p("Added field",this.options)}}}function O(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function w(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){O(e,t,r[t])}))}return e}function j(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}class S{static get Events(){return r}static get version(){}_addField(e,t){if(!(e="string"==typeof e?document.querySelector(e):e))return t;var r,o,i=document.createElement("div");return r=e,o=i,Array.from(r.attributes).forEach((e=>{var t=e.name,r=e.value;l.some((e=>new RegExp(e).test(t)))&&o.setAttribute(t,r)})),(i=o).classList.add("secure-fields__input","secure-fields__input--".concat(f(t.type))),i.appendChild(t.frame),e.parentNode.replaceChild(i,e),window.addEventListener("message",(e=>{var r;if(e.origin===this.frameUrl&&(null===(r=e.data.data)||void 0===r?void 0:r.id)===t.type)switch(e.data.type){case"blur":c.publish("".concat(t.type,":blur"),e.data.data),i.removeAttribute(n.FOCUSED),p("Field blurred",e.data.data);break;case"focus":c.publish("".concat(t.type,":focus"),e.data.data),i.setAttribute(n.FOCUSED,""),p("Field focused",e.data.data);break;case"input":c.publish("".concat(t.type,":input"),e.data.data),e.data.data.valid?i.removeAttribute(n.INVALID):i.setAttribute(n.INVALID,""),e.data.data.autofilled?i.setAttribute(n.AUTOFILLED,""):i.removeAttribute(n.AUTOFILLED),p("Field input changed",e.data.data)}})),t.addEventListener=this.addEventListener,t.removeEventListener=this.removeEventListener,t}addCardNumberField(e,t){return this.cardNumber||(this.cardNumber=new v({frameUrl:this.frameUrl,parentOrigin:this.parentOrigin,font:this.font,options:j(w({label:"Card number"},t),{type:"number"})})),this._addField(e,this.cardNumber)}addSecurityCodeField(e,t){return this.securityCode||(this.securityCode=new v({frameUrl:this.frameUrl,parentOrigin:this.parentOrigin,font:this.font,options:j(w({label:"Security code"},t),{type:"securityCode"})})),this._addField(e,this.securityCode)}addExpiryDateField(e,t){return this.expiryDate||(this.expiryDate=new v({frameUrl:this.frameUrl,parentOrigin:this.parentOrigin,font:this.font,options:j(w({label:"Expiry date"},t),{type:"expiryDate"})})),this._addField(e,this.expiryDate)}addEventListener(e,t){var r=this.type,n="".concat(this.constructor===v?"".concat(r,":"):"").concat(e);c.subscribe(n,t)}removeEventListener(e,t){var r=this.type,n="".concat(this.constructor===v?"".concat(r,":"):"").concat(e);c.unsubscribe(n,t)}submit(){var e=t=>{if(["success","error"].includes(t.data.type)&&t.origin===this.frameUrl&&t.data.channel===i){switch(t.data.type){case"success":c.publish(r.CARD_VAULT_SUCCESS),p("Payment method tokenized successfully");break;case"error":c.publish(r.CARD_VAULT_FAILURE,t.data),p("Failed to update checkout session",t.data.data)}window.removeEventListener("message",e)}};window.addEventListener("message",e),this.controller.contentWindow.postMessage({type:"submit",channel:i},this.frameUrl)}setDebug(e){localStorage.setItem(o,String(e))}addFont(e){this.font=e.replace(/\s/g,"+")}constructor(e){O(this,"config",void 0),O(this,"controller",void 0),O(this,"frameUrl",void 0),O(this,"apiUrl",void 0),O(this,"parentOrigin",void 0),O(this,"font",void 0),O(this,"cardNumber",void 0),O(this,"securityCode",void 0),O(this,"expiryDate",void 0),this.config=w({environment:"production"},e);var t="sandbox"===this.config.environment?"sandbox.":"";this.frameUrl=window.SECURE_FIELDS_FRAME_URL||"https://secure-fields.".concat(t).concat(this.config.gr4vyId,".gr4vy.app"),this.parentOrigin=window.location.origin,this.controller=document.createElement("iframe"),this.controller.id="controller",this.controller.src="".concat(this.frameUrl,"/controller.html?parentOrigin=").concat(this.parentOrigin,"&sessionId=").concat(this.config.sessionId,"&gr4vyId=").concat(this.config.gr4vyId,"&environment=").concat(this.config.environment),this.controller.style.position="absolute",this.controller.style.left="-9999999px",document.body.appendChild(this.controller),window.onload=()=>{c.publish(r.READY,w({version:S.version},this.config))},p("Initialized",j(w({},this.config),{frameUrl:this.frameUrl,parentOrigin:this.parentOrigin})),window.addEventListener("message",(e=>{e.origin===this.frameUrl&&"form-change"===e.data.type&&(c.publish(r.FORM_CHANGE,e.data.data),p("Form change",e.data.data))}))}}return t}()}));
|
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(this,(function(){return function(){"use strict";var e={d:function(t,r){for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{SecureFields:function(){return S},SecureInput:function(){return v}});var r,n,o="@gr4vy-secure-fields-debug";!function(e){e.CARD_VAULT_SUCCESS="card-vault-success",e.CARD_VAULT_FAILURE="card-vault-failure",e.FORM_CHANGE="form-change",e.READY="ready"}(r||(r={})),function(e){e.FOCUSED="data-secure-fields-focused",e.INVALID="data-secure-fields-invalid",e.AUTOFILLED="data-secure-fields-autofilled"}(n||(n={}));var i="secure-fields";function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function s(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){s=!0,o=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return a(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,t):void 0}}(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.")}()}var c=new class{subscribe(e,t){this.subscribers.push([e,t])}unsubscribe(e,t){this.subscribers=this.subscribers.filter((r=>{var n=s(r,2),o=n[0],i=n[1];return o!==e||i.toString()!==t.toString()}))}publish(e,t){this.subscribers.forEach((r=>{var n=s(r,2),o=n[0],i=n[1];return setTimeout((()=>o===e?i(t):null),0)}))}constructor(){var e,t;t=void 0,(e="subscribers")in this?Object.defineProperty(this,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):this[e]=t,this.subscribers=[]}},l=["accesskey","autocapitalize","autocomplete","autofocus","aria-.","class","contenteditable","data-.","dir","draggable","enterkeyhint","hidden","id","inert","inputmode","is","itemid","itemprop","itemref","itemscope","itemtype","lang","nonce","onabort","onautocomplete","onautocompleteerror","onblur","oncancel","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextmenu","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onmousewheel","onpause","onplay","onplaying","onprogress","onratechange","onreset","onresize","onscroll","onseeked","onseeking","onselect","onshow","onsort","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","onvolumechange","onwaiting","popover","role","slot","spellcheck","style","tabindex","title","translate"];function u(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var d={debug:!1,level:"log"},p=(e,t,r)=>{var n=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){u(e,t,r[t])}))}return e}({},d,r),i=n.debug,a=n.level;(i||"true"===localStorage.getItem(o))&&console[a]("Gr4vy - Secure Fields - ".concat(e),t||{})},f=e=>(e!=e.toLowerCase()&&(e=e.replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))),e);function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var y=function(){var e=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.entries(t).reduce(((n,o)=>{var i,a,s=(a=2,function(e){if(Array.isArray(e))return e}(i=o)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){s=!0,o=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw o}}return i}}(i,a)||function(e,t){if(e){if("string"==typeof e)return h(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?h(e,t):void 0}}(i,a)||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.")}()),c=s[0],l=s[1];return(e=>"[object Object]"===Object.prototype.toString.call(e))(l)?n.push(...e(t[c],"".concat((r+c).match(/[a-zA-Z0-9]+/g).join("-"),"-"))):(c=f(c).replace(/^-/,""),n.push(["--".concat(r).concat(c),l])),n}),[])};return e(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})};function b(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function m(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){b(e,t,r[t])}))}return e}function g(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}class v{_postMessage(e){this.frame.contentWindow.postMessage(m({channel:i},e),this.frameUrl)}update(e){this.options=m({},this.options,e);var t=y(m({},this.options.styles,e.styles)),r=g(m({},this.options,e),{styles:t});this._postMessage({type:"update",data:g(m({},r),{styles:t})}),p("Updated field",this.options)}setPlaceholder(e){this.update({placeholder:e})}setStyles(e){this.update({styles:e})}constructor(e){b(this,"frameUrl",void 0),b(this,"parentOrigin",void 0),b(this,"frame",void 0),b(this,"type",void 0),b(this,"options",void 0),b(this,"addEventListener",void 0),b(this,"removeEventListener",void 0);var t=e.frameUrl,r=e.parentOrigin,n=e.font,o=e.options.type,i=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(e.options,["type"]);this.frameUrl=t,this.parentOrigin=r,this.type=o,this.options=i;var a=y(i.styles);this.frame=document.createElement("iframe"),this.frame.id=o,this.frame.src="".concat(t,"/input.html?parentOrigin=").concat(r,"&type=").concat(this.type),this.frame.style.display="block",this.frame.style.height="100%",this.frame.style.border="none",this.frame.style.width="100%",n&&(this.frame.src+="&font=".concat(n)),this.frame.onload=()=>{this._postMessage({type:"update",data:g(m({},this.options),{styles:a})}),p("Added field",this.options)}}}function O(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function w(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){O(e,t,r[t])}))}return e}function j(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}class S{static get Events(){return r}static get version(){return"#97ea48032fae8b446b104507613e25abd0e7587b"}_addField(e,t){if(!(e="string"==typeof e?document.querySelector(e):e))return t;var r,o,i=document.createElement("div");return r=e,o=i,Array.from(r.attributes).forEach((e=>{var t=e.name,r=e.value;l.some((e=>new RegExp(e).test(t)))&&o.setAttribute(t,r)})),(i=o).classList.add("secure-fields__input","secure-fields__input--".concat(f(t.type))),i.appendChild(t.frame),e.parentNode.replaceChild(i,e),window.addEventListener("message",(e=>{var r;if(e.origin===this.frameUrl&&(null===(r=e.data.data)||void 0===r?void 0:r.id)===t.type)switch(e.data.type){case"blur":c.publish("".concat(t.type,":blur"),e.data.data),i.removeAttribute(n.FOCUSED),p("Field blurred",e.data.data);break;case"focus":c.publish("".concat(t.type,":focus"),e.data.data),i.setAttribute(n.FOCUSED,""),p("Field focused",e.data.data);break;case"input":c.publish("".concat(t.type,":input"),e.data.data),e.data.data.valid?i.removeAttribute(n.INVALID):i.setAttribute(n.INVALID,""),e.data.data.autofilled?i.setAttribute(n.AUTOFILLED,""):i.removeAttribute(n.AUTOFILLED),p("Field input changed",e.data.data)}})),t.addEventListener=this.addEventListener,t.removeEventListener=this.removeEventListener,t}addCardNumberField(e,t){return this.cardNumber||(this.cardNumber=new v({frameUrl:this.frameUrl,parentOrigin:this.parentOrigin,font:this.font,options:j(w({label:"Card number"},t),{type:"number"})})),this._addField(e,this.cardNumber)}addSecurityCodeField(e,t){return this.securityCode||(this.securityCode=new v({frameUrl:this.frameUrl,parentOrigin:this.parentOrigin,font:this.font,options:j(w({label:"Security code"},t),{type:"securityCode"})})),this._addField(e,this.securityCode)}addExpiryDateField(e,t){return this.expiryDate||(this.expiryDate=new v({frameUrl:this.frameUrl,parentOrigin:this.parentOrigin,font:this.font,options:j(w({label:"Expiry date"},t),{type:"expiryDate"})})),this._addField(e,this.expiryDate)}addEventListener(e,t){var r=this.type,n="".concat(this.constructor===v?"".concat(r,":"):"").concat(e);c.subscribe(n,t)}removeEventListener(e,t){var r=this.type,n="".concat(this.constructor===v?"".concat(r,":"):"").concat(e);c.unsubscribe(n,t)}submit(){var e=t=>{if(["success","error"].includes(t.data.type)&&t.origin===this.frameUrl&&t.data.channel===i){switch(t.data.type){case"success":c.publish(r.CARD_VAULT_SUCCESS),p("Payment method tokenized successfully");break;case"error":c.publish(r.CARD_VAULT_FAILURE,t.data),p("Failed to update checkout session",t.data.data)}window.removeEventListener("message",e)}};window.addEventListener("message",e),this.controller.contentWindow.postMessage({type:"submit",channel:i},this.frameUrl)}setDebug(e){localStorage.setItem(o,String(e))}addFont(e){this.font=e.replace(/\s/g,"+")}constructor(e){O(this,"config",void 0),O(this,"controller",void 0),O(this,"frameUrl",void 0),O(this,"apiUrl",void 0),O(this,"parentOrigin",void 0),O(this,"font",void 0),O(this,"cardNumber",void 0),O(this,"securityCode",void 0),O(this,"expiryDate",void 0),this.config=w({environment:"production"},e);var t="sandbox"===this.config.environment?"sandbox.":"";this.frameUrl=window.SECURE_FIELDS_FRAME_URL||"https://secure-fields.".concat(t).concat(this.config.gr4vyId,".gr4vy.app"),this.parentOrigin=window.location.origin,this.controller=document.createElement("iframe"),this.controller.id="controller",this.controller.src="".concat(this.frameUrl,"/controller.html?parentOrigin=").concat(this.parentOrigin,"&sessionId=").concat(this.config.sessionId,"&gr4vyId=").concat(this.config.gr4vyId,"&environment=").concat(this.config.environment),this.controller.style.position="absolute",this.controller.style.left="-9999999px",document.body.appendChild(this.controller),window.onload=()=>{c.publish(r.READY,w({version:S.version},this.config))},p("Initialized",j(w({},this.config),{version:S.version,frameUrl:this.frameUrl,parentOrigin:this.parentOrigin})),window.addEventListener("message",(e=>{e.origin===this.frameUrl&&"form-change"===e.data.type&&(c.publish(r.FORM_CHANGE,e.data.data),p("Form change",e.data.data))}))}}return t}()}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gr4vy/secure-fields",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"description": "Gr4vy-hosted secure fields offering advanced theming, PCI compliance, event handling, and more.",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"types": "lib/index",
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
"style-loader": "^3.3.3",
|
|
48
48
|
"ts-patch": "^2.1.0",
|
|
49
49
|
"typedoc": "^0.24.8",
|
|
50
|
-
"typedoc-plugin-missing-exports": "^2.0.
|
|
50
|
+
"typedoc-plugin-missing-exports": "^2.0.1",
|
|
51
51
|
"typescript-transform-paths": "^3.4.6"
|
|
52
52
|
},
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "97ea48032fae8b446b104507613e25abd0e7587b"
|
|
57
57
|
}
|