{"action":"created","issue":{"url":"https://api.github.com/repos/Adyen/CSE-JS/issues/16","repository_url":"https://api.github.com/repos/Adyen/CSE-JS","labels_url":"https://api.github.com/repos/Adyen/CSE-JS/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/Adyen/CSE-JS/issues/16/comments","events_url":"https://api.github.com/repos/Adyen/CSE-JS/issues/16/events","html_url":"https://github.com/Adyen/CSE-JS/issues/16","id":150579854,"number":16,"title":"Node module returns sjcl lib instead of adyen","user":{"login":"agudulin","id":492261,"avatar_url":"https://avatars.githubusercontent.com/u/492261?v=3","gravatar_id":"","url":"https://api.github.com/users/agudulin","html_url":"https://github.com/agudulin","followers_url":"https://api.github.com/users/agudulin/followers","following_url":"https://api.github.com/users/agudulin/following{/other_user}","gists_url":"https://api.github.com/users/agudulin/gists{/gist_id}","starred_url":"https://api.github.com/users/agudulin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agudulin/subscriptions","organizations_url":"https://api.github.com/users/agudulin/orgs","repos_url":"https://api.github.com/users/agudulin/repos","events_url":"https://api.github.com/users/agudulin/events{/privacy}","received_events_url":"https://api.github.com/users/agudulin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-04-23T17:50:05Z","updated_at":"2016-06-30T10:30:07Z","closed_at":null,"body":"When I try to use no-dom version as a node module, I get the wrong object.\r\n\r\n```js\r\n// package.json\r\n\"dependencies\": {\r\n  \"adyen-cse-js\": \"git+https://github.com/Adyen/CSE-JS.git#v0.1.17\"\r\n}\r\n\r\n// app.js\r\nimport adyenEncrypt from 'adyen-cse-js'\r\nconsole.log(adyenEncrypt)\r\n// → Object { cipher, hash, keyexchange, mode, misc, codec, exception, bitArray, prng, random, json, encrypt, decrypt }\r\n```\r\n\r\n### Why\r\n\r\nEvery node module has a `module` variable as a reference to the object representing the current module.\r\n\r\nAnd I figured out that this variable is used in `sjcl` library, and you include this library into your module without any encapsulation.\r\n\r\nAs a result, when I import your library I get `sjcl` library instead.\r\n\r\n### How to fix\r\n\r\nYou may want to wrap [this code](https://github.com/Adyen/CSE-JS/blob/master/js/adyen.encrypt.nodom.js#L149) into closure, and pass an empty object as `module` variable:\r\n\r\n```js\r\n(function (module) {\r\n  // ... current sjcl code on L149\r\n})({});\r\n```\r\n\r\nAlso [after defining AMD module](https://github.com/Adyen/CSE-JS/blob/master/js/adyen.encrypt.nodom.js#L172) it would be great to make it obvious what exactly do we want to export:\r\n\r\n```js\r\n// L172\r\nif (module && module.exports) {\r\n  module.exports = encrypt;\r\n}\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/Adyen/CSE-JS/issues/comments/229621763","html_url":"https://github.com/Adyen/CSE-JS/issues/16#issuecomment-229621763","issue_url":"https://api.github.com/repos/Adyen/CSE-JS/issues/16","id":229621763,"user":{"login":"agudulin","id":492261,"avatar_url":"https://avatars.githubusercontent.com/u/492261?v=3","gravatar_id":"","url":"https://api.github.com/users/agudulin","html_url":"https://github.com/agudulin","followers_url":"https://api.github.com/users/agudulin/followers","following_url":"https://api.github.com/users/agudulin/following{/other_user}","gists_url":"https://api.github.com/users/agudulin/gists{/gist_id}","starred_url":"https://api.github.com/users/agudulin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agudulin/subscriptions","organizations_url":"https://api.github.com/users/agudulin/orgs","repos_url":"https://api.github.com/users/agudulin/repos","events_url":"https://api.github.com/users/agudulin/events{/privacy}","received_events_url":"https://api.github.com/users/agudulin/received_events","type":"User","site_admin":false},"created_at":"2016-06-30T10:30:07Z","updated_at":"2016-06-30T10:30:07Z","body":"however the corresponding PR has been already merged\r\nand this issue can be closed"}}
{"actor":{"display_login":"agudulin"}}