Adyen / adyen-cse-web

[DEPRECATED] Client-side encryption on JavaScript
MIT License
15 stars 39 forks source link

About adyen.enrypt.nodom and window object #3

Closed ikryvanos closed 9 years ago

ikryvanos commented 9 years ago

Hello,

I'm a developer, which integrating you library with angular app. I need to implement lazy loading of you library. As always I wrap code into anonymous function and add definition of empty object with name window, then eval this code after ajax load. But I got exception on line 153. Because of this function a(c, d, e, b) { // c is a window (replaced by my fake) object // because of addEventListener is not defined it is not a function if (typeof c.addEventListener === "function") { c.addEventListener(d, e, b) } else { // also attachEvent is not defined if (c.attachEvent) { c.attachEvent("on" + d, e) } else { // there is throw exception, but encrypt is not defined yet, because it defined on line 162 throw new Error(encrypt.errors.UNABLETOBIND + ": Unable to bind " + d + "-event") } } } I don't understand, why you need to use window object in "nodom" library. May be it is not bug, but looks like. May be you have version of you library which fully nodom?

ArnoudAdyen commented 9 years ago

Hi,

Thank you for reporting. From a defensive programming perspective this is a bug I will look into, and make sure that the library shall not crash if the window object isn't there.

And you are correct to assume that the library is not fully DOM independent. The library does keep track of events on the window object to provide input for randomization in fallback scenario's. We are also looking into using specific events on the window as input for user behavior tracking we can use for anti fraud measures.

The nodom library is a variant in which only the form handling has been removed and allow for integration where developers implement their own form handling instead of using the plain vanilla implementation.

I hope to bring out a new version of the library next week because of other request involved. I will look into fixing this bug as well if time allows me.

Kind regards.

Arnoud

ikryvanos commented 9 years ago

Thank you

ArnoudAdyen commented 9 years ago

Hi,

Slightly delayed but the V0_1_13 should work in your given scenario. Please let me know if it doesn't.

Kind regards,

Arnoud