{"action":"created","comment":{"url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/pulls/comments/36790845","id":36790845,"diff_hunk":"@@ -0,0 +1,113 @@\n+'use strict';\n+\n+var crypto = require('crypto');\n+var fs = require('fs');\n+var path = require('path');\n+\n+// The password is not secure because anyone who can get to the file can get\n+// to the app and thus can get the password. The password is used here only to\n+// satisfy the crypto/PKCS12 APIs.\n+var password = 'password';\n+var certname = 'certname';\n+var country = 'country';\n+var organization = 'organization';\n+var pkcs12FileName = '/pkcs12.pfx';\n+var macName = 'SHA256';\n+var hashSizeInBytes = 16;\n+\n+module.exports = {\n+  \n+  pkcs12FileName: pkcs12FileName,","path":"thali/thalicryptomanager.js","position":20,"original_position":20,"commit_id":"c01494eb5e4129540d703f0c35e26a320f77f10b","original_commit_id":"c01494eb5e4129540d703f0c35e26a320f77f10b","user":{"login":"srichal","id":11357884,"avatar_url":"https://avatars.githubusercontent.com/u/11357884?v=3","gravatar_id":"","url":"https://api.github.com/users/srichal","html_url":"https://github.com/srichal","followers_url":"https://api.github.com/users/srichal/followers","following_url":"https://api.github.com/users/srichal/following{/other_user}","gists_url":"https://api.github.com/users/srichal/gists{/gist_id}","starred_url":"https://api.github.com/users/srichal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srichal/subscriptions","organizations_url":"https://api.github.com/users/srichal/orgs","repos_url":"https://api.github.com/users/srichal/repos","events_url":"https://api.github.com/users/srichal/events{/privacy}","received_events_url":"https://api.github.com/users/srichal/received_events","type":"User","site_admin":false},"body":"Done.","created_at":"2015-08-11T19:57:01Z","updated_at":"2015-08-11T19:57:01Z","html_url":"https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r36790845","pull_request_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/pulls/41","_links":{"self":{"href":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/pulls/comments/36790845"},"html":{"href":"https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r36790845"},"pull_request":{"href":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/pulls/41"}}},"pull_request":{"url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/pulls/41","id":40512063,"html_url":"https://github.com/thaliproject/Thali_CordovaPlugin/pull/41","diff_url":"https://github.com/thaliproject/Thali_CordovaPlugin/pull/41.diff","patch_url":"https://github.com/thaliproject/Thali_CordovaPlugin/pull/41.patch","issue_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/issues/41","number":41,"state":"open","locked":false,"title":"Added a new file \"thalicryptomanager.js\" which has an API to obtain the","user":{"login":"srichal","id":11357884,"avatar_url":"https://avatars.githubusercontent.com/u/11357884?v=3","gravatar_id":"","url":"https://api.github.com/users/srichal","html_url":"https://github.com/srichal","followers_url":"https://api.github.com/users/srichal/followers","following_url":"https://api.github.com/users/srichal/following{/other_user}","gists_url":"https://api.github.com/users/srichal/gists{/gist_id}","starred_url":"https://api.github.com/users/srichal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srichal/subscriptions","organizations_url":"https://api.github.com/users/srichal/orgs","repos_url":"https://api.github.com/users/srichal/repos","events_url":"https://api.github.com/users/srichal/events{/privacy}","received_events_url":"https://api.github.com/users/srichal/received_events","type":"User","site_admin":false},"body":"public-key-hash value. Also added new functionality to the \"ThaliReplicationManager.prototype.start\" function where the public-key-hash is obtained for the device and it is added to the DB if needed.\n<a href='#crh-start'></a><a href='#crh-data-%7B%22processed%22%3A%20%5B%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35162586%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35162646%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35162748%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35163221%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35163357%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35228119%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35228278%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35281171%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35281316%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35281388%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35282904%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35284830%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35377318%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35377637%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35378189%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35378331%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35378404%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35378529%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35378731%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35379003%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35379157%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35379212%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35379283%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35726605%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35726635%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35726834%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35726870%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35726919%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35726998%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35882873%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35882982%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35883075%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35883156%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35883211%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35883387%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35883406%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35883495%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35883600%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35883661%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35883904%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35884036%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35884216%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35884302%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35884354%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35884408%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35884440%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36154300%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36154345%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36154705%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36202862%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36202957%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36203065%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36203092%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36204257%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36205733%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36205802%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36205941%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36205994%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36258790%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36259524%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36259535%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36259564%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36259572%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36259648%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36259665%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36365037%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36434831%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36434850%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36434940%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36435270%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36435344%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36435760%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36436016%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36436343%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36436379%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36436402%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36437326%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36445355%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36445400%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36449291%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23issuecomment-128469605%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36491165%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36552767%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36552905%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36553068%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36553649%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36553939%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36553970%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36553998%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36554054%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36554082%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36554519%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36554586%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36554698%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36554932%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36555048%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36555153%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36555266%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36555320%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36567702%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36571186%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36707608%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36707619%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36707626%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36707690%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36707700%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36707718%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36707726%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36707751%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36707767%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36707800%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36763931%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36764097%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36764248%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36764321%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36764625%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36767030%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36767056%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36767127%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36767160%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36769327%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36774522%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36779495%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36779598%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36783508%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36783535%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36786143%22%2C%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36790829%22%5D%2C%20%22comments%22%3A%20%7B%22Pull%203a38f2bfffb4b26172d4c0ce9864a2ddd1d2c750%20thali/thalireplicationmanager.js%204%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35378731%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Why%20is%20addressPrefix%20in%20the%20thalireplicationmanager%3F%20That%20is%20something%20that%20is%20specific%20to%20the%20postcardapp.%20It%20is%20not%20generic%20to%20Thali%20at%20all.%20It%20shouldn%27t%20be%20Thali_CordovaPlugin%2C%20it%20should%20be%20in%20postcardapp.%22%2C%20%22created_at%22%3A%20%222015-07-23T22%3A21%3A35Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Fixed%20as%20part%20of%20the%20redesign%20where%20the%20thalireplicationmanager%20does%20not%20add%20anything%20o%20the%20DB.%22%2C%20%22created_at%22%3A%20%222015-07-29T04%3A14%3A28Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-07-30T15%3A36%3A08Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalireplicationmanager.js%3AL6-13%22%7D%2C%20%22Pull%20698ba1fa9d67efe22e5656685e995b25bc42fa05%20thali/thalicryptomanager.js%2035%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35162748%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Same%20callback%20comment%20as%20above%20and%20again%20in%20line%2042%20and%20so%20on.%22%2C%20%22created_at%22%3A%20%222015-07-21T22%3A33%3A15Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Fixed.%22%2C%20%22created_at%22%3A%20%222015-07-23T00%3A50%3A04Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-07-30T15%3A26%3A58Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalicryptomanager.js%3AL1-95%22%7D%2C%20%22Pull%203a38f2bfffb4b26172d4c0ce9864a2ddd1d2c750%20thali/thalireplicationmanager.js%2060%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35379212%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22There%20should%20be%202%2C%20not%203%20ds%20in%20Addr.%20Actually%20it%27s%20generally%20not%20recommended%20to%20use%20abbreviations.%20Now%20that%20we%20have%20auto-complete%20in%20our%20IDEs%20it%27s%20better%20to%20just%20use%20the%20full%20word%2C%20e.g.%20currentAddressFound.%22%2C%20%22created_at%22%3A%20%222015-07-23T22%3A27%3A45Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22I%20am%20not%20using%20abbreviations%20anymore.%22%2C%20%22created_at%22%3A%20%222015-07-29T04%3A22%3A44Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-07-30T15%3A37%3A55Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalireplicationmanager.js%3AL39-109%22%7D%2C%20%22Pull%208088c23025ee4f6f4b8675fede79a9902c7b455e%20test/www/jxcore/test/mockmobilegetdocpath.js%209%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36554586%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Why%20are%20you%20using%20arguments%3F%20Why%20not%20just%20put%20errArg%20and%20fileLocationArg%20into%20the%20function%20signature%3F%22%2C%20%22created_at%22%3A%20%222015-08-07T19%3A50%3A27Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Fixed.%22%2C%20%22created_at%22%3A%20%222015-08-11T02%3A52%3A59Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-08-11T16%3A15%3A39Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20test/www/jxcore/test/mockmobilegetdocpath.js%3AL1-18%22%7D%2C%20%22Pull%203a38f2bfffb4b26172d4c0ce9864a2ddd1d2c750%20thali/thalireplicationmanager.js%2043%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35379003%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22This%20should%20not%20be%20here%20per%20my%20previous%20comment.%20I%20think%20it%20makes%20sense%20for%20the%20cryptomanager%20to%20be%20here.%20I%20think%20it%20makes%20sense%20for%20the%20cryptomanager%20to%20be%20part%20of%20start%20up%20%28after%20all%2C%20you%20can%27t%20do%20replication%20with%20an%20identity%29.%20I%20even%20think%20it%20makes%20sense%20for%20the%20cryptomanager%20to%20get%20the%20publickeyhash.%20But%20that%20is%20where%20it%20ends.%20That%20publickeyhash%20should%20be%20available%20as%20a%20property%20identifying%20the%20current%20device%20but%20that%27s%20it.%20It%20should%20be%20up%20to%20the%20postcardapp%20to%20then%20get%20that%20publickeyhash%20and%20use%20it%20for%20something.%5Cr%5Cn%5Cr%5CnPlease%20propose%20a%20design%20for%20how%20we%20can%20expose%20the%20publickeyhash%20all%20the%20way%20to%20the%20postcardapp%20in%20a%20manner%20that%20makes%20logical%20sense.%22%2C%20%22created_at%22%3A%20%222015-07-23T22%3A25%3A03Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Completed%20the%20redesign%20as%20proposed.%22%2C%20%22created_at%22%3A%20%222015-07-29T04%3A15%3A25Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-07-30T15%3A36%3A56Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalireplicationmanager.js%3AL39-109%22%7D%2C%20%22Pull%208088c23025ee4f6f4b8675fede79a9902c7b455e%20thali/thalireplicationmanager.js%2056%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36553068%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22All%20switches%20should%20always%20have%20a%20catch%20to%20find%20errors.%20Can%20you%20please%20put%20in%20a%20return%20on%20line%2066%20and%20then%20put%20in%20a%20throw%20if%20we%20get%20past%20line%2067%3F%22%2C%20%22created_at%22%3A%20%222015-08-07T19%3A30%3A34Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Fixed.%22%2C%20%22created_at%22%3A%20%222015-08-11T02%3A51%3A00Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-08-11T16%3A40%3A16Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalireplicationmanager.js%3AL43-136%22%7D%2C%20%22Pull%203a38f2bfffb4b26172d4c0ce9864a2ddd1d2c750%20thali/thalireplicationmanager.js%2061%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35379157%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Again%2C%20this%20is%20postcardapp%20specific.%20It%27s%20not%20generic%20to%20Thali.%20I%20do%20believe%20that%20eventually%20Thali%20should%20have%20a%20central%20address%20book%20store%20and%20when%20we%20work%20on%20ACLs%20and%20identity%20exchange%20we%20will%20add%20one.%20But%20for%20now%20the%20thali%20replication%20manager%20can%20only%20handle%20one%20DB%20at%20a%20time%20so%20we%20agreed%20to%20put%20the%20addressbook%20entries%20in%20it%20but%20that%20should%20be%20an%20app%20level%20%28e.g.%20postcardapp%29%20consideration%2C%20not%20a%20Thali_CordovaPlugin%20consideration.%22%2C%20%22created_at%22%3A%20%222015-07-23T22%3A27%3A03Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Fixed%20as%20part%20of%20the%20redesign.%22%2C%20%22created_at%22%3A%20%222015-07-29T04%3A21%3A23Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-07-30T15%3A37%3A31Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalireplicationmanager.js%3AL39-109%22%7D%2C%20%22Pull%203a38f2bfffb4b26172d4c0ce9864a2ddd1d2c750%20thali/thalicryptomanager.js%2040%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35378331%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Is%20this%20really%20necessary%20in%20the%20log%3F%20Please%20review%20your%20console.log%20statements%20and%20ask%20yourself%20%5C%22Will%20anyone%20benefit%20by%20adding%20all%20of%20this%20to%20the%20log%3F%5C%22%20The%20more%20stuff%20is%20in%20the%20log%20the%20harder%20it%20is%20to%20use%20for%20much%20of%20anything.%20We%20already%20have%20a%20work%20item%20to%20add%20some%20kind%20of%20log%20leveling%20but%20we%20aren%27t%20there%20yet.%22%2C%20%22created_at%22%3A%20%222015-07-23T22%3A16%3A50Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-07-30T15%3A31%3A22Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalicryptomanager.js%3AL1-103%22%7D%2C%20%22Pull%20698ba1fa9d67efe22e5656685e995b25bc42fa05%20thali/thalicryptomanager.js%2092%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35163357%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Why%20did%20you%20go%20through%20all%20the%20trouble%20to%20create%20a%20Buffer%20when%20you%20end%20up%20only%20using%20the%20value%20as%20a%20string%3F%20In%20fact%2C%20when%20would%20it%20ever%20be%20used%20as%20a%20buffer%3F%22%2C%20%22created_at%22%3A%20%222015-07-21T22%3A40%3A59Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Fixed%20by%20returning%20a%20string.%22%2C%20%22created_at%22%3A%20%222015-07-23T01%3A25%3A31Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-07-30T15%3A29%3A30Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalicryptomanager.js%3AL1-95%22%7D%2C%20%22Pull%20c01494eb5e4129540d703f0c35e26a320f77f10b%20thali/thalicryptomanager.js%2020%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36774522%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22We%20should%20never%20be%20exporting%20local%20variables.%20That%20just%20isn%27t%20right.%20At%20a%20minimum%20they%20should%20be%20wrapped%20in%20getter%20functions.%20But%20why%20are%20these%20here%20at%20all%3F%20Are%20you%20having%20binding%20problems%3F%20Is%20this%20for%20testing%3F%20Even%20for%20testing%20we%20should%20have%20setter%20wrappers%20with%20big%20warnings%20on%20them%20that%20they%20are%20only%20for%20testing%20purposes.%22%2C%20%22created_at%22%3A%20%222015-08-11T17%3A42%3A24Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22These%20are%20local%20variables%20in%20cryptomanager.js%20that%20are%20needed%20when%20creating%20the%20pkcs12%20package.%5Cr%5Cn%5Cr%5Cn%20%20%20%20%20%20var%20pkcs12Content%20%3D%20crypto.pkcs12%5Cr%5Cn%20%20%20%20%20%20%20%20.createBundle%28password%2C%20certname%2C%20country%2C%20organization%29%3B%22%2C%20%22created_at%22%3A%20%222015-08-11T19%3A13%3A50Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalicryptomanager.js%3AL1-114%22%7D%2C%20%22General%20Comment%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23issuecomment-128469605%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Learned%20a%20new%20thing%20today%20%3A%29.%20Removed%20the%20function%20as%20it%20only%20had%20one%20line.%22%2C%20%22created_at%22%3A%20%222015-08-06T18%3A38%3A17Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%5D%2C%20%22title%22%3A%20%22General%20Comment%22%7D%2C%20%22Pull%208088c23025ee4f6f4b8675fede79a9902c7b455e%20test/www/jxcore/test/mockmobilegetdocpath.js%2017%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36554519%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Why%20do%20you%20kill%20the%20entire%20mobile%20object%3F%20Wouldn%27t%20it%20make%20much%20more%20sense%20to%20move%20this%20into%20the%20mockmobile%20file%20above%20and%20just%20take%20over%20storeGetDocumentsPathReturnArguments%20and%20GetDocumentsPath%3F%22%2C%20%22created_at%22%3A%20%222015-08-07T19%3A49%3A49Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Actually%20realized%20my%20mistake%20and%20fixed%20this%20before%20seeing%20the%20comment.%22%2C%20%22created_at%22%3A%20%222015-08-11T02%3A52%3A51Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-08-11T16%3A15%3A59Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20test/www/jxcore/test/mockmobilegetdocpath.js%3AL1-18%22%7D%2C%20%22Pull%209d917e15deeebffdf5e86405cb7dbf3189ad2022%20thali/thalireplicationmanager.js%2035%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36435760%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22It%20is%20generally%20considered%20best%20coding%20practice%20to%20avoid%20implementing%20the%20equivalent%20of%20case%20statements%20as%20nested%20if-then-elses.%20It%20is%20hard%20to%20read%20and%20keep%20track%20of%20state.%20A%20much%20cleaner%20solution%2C%20in%20my%20opinion%2C%20is%20to%20just%20use%20return%20statements.%20In%20other%20words%5Cr%5Cn%5Cr%5Cnif%20%28..deviceIdentityAvailable...%29%20%7B%5Cr%5Cn%20%20cb%28%29%3B%5Cr%5Cn%20%20return%3B%5Cr%5Cn%7D%5Cr%5Cn%5Cr%5Cnif%20%28...noDeviceIdentitySet...%29%20%7B%5Cr%5Cn%20%20stuff...%5Cr%5Cn%20%20return%3B%5Cr%5Cn%7D%5Cr%5Cn%5Cr%5Cnif%20%28...gettingDeviceIdentity...%29%20%7B%5Cr%5Cn%20%20blah...%5Cr%5Cn%20%20return%3B%5Cr%5Cn%7D%22%2C%20%22created_at%22%3A%20%222015-08-06T16%3A35%3A00Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Fixed.%22%2C%20%22created_at%22%3A%20%222015-08-06T18%3A03%3A44Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-08-07T19%3A43%3A05Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalireplicationmanager.js%3AL47-101%22%7D%2C%20%22Pull%20fe52ed1cc48102a338cad41f60d4f612e94e36c2%20thali/thalicryptomanager.js%2092%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36204257%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22I%20believe%20this%20code%20suffers%20from%20a%20very%20nasty%20race%20condition%21%20Imagine%20that%20two%20people%20call%20getPKCS12Content%20at%20the%20same%20time%20%28this%20can%20easily%20happen%20if%20two%20calls%20to%20getDeviceIdentity%20are%20made%29%20and%20the%20PKCS12%20file%20doesn%27t%20exist%20yet.%20In%20that%20case%20both%20calls%20can%20get%20false%20on%20line%2070%20%28since%20exists%20is%20an%20async%20function%29%20and%20both%20calls%20can%20successfully%20get%20to%20line%2092%20and%20both%20will%20succeed%20on%20line%2092%20%28since%20writeFile%20is%20async%20and%20explicitly%20overwrites%20if%20the%20file%20already%20exists%29%20and%20so%20there%20will%20be%20two%20callbacks%20with%20two%20difference%20public%20keys%20for%20the%20same%20device%21%5Cr%5Cn%5Cr%5CnThankfully%20I%20think%20there%20is%20a%20pretty%20easy%20fix.%20If%20you%20pass%20in%20the%20%5C%22wx%5C%22%20flag%20to%20writeFile%20then%20it%20should%20fail%20if%20the%20file%20already%20exists.%20In%20that%20case%20exactly%20one%20of%20the%20two%20calls%20would%20succeed%20on%20the%20write%2C%20the%20other%20would%20get%20a%20file%20exists%20error.%22%2C%20%22created_at%22%3A%20%222015-08-04T15%3A47%3A04Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22The%20fix%20will%20not%20work%20entirely...%20The%202nd%20call%20to%20writeFile%20will%20fail%20as%20you%20explained.%20But%20the%202nd%20guy%20who%20called%20getPKCS12Content%20will%20not%20get%20the%20content%20and%20thus%20will%20not%20get%20the%20public%20key%20hash.%5Cr%5Cn%5Cr%5CnThis%20is%20better%20than%20having%20two%20different%20public%20keys%20for%20the%20same%20device%20but%20the%202nd%20guy%20will%20have%20to%20retry%20by%20calling%20getPublicKeyHash%20again.%22%2C%20%22created_at%22%3A%20%222015-08-05T00%3A28%3A49Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22Please%20ignore%20my%20above%20comment.%20You%20already%20mentioned%20the%20issue%20below.%22%2C%20%22created_at%22%3A%20%222015-08-05T00%3A44%3A25Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22Fixed%20as%20suggested.%22%2C%20%22created_at%22%3A%20%222015-08-05T00%3A44%3A43Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-08-06T16%3A41%3A03Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalicryptomanager.js%3AL1-111%22%7D%2C%20%22Pull%20fe52ed1cc48102a338cad41f60d4f612e94e36c2%20thali/thalireplicationmanager.js%204%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36202862%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Why%20introduce%20currentDeviceIdentity%20if%20we%20already%20have%20_deviceName%3F%22%2C%20%22created_at%22%3A%20%222015-08-04T15%3A36%3A10Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Fixed.%22%2C%20%22created_at%22%3A%20%222015-08-05T00%3A42%3A02Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-08-06T16%3A26%3A13Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalireplicationmanager.js%3AL7-15%22%7D%2C%20%22Pull%208088c23025ee4f6f4b8675fede79a9902c7b455e%20test/www/jxcore/test/pkcs12foldergood/.gitignore%203%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36554698%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22I%27m%20confused.%20Why%20would%20you%20need%20to%20tell%20the%20system%20not%20to%20ignore%20.gitignore%3F%20It%20wouldn%27t%20ignore%20it%20anyway%3F%22%2C%20%22created_at%22%3A%20%222015-08-07T19%3A51%3A50Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Will%20fix%20this%20when%20I%20use%20the%20global%20setup%20using%20tape.%22%2C%20%22created_at%22%3A%20%222015-08-11T02%3A55%3A47Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22Deleted%20the%20%5C%22.gitignore%5C%22%20file%20as%20well%20as%20the%20folder%20%5C%22pkcs12foldergood%5C%22.%22%2C%20%22created_at%22%3A%20%222015-08-11T18%3A20%3A56Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20test/www/jxcore/test/pkcs12foldergood/.gitignore%3AL1-4%22%7D%2C%20%22Pull%208088c23025ee4f6f4b8675fede79a9902c7b455e%20test/www/jxcore/test/thalicryptomanagertests.js%2022%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36555320%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22It%27s%20not%20safe%20to%20rely%20on%20test%20execution%20order.%20If%20the%20tests%20get%20moved%20around%20or%20the%20test%20running%20decides%20to%20run%20the%20tests%20in%20a%20different%20order%20%28happens%20all%20the%20time%29%20then%20this%20test%20will%20look%20like%20it%20passed%20but%20in%20fact%20it%20didn%27t%20do%20what%20you%20want.%20What%20you%20really%20need%20to%20do%20is%20first%20call%20the%20PKCS12%20generation%20function%20yourself%20directly.%20Then%20read%20in%20the%20file%20and%20generate%20the%20hash.%20Then%20call%20getPublicKeyHash%20and%20makes%20sure%20it%20returns%20the%20same%20hash%20so%20you%20know%20it%20read%20the%20same%20document.%22%2C%20%22created_at%22%3A%20%222015-08-07T19%3A59%3A46Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Fixed.%22%2C%20%22created_at%22%3A%20%222015-08-11T02%3A53%3A39Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-08-11T16%3A13%3A00Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20test/www/jxcore/test/thalicryptomanagertests.js%3AL1-62%22%7D%2C%20%22Pull%209d917e15deeebffdf5e86405cb7dbf3189ad2022%20thali/thalireplicationmanager.js%20101%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36436016%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Shouldn%27t%20this%20code%20be%20hanging%20out%20with%20the%20rest%20of%20the%20identity%20set%20code%3F%20It%27s%20odd%20to%20separate%20them.%20But%20I%20realize%20this%20was%20probably%20a%20consequence%20of%20my%20comment%20about%20moving%20the%20require%20not%20being%20clear%20enough.%20Sorry.%20But%20could%20you%20please%20re-unite%20informDeviceIdentityListeners%20and%20clearDeviceIdentityListeners%20with%20getDeviceIdentity%3F%22%2C%20%22created_at%22%3A%20%222015-08-06T16%3A37%3A51Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Actually%2C%20Matt%20had%20all%20the%20external%20functions%20at%20the%20top%20followed%20by%20all%20the%20internal%20functions.%20So%20I%20was%20following%20that%20pattern.%20But%20I%20have%20reunited%20the%20functions%20now.%22%2C%20%22created_at%22%3A%20%222015-08-06T18%3A36%3A32Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-08-07T19%3A43%3A54Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalireplicationmanager.js%3AL148-166%22%7D%2C%20%22Pull%20698ba1fa9d67efe22e5656685e995b25bc42fa05%20thali/thalicryptomanager.js%2065%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35163221%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22I%20would%20restructure%20this%20code%20so%20there%20is%20one%20function%20that%20checks%20if%20the%20file%20exists%20and%20if%20not%20creates%20it%20and%20if%20so%20returns%20it.%20So%20in%20either%20case%20the%20function%20will%20return%20the%20file%20contents.%20Then%20I%20would%20have%20code%20that%20takes%20the%20returned%20value%20and%20gets%20the%20public%20key%20and%20generates%20the%20hash.%20that%20way%20we%20wouldn%27t%20have%20identical%20code%20in%20two%20places%20like%20we%20have%20in%2039-46%20and%2065-72%20and%20I%20think%20the%20code%20would%20be%20easier%20to%20read.%22%2C%20%22created_at%22%3A%20%222015-07-21T22%3A39%3A17Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Fixed%20as%20suggested.%22%2C%20%22created_at%22%3A%20%222015-07-23T02%3A13%3A04Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-07-30T15%3A27%3A41Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalicryptomanager.js%3AL1-95%22%7D%2C%20%22Pull%20698ba1fa9d67efe22e5656685e995b25bc42fa05%20thali/thalicryptomanager.js%2025%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35162586%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22We%20should%20follow%20the%20usual%20node.js%20convention%20of%20returning%20an%20error%20in%20the%20first%20argument%20and%20success%20information%20in%20the%20second%20argument.%20So%20we%20should%20be%20returning%20an%20error%20string%20in%20the%20first%20argument%20here%20not%20null.%22%2C%20%22created_at%22%3A%20%222015-07-21T22%3A31%3A10Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Correct%2C%20it%20must%20be%20in%20the%20form%20of%20%60cb%28err%2C%20...args%29%60%20where%20the%20error%20is%20always%20first%20even%20if%20null/undefined%2C%20meaning%20%60cb%28%29%60%20is%20perfectly%20valid%20if%20there%20are%20no%20errors%20and%20no%20return%20value.%22%2C%20%22created_at%22%3A%20%222015-07-22T15%3A49%3A22Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/49051%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/mattpodwysocki%22%7D%7D%2C%20%7B%22body%22%3A%20%22Fixed%20as%20per%20comments.%22%2C%20%22created_at%22%3A%20%222015-07-23T00%3A44%3A48Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-07-30T15%3A25%3A26Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalicryptomanager.js%3AL1-95%22%7D%2C%20%22Pull%208088c23025ee4f6f4b8675fede79a9902c7b455e%20thali/thalireplicationmanager.js%2095%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36552905%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Shouldn%27t%20you%20be%20checking%20the%20flag%27s%20state%20rather%20than%20the%20_deviceName%3F%22%2C%20%22created_at%22%3A%20%222015-08-07T19%3A28%3A47Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Now%20your%20state%20machine%20is%20stretched%20across%20two%20different%20places%2C%20getDeviceIdentity%20and%20here.%20Why%20would%20you%20do%20that%3F%20It%20just%20increases%20the%20probability%20of%20screwing%20something%20up.%20Wouldn%27t%20it%20be%20simpler%20to%20just%20call%20getDeviceIdentity%20and%20in%20the%20callback%20call%20startReplicationManager%3F%20Since%20start%20doesn%27t%20have%20a%20return%20value%20%28it%20instead%20emits%20an%20event%20when%20things%20get%20going%29%20it%20doesn%27t%20matter%20that%20you%20point%20an%20asynchronous%20call%20in%20here%20and%20it%20simplifies%20the%20heck%20out%20of%20your%20code.%22%2C%20%22created_at%22%3A%20%222015-08-07T19%3A42%3A19Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Fixed.%22%2C%20%22created_at%22%3A%20%222015-08-11T02%3A51%3A23Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-08-11T16%3A18%3A06Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalireplicationmanager.js%3AL43-136%22%7D%2C%20%22Pull%20698ba1fa9d67efe22e5656685e995b25bc42fa05%20thali/thalicryptomanager.js%2027%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35162646%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Typically%20just%20concatenating%20paths%20isn%27t%20safe%20across%20OS%27s.%20I%20think%20Node.js%20has%20a%20function%20somewhere%20in%20FS%20to%20handle%20safe%20file%20concatenation.%20Can%20you%20please%20find%20it%20and%20use%20it%3F%22%2C%20%22created_at%22%3A%20%222015-07-21T22%3A32%3A03Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Yes%2C%20use%20%60path.join%60%20https%3A//nodejs.org/api/path.html%23path_path_join_path1_path2%22%2C%20%22created_at%22%3A%20%222015-07-22T15%3A48%3A06Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/49051%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/mattpodwysocki%22%7D%7D%2C%20%7B%22body%22%3A%20%22Fixed%20as%20per%20comments.%22%2C%20%22created_at%22%3A%20%222015-07-23T00%3A48%3A33Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-07-30T15%3A26%3A18Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalicryptomanager.js%3AL1-95%22%7D%2C%20%22Pull%20798cc92aa9292c2a0b542ef7a65abdfe897f3890%20thali/thalicryptomanager.js%2095%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35883211%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22/piblic/public%22%2C%20%22created_at%22%3A%20%222015-07-30T15%3A28%3A12Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22fixed.%22%2C%20%22created_at%22%3A%20%222015-08-04T03%3A13%3A10Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-08-04T16%3A00%3A10Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalicryptomanager.js%3AL1-105%22%7D%2C%20%22Pull%20798cc92aa9292c2a0b542ef7a65abdfe897f3890%20thali/thalicryptomanager.js%2093%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35883387%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22In%20general%20you%20don%27t%20need%20to%20document%20internal%20functions%20and%20you%20especially%20don%27t%20need%20to%20document%20such%20a%20short%20function.%20Typically%20headers%20like%20this%20are%20only%20needed%20on%20public%20functions%20or%20on%20functions%20that%20do%20something%20really%20confusing%20and%20so%20could%20benefit%20from%20extra%20explanation.%20Remember%2C%20comments%20rot.%20So%20we%20only%20want%20to%20use%20them%20when%20the%20value%20they%20bring%20is%20greater%20than%20the%20cost%20of%20maintaining%20them.%22%2C%20%22created_at%22%3A%20%222015-07-30T15%3A29%3A22Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Removed%20the%20documentation.%22%2C%20%22created_at%22%3A%20%222015-08-04T03%3A14%3A29Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-08-04T16%3A00%3A32Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalicryptomanager.js%3AL1-105%22%7D%2C%20%22Pull%203a38f2bfffb4b26172d4c0ce9864a2ddd1d2c750%20thali/thalicryptomanager.js%2018%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35378189%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22This%20description%20is%20not%20correct.%20It%20would%20be%20better%20to%20use%20a%20correct%20description%20which%20is%20that%20this%20function%20looks%20for%20a%20pkcs12%20file%20in%20a%20known%20location%20and%20will%20create%20it%20if%20it%20doesn%27t%20exist%20and%20then%20extract%20the%20public%20key%20and%20return%20its%20SHA256%20hash.%22%2C%20%22created_at%22%3A%20%222015-07-23T22%3A15%3A24Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-07-30T15%3A30%3A44Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalicryptomanager.js%3AL1-103%22%7D%2C%20%22Pull%203a38f2bfffb4b26172d4c0ce9864a2ddd1d2c750%20thali/thalicryptomanager.js%2019%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35378404%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Why%20doesn%27t%20the%20JSDoc%20specify%20the%20callback%3F%20See%20http%3A//usejsdoc.org/tags-callback.html%22%2C%20%22created_at%22%3A%20%222015-07-23T22%3A17%3A57Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-07-30T15%3A33%3A26Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalicryptomanager.js%3AL1-103%22%7D%2C%20%22Pull%20fe52ed1cc48102a338cad41f60d4f612e94e36c2%20thali/thalireplicationmanager.js%2066%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36203065%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Why%20are%20you%20requiring%20this%20down%20here%20rather%20than%20at%20the%20top%20of%20the%20file%3F%22%2C%20%22created_at%22%3A%20%222015-08-04T15%3A37%3A47Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Moved%20the%20getDeviceIdentity%20function%20to%20the%20top%20of%20the%20file.%22%2C%20%22created_at%22%3A%20%222015-08-05T00%3A42%3A40Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22I%20wasn%27t%20referring%20to%20the%20function%20definition.%20I%20was%20referring%20to%20your%20use%20of%20require%28%27./thalicryptomanager%27%29.%20Generally%20it%20is%20considered%20good%20practice%20to%20put%20require%20statements%20at%20the%20top%20of%20the%20file.%20See%20http%3A//justbuildsomething.com/node-js-best-practices/%232%20for%20an%20example%20why.%22%2C%20%22created_at%22%3A%20%222015-08-06T16%3A29%3A45Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22I%20declared%20the%20%5C%22require%5C%22%20here%20as%20it%20%20is%20used%20only%20one%20time%20here.%20But%20you%20are%20right%2C%20it%20is%20better%20to%20put%20it%20at%20the%20top.%20I%20moved%20it%20now.%5Cr%5Cn%22%2C%20%22created_at%22%3A%20%222015-08-06T16%3A49%3A39Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-08-07T19%3A27%3A12Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalireplicationmanager.js%3AL113-141%22%7D%2C%20%22Pull%20fe52ed1cc48102a338cad41f60d4f612e94e36c2%20thali/thalireplicationmanager.js%2067%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36203092%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Please%20remove%20this%20comment.%20When%20the%20function%20is%20called%20%27getPublicKeyHash%27%20it%27s%20pretty%20clear%20what%27s%20going%20on.%22%2C%20%22created_at%22%3A%20%222015-08-04T15%3A38%3A08Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Done.%22%2C%20%22created_at%22%3A%20%222015-08-05T00%3A42%3A55Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-08-06T16%3A30%3A24Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalireplicationmanager.js%3AL113-141%22%7D%2C%20%22Pull%20fe52ed1cc48102a338cad41f60d4f612e94e36c2%20thali/thalireplicationmanager.js%2068%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36205733%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Assuming%20you%20make%20the%20change%20I%20talked%20about%20in%20the%20the%20crypto%20file%20to%20deal%20with%20the%20race%20condition%20we%20still%20have%20a%20problem%20with%20this%20code.%20Which%20is%20that%20if%20the%20function%20gets%20called%20twice%20when%20there%20is%20no%20existing%20PKCS12%20file%20then%20one%20of%20the%20two%20calls%20can%20end%20up%20with%20an%20error%20because%20the%20underlying%20write%20failed.%20That%20sort%20of%20thing%20shouldn%27t%20be%20visible%20%28or%20be%20a%20concern%29%20for%20someone%20calling%20getDeviceIdentity.%5Cr%5Cn%5Cr%5CnThe%20problem%20is%20that%20fixing%20this%20is%20tricky%20because%20it%27s%20possible%20that%20when%20the%20error%20is%20returned%20the%20PKCS12%20file%20may%20have%20been%20created%20but%20currentDeviceIdentity%20hasn%27t%20been%20set%20yet.%5Cr%5Cn%5Cr%5CnThere%20are%20several%20traditional%20ways%20to%20deal%20with%20this%20in%20Node.js%20land%20-%20%5Cr%5Cn%5Cr%5CnPromises%20-%20We%20could%20use%20promises%20to%20work%20around%20this%20by%20creating%20a%20promise%20to%20retrieve%20the%20public%20key%20from%20the%20file%20and%20then%20adding%20any%20cbs%20to%20a%20then%20on%20that%20promise.%20They%20will%20then%20automatically%20be%20run%20once%20the%20ID%20is%20returned.%20But%20I%20don%27t%20think%20it%27s%20worth%20adding%20the%20promises%20library%20%28we%20are%20using%20lie%29%20just%20to%20solve%20this%20one%20issue.%5Cr%5Cn%5Cr%5CnFlags%20-%20Another%20traditional%20approach%20is%20some%20kind%20of%20state%20flag.%20You%20set%20the%20flag%20initially%20to%20%27noDeviceIdentitySet%27%20and%20then%20when%20the%20first%20call%20is%20made%20to%20getDeviceIdentity%20this%20will%20cause%20you%20to%20set%20the%20flag%20to%20%27gettingDeviceKey%27%20and%20you%20will%20then%20make%20the%20call%20to%20getPublicKeyHash.%20Any%20calls%20to%20getDeviceIdentity%20while%20the%20flag%20is%20set%20to%20%27gettingDeviceKey%27%20will%20just%20have%20their%20cb%20added%20to%20a%20cb%20array.%20When%20getPublicKeyHash%20returns%20then%20you%20would%20set%20the%20flag%20to%20%27deviceKeyAvailable%27%20and%20you%20would%20call%20all%20the%20cbs%20in%20the%20arrays.%20Any%20future%20calls%20to%20getDeviceIdentity%20would%20just%20immediately%20return%20the%20value%20since%20the%20state%20is%20%27deviceKeyAvailable%27.%5Cr%5Cn%5Cr%5CnEvent%20Emitter%20-%20The%20third%20approach%20is%20to%20use%20an%20event%20emitter.%20This%20is%20a%20bit%20more%20complicated%20but%20basically%20you%20could%20attach%20the%20CBs%20as%20a%20listener%20to%20the%20event%20emitter%20and%20once%20the%20key%20is%20available%20then%20you%20would%20emit%20the%20event%20which%20would%20trigger%20the%20CBs.%20You%20would%20also%20need%20to%20check%20if%20the%20device%20identity%20is%20already%20available%20and%20skip%20the%20emitter%20all%20together%20in%20that%20case.%20Honestly%20I%20think%20this%20is%20more%20work%20than%20it%27s%20worth.%5Cr%5Cn%5Cr%5CnSo%20my%20suggestion%20would%20be%20the%20flag%20approach.%5Cr%5Cn%5Cr%5Cn%40mattpodwysocki%20-%20What%20do%20you%20think%20is%20the%20best%20way%20to%20handle%20this%20race%20condition%3F%20Or%20is%20there%20no%20race%20condition%20and%20I%27m%20just%20hallucinating%3F%22%2C%20%22created_at%22%3A%20%222015-08-04T15%3A58%3A38Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Fixed%20using%20flags.%22%2C%20%22created_at%22%3A%20%222015-08-05T22%3A59%3A56Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-08-06T16%3A41%3A18Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalireplicationmanager.js%3AL113-141%22%7D%2C%20%22Pull%20c01494eb5e4129540d703f0c35e26a320f77f10b%20thali/thalicryptomanager.js%2018%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36769327%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Although%20this%20use%20of%20module.exports%20is%20technically%20correct%20it%20is%20not%20idiomatic.%20When%20a%20module%20exports%20multiple%20functions%20this%20is%20usually%20handled%20by%20having%20each%20function%20individually%20declared%20using%20exports.x%20%3D%20function%28%29%20%28e.g.%20look%20at%20the%20Exporting%20a%20module%20section%20of%20http%3A//www.sitepoint.com/understanding-module-exports-exports-node-js/%29.%20Please%20update%20accordingly.%5Cr%5Cn%5Cr%5CnThe%20reason%20for%20this%2C%20btw%2C%20is%20to%20make%20it%20easy%20to%20intersperse%20exported%20code%20with%20non-exports%20content%20like%20purely%20local%20functions.%22%2C%20%22created_at%22%3A%20%222015-08-11T16%3A58%3A43Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Fixed.%22%2C%20%22created_at%22%3A%20%222015-08-11T19%3A56%3A50Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalicryptomanager.js%3AL1-114%22%7D%2C%20%22Pull%20c01494eb5e4129540d703f0c35e26a320f77f10b%20thali/thalireplicationmanager.js%2069%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36767127%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22/unknow/unknown/%22%2C%20%22created_at%22%3A%20%222015-08-11T16%3A40%3A01Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22fixed.%22%2C%20%22created_at%22%3A%20%222015-08-11T18%3A51%3A26Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalireplicationmanager.js%3AL43-126%22%7D%2C%20%22Pull%209d917e15deeebffdf5e86405cb7dbf3189ad2022%20thali/thalireplicationmanager.js%20108%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36436343%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Wouldn%27t%20it%20be%20easier%20to%20just%20set%20this._deviceIdentityListeners%20%3D%20%5B%5D%3F%22%2C%20%22created_at%22%3A%20%222015-08-06T16%3A40%3A43Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Learned%20a%20new%20thing%20today%20%3A%29.%20Also%20removed%20the%20function%20as%20it%20only%20has%20one%20line%20now.%22%2C%20%22created_at%22%3A%20%222015-08-07T05%3A01%3A07Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-08-07T19%3A44%3A19Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalireplicationmanager.js%3AL148-166%22%7D%2C%20%22Pull%203a38f2bfffb4b26172d4c0ce9864a2ddd1d2c750%20thali/thalireplicationmanager.js%2070%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35379283%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Please%20don%27t%20check%20into%20story%20main%20with%20a%20todo%20like%20this.%20Please%20add%20in%20the%20error%20handler%21%22%2C%20%22created_at%22%3A%20%222015-07-23T22%3A28%3A42Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22This%20entire%20DB%20operation%20has%20been%20moved%20to%20the%20app.%20I%20also%20handled%20the%20DB%20operation%20error%20there.%22%2C%20%22created_at%22%3A%20%222015-07-29T04%3A24%3A05Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-07-30T15%3A38%3A14Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalireplicationmanager.js%3AL39-109%22%7D%2C%20%22Pull%203a38f2bfffb4b26172d4c0ce9864a2ddd1d2c750%20thali/thalireplicationmanager.js%2015%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35378529%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Where%20is%20the%20jsdoc%20for%20deviceName%3F%22%2C%20%22created_at%22%3A%20%222015-07-23T22%3A19%3A17Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22The%20deviceName%20parameter%20is%20not%20being%20passed%20to%20the%20thalireplicationmanager%27s%20start%20function%20anymore.%20The%20device-name/device-identity%20is%20already%20available%20in%20the%20thalireplicationmanager.%22%2C%20%22created_at%22%3A%20%222015-07-29T04%3A26%3A26Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-07-30T15%3A34%3A26Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalireplicationmanager.js%3AL39-109%22%7D%2C%20%22Pull%208088c23025ee4f6f4b8675fede79a9902c7b455e%20thali/thalireplicationmanager.js%2060%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36553649%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22I%20have%20several%20suggestions%20here.%5Cr%5Cn1.%20I%20would%20suggest%20that%20when%20getDeviceIdentity%20is%20called%20above%20and%20you%20end%20up%20in%20line%2066%20that%20you%20immediately%20just%20add%20cb%20to%20_deviceIdentityListeners.%20Otherwise%20you%20end%20up%20with%20the%20code%20below%20where%20you%20have%20to%20remember%20%28in%20two%20different%20places%29%20to%20call%20informDeviceIdentityListeners%20as%20well%20as%20to%20clean%20up%20the%20cb.%20If%20you%20just%20add%20cb%20to%20_deviceIdentityListeners%20then%20you%20won%27t%20have%20to%20remember%20anything.%5Cr%5Cn2.%20Why%20do%20you%20set%20this_deviceIdentityListeners%20%3D%20%5B%5D%20on%20both%2075%20and%2081%3F%20Since%20you%20have%20to%20do%20it%20in%20both%20places%20why%20not%20just%20set%20that%20line%20after%20line%2083%3F%5Cr%5Cn3.%20If%20you%20implement%20the%20two%20suggestions%20above%20then%20this%20function%20gets%20small%20enough%20that%20I%20would%20suggest%20just%20getting%20rid%20of%20it%20and%20putting%20the%20smaller%20code%20straight%20into%20line%2061.%22%2C%20%22created_at%22%3A%20%222015-08-07T19%3A38%3A35Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22I%20fixed%20%232%20%26%20%233.%20But%20I%20do%20not%20understand%20%231.%20I%20am%20already%20adding%20cb%20to%20_deviceIdentityListeners%20at%20line%2066.%20Please%20clarify.%22%2C%20%22created_at%22%3A%20%222015-08-07T22%3A40%3A43Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22Sorry%2C%20on%20comment%201%20I%20meant%20line%2061%20not%20line%2066%21%20I%20had%20a%20typo.%22%2C%20%22created_at%22%3A%20%222015-08-07T23%3A57%3A33Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Fixed%20all%203.%22%2C%20%22created_at%22%3A%20%222015-08-11T02%3A51%3A15Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-08-11T16%3A39%3A20Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalireplicationmanager.js%3AL43-136%22%7D%2C%20%22Pull%20c01494eb5e4129540d703f0c35e26a320f77f10b%20thali/thalireplicationmanager.js%2060%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36767030%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22I%20think%20this%20code%20has%20a%20race%20condition.%5Cr%5Cn%5Cr%5CnLet%27s%20imagine%20that%20getPublicKeyHash%20fails.%5Cr%5CnSo%20on%20line%2070%20we%20call%20all%20the%20registered%20CBs.%5Cr%5CnOne%20of%20those%20CBs%20then%20immediately%20calls%20back%20into%20getDeviceIdentity%20to%20try%20again.%5Cr%5CnTheir%20request%20will%20hit%20line%2059%20because%20we%20already%20set%20the%20flag%20to%20noDeviceIdentitySet%2C%20they%20will%20then%20have%20their%20CB%20pushed%20onto%20_deviceIdentityListeners%20in%20line%2062%20and%20then%20they%20will%20return%20when%20they%20hit%20line%2063%20because%20it%27s%20asynchronous.%5Cr%5CnAt%20that%20point%20we%20return%20from%20line%2070%20and%20then%20call%20line%2071%20who%20immediately%20erases%20their%20enqueued%20CB.%5Cr%5Cn%5Cr%5CnThis%20is%20the%20kind%20of%20heiseinbug%20that%20drives%20people%20insane.%5Cr%5Cn%5Cr%5CnAnytime%20you%20write%20Javascript%20code%20you%20have%20to%20always%20ask%20yourself%20%5C%22is%20my%20function%20giving%20up%20control%20to%20anyone%20else%3F%5C%22%20because%20the%20minute%20you%20do%20you%20have%20to%20think%20very%20carefully%20about%20re-entrant%20behavior.%5Cr%5Cn%5Cr%5CnI%20suspect%20the%20least%20mind%20bending%20behavior%20to%20fix%20this%20is%20to%20use%20something%20like%20slice%28%29%20or%20equivalent%20to%20create%20a%20local%20copy%20of%20_deviceIdentityListeners%2C%20then%20set%20the%20global%20version%20to%20%5B%5D%20and%20then%20run%20get%20rid%20of%20informDeviceIdentityListeners%20%28since%20you%20only%20use%20it%20one%20place%29%20and%20just%20run%20the%20foreach%20that%20used%20to%20be%20in%20informDeviceIdentityListeners%20directly%20on%20the%20local%20copy.%20That%20should%20make%20everything%20work%20right%20even%20with%20re-entrant%20behavior.%20I%20think.%22%2C%20%22created_at%22%3A%20%222015-08-11T16%3A39%3A06Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Fixed%20as%20suggested.%22%2C%20%22created_at%22%3A%20%222015-08-11T18%3A51%3A06Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalireplicationmanager.js%3AL43-126%22%7D%2C%20%22Pull%208088c23025ee4f6f4b8675fede79a9902c7b455e%20test/www/jxcore/test/thalicryptomanagertests.js%2017%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36555153%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22How%20do%20you%20know%20that%20you%20are%20actually%20getting%20back%20the%20proper%20hash%20of%20a%20properly%20generated%20certificate%3F%20At%20a%20minimum%20you%20should%20read%20in%20the%20pkcs12%20file%20yourself%20and%20run%20the%20hash%20function%20and%20compare%20the%20results%20so%20you%20can%20be%20sure.%22%2C%20%22created_at%22%3A%20%222015-08-07T19%3A57%3A44Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Fixed.%22%2C%20%22created_at%22%3A%20%222015-08-11T02%3A53%3A32Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-08-11T16%3A14%3A23Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20test/www/jxcore/test/thalicryptomanagertests.js%3AL1-62%22%7D%2C%20%22Pull%208088c23025ee4f6f4b8675fede79a9902c7b455e%20test/www/jxcore/test/thalicryptomanagertests.js%203%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36554932%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22This%20is%20going%20to%20break%20when%20you%20merge%20with%20story%200%20because%20we%20no%20longer%20include%20thali%20via%20file%20path%2C%20instead%20its%20now%20a%20normal%20NPM%20dependency.%20So%20this%20path%20should%20become%20%27thali/thalicryptomanager%27%22%2C%20%22created_at%22%3A%20%222015-08-07T19%3A54%3A47Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Will%20fix%20this%20when%20I%20merge%20with%20story-0.%22%2C%20%22created_at%22%3A%20%222015-08-11T02%3A54%3A56Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20test/www/jxcore/test/thalicryptomanagertests.js%3AL1-62%22%7D%2C%20%22Pull%20fe52ed1cc48102a338cad41f60d4f612e94e36c2%20thali/thalireplicationmanager.js%2048%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36202957%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Please%20remove%20the%20comment%20on%20line%2070%20and%2071.%20This%20is%20just%20the%20kind%20of%20comment%20that%20rots%20really%20quickly%20as%20soon%20as%20there%20is%20an%20edit.%20We%20have%20IDEs%20to%20handle%20matching%20squiggly%20braces.%22%2C%20%22created_at%22%3A%20%222015-08-04T15%3A36%3A52Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Fixed.%22%2C%20%22created_at%22%3A%20%222015-08-05T00%3A42%3A15Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-08-06T16%3A27%3A01Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalireplicationmanager.js%3AL67-75%22%7D%2C%20%22Pull%209d917e15deeebffdf5e86405cb7dbf3189ad2022%20thali/thalireplicationmanager.js%2082%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36434831%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22I%20apologize%20if%20I%27m%20missing%20something%20but%20I%20don%27t%20see%20a%20check%20anywhere%20here%20that%20this._deviceName%20is%20actually%20set.%20There%20seems%20to%20be%20an%20assumption%20that%20getDeviceIdentity%20will%20always%20be%20called%20before%20start.%20That%20seems%20like%20a%20dangerous%20assumption%20to%20make.%20If%20in%20fact%20we%20are%20making%20that%20assumption%20then%20I%20would%20suggest%20that%20code%20should%20be%20%27fail%20safe%27.%20That%20is%2C%20either%20start%20should%20fail%20if%20getDeviceIdentity%20hasn%27t%20been%20called%20or%20we%20should%20build%20getDeviceIdentity%20into%20start%20just%20to%20make%20sure.%20The%20later%20seems%20preferable.%5Cr%5Cn%5Cr%5CnSorry%20if%20I%20missed%20where%20deviceName%20was%20guaranteed%20to%20be%20set.%22%2C%20%22created_at%22%3A%20%222015-08-06T16%3A26%3A06Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22Fixed%20by%20building%20getDeviceIdentity%20if%20user%20has%20not%20done%20it%20before%20calling%20start.%22%2C%20%22created_at%22%3A%20%222015-08-06T18%3A03%3A21Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-08-07T19%3A42%3A39Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalireplicationmanager.js%3AL47-101%22%7D%2C%20%22Pull%203a38f2bfffb4b26172d4c0ce9864a2ddd1d2c750%20thali/thalicryptomanager.js%208%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r35377318%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Please%20put%20in%20a%20comment%20specifying%20that%20we%20use%20a%20bogus%20password%20because%20using%20a%20password%20at%20all%20is%20bogus.%20Anyone%20who%20can%20get%20to%20the%20file%20can%20get%20to%20the%20app%20and%20thus%20can%20get%20the%20password.%20So%20we%20just%20include%20something%20because%20the%20API%20expects%20it.%20If%20and%20when%20mobile%20devices%20start%20having%20secure%20key%20stores%20that%20are%20tagged%20to%20app%20IDs%20then%20we%20can%20discuss%20using%20a%20real%20password.%22%2C%20%22created_at%22%3A%20%222015-07-23T22%3A05%3A11Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22I%27ll%20go%20file%20an%20issue%20that%20we%20really%20should%20be%20using%20the%20key%20stores%20on%20both%20iOS%20and%20Android.%20But%20keep%20in%20mind%20that%20this%20only%20provides%20a%20nominal%20security%20benefit%20since%20no%20secure%20hardware%20is%20being%20used.%20Instead%20what%20it%20does%20it%20store%20the%20keys%20in%20an%20encrypted%20file%20based%20off%20the%20device%27s%20key.%20This%20does%20provide%20some%20%28tiny%29%20level%20of%20protection%20for%20unencrypted%20devices.%20For%20devices%20that%20encrypt%20their%20drives%20it%20provides%20no%20meaningful%20protection.%20As%20such%20I%20think%20adding%20in%20support%20for%20local%20keystores%20is%20low%20priority.%22%2C%20%22created_at%22%3A%20%222015-07-23T22%3A08%3A43Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22I%20don%27t%20see%20a%20comment.%22%2C%20%22created_at%22%3A%20%222015-07-30T15%3A30%3A00Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22The%20comment%20was%20added%20in%20a%20different%20place.%20Now%20moved%20it%20here.%22%2C%20%22created_at%22%3A%20%222015-08-04T03%3A25%3A13Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222015-08-04T15%3A59%3A06Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20thali/thalicryptomanager.js%3AL1-103%22%7D%2C%20%22Pull%208088c23025ee4f6f4b8675fede79a9902c7b455e%20test/www/jxcore/test/thalicryptomanagertests.js%208%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/thaliproject/Thali_CordovaPlugin/pull/41%23discussion_r36555048%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22You%20are%20assuming%20this%20location%20exists%20which%20it%20generally%20shouldn%27t%20since%20we%20have%20nothing%20to%20put%20in%20there%20and%20git%20doesn%27t%20record%20directories.%20Instead%20you%20should%20include%20a%20global%20setup%20using%20tape%20and%20just%20have%20it%20create%20the%20directory.%20Also%20please%20make%20sure%20to%20put%20in%20a%20global%20cleanup%20and%20have%20it%20delete%20the%20directory%20and%20its%20contents.%20You%20can%20use%20fs-extras-promise%20to%20handle%20the%20recursive%20delete.%22%2C%20%22created_at%22%3A%20%222015-08-07T19%3A56%3A19Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22BTW%2C%20these%20setup/tear%20downs%20should%20be%20run%20after%20each%20test%20so%20you%20know%20you%20have%20a%20clean%20environment.%22%2C%20%22created_at%22%3A%20%222015-08-07T19%3A59%3A04Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1480964%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/yaronyg%22%7D%7D%2C%20%7B%22body%22%3A%20%22This%20is%20not%20done%20yet.%22%2C%20%22created_at%22%3A%20%222015-08-11T02%3A54%3A21Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%2C%20%7B%22body%22%3A%20%22The%20folder%20where%20the%20pkcs12%20file%20will%20be%20saved%20will%20be%20created%20before%20every%20test%20begins%20and%20deleted%20at%20the%20end%20of%20every%20test.%22%2C%20%22created_at%22%3A%20%222015-08-11T18%3A21%3A44Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/11357884%3Fv%3D3%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/srichal%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20test/www/jxcore/test/thalicryptomanagertests.js%3AL1-62%22%7D%7D%7D'></a>\n<a href='https://www.codereviewhub.com/'><img src='http://www.codereviewhub.com/site/github-bar.png' height=40></a>\n- [ ] <a href='#crh-comment-General Comment'></a> <img src='http://www.codereviewhub.com/site/github-remaining.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#issuecomment-128469605'>General Comment</a></b>\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Learned a new thing today :). Removed the function as it only had one line.\n- [ ] <a href='#crh-comment-Pull 8088c23025ee4f6f4b8675fede79a9902c7b455e test/www/jxcore/test/pkcs12foldergood/.gitignore 3'></a> <img src='http://www.codereviewhub.com/site/github-remaining.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r36554698'>File: test/www/jxcore/test/pkcs12foldergood/.gitignore:L1-4</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> I'm confused. Why would you need to tell the system not to ignore .gitignore? It wouldn't ignore it anyway?\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Will fix this when I use the global setup using tape.\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Deleted the \".gitignore\" file as well as the folder \"pkcs12foldergood\".\n- [ ] <a href='#crh-comment-Pull 8088c23025ee4f6f4b8675fede79a9902c7b455e test/www/jxcore/test/thalicryptomanagertests.js 3'></a> <img src='http://www.codereviewhub.com/site/github-remaining.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r36554932'>File: test/www/jxcore/test/thalicryptomanagertests.js:L1-62</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> This is going to break when you merge with story 0 because we no longer include thali via file path, instead its now a normal NPM dependency. So this path should become 'thali/thalicryptomanager'\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Will fix this when I merge with story-0.\n- [ ] <a href='#crh-comment-Pull 8088c23025ee4f6f4b8675fede79a9902c7b455e test/www/jxcore/test/thalicryptomanagertests.js 8'></a> <img src='http://www.codereviewhub.com/site/github-remaining.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r36555048'>File: test/www/jxcore/test/thalicryptomanagertests.js:L1-62</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> You are assuming this location exists which it generally shouldn't since we have nothing to put in there and git doesn't record directories. Instead you should include a global setup using tape and just have it create the directory. Also please make sure to put in a global cleanup and have it delete the directory and its contents. You can use fs-extras-promise to handle the recursive delete.\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> BTW, these setup/tear downs should be run after each test so you know you have a clean environment.\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> This is not done yet.\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> The folder where the pkcs12 file will be saved will be created before every test begins and deleted at the end of every test.\n- [ ] <a href='#crh-comment-Pull c01494eb5e4129540d703f0c35e26a320f77f10b thali/thalireplicationmanager.js 60'></a> <img src='http://www.codereviewhub.com/site/github-remaining.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r36767030'>File: thali/thalireplicationmanager.js:L43-126</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> I think this code has a race condition.\nLet's imagine that getPublicKeyHash fails.\nSo on line 70 we call all the registered CBs.\nOne of those CBs then immediately calls back into getDeviceIdentity to try again.\nTheir request will hit line 59 because we already set the flag to noDeviceIdentitySet, they will then have their CB pushed onto _deviceIdentityListeners in line 62 and then they will return when they hit line 63 because it's asynchronous.\nAt that point we return from line 70 and then call line 71 who immediately erases their enqueued CB.\nThis is the kind of heiseinbug that drives people insane.\nAnytime you write Javascript code you have to always ask yourself \"is my function giving up control to anyone else?\" because the minute you do you have to think very carefully about re-entrant behavior.\nI suspect the least mind bending behavior to fix this is to use something like slice() or equivalent to create a local copy of _deviceIdentityListeners, then set the global version to [] and then run get rid of informDeviceIdentityListeners (since you only use it one place) and just run the foreach that used to be in informDeviceIdentityListeners directly on the local copy. That should make everything work right even with re-entrant behavior. I think.\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Fixed as suggested.\n- [ ] <a href='#crh-comment-Pull c01494eb5e4129540d703f0c35e26a320f77f10b thali/thalireplicationmanager.js 69'></a> <img src='http://www.codereviewhub.com/site/github-remaining.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r36767127'>File: thali/thalireplicationmanager.js:L43-126</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> /unknow/unknown/\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> fixed.\n- [ ] <a href='#crh-comment-Pull c01494eb5e4129540d703f0c35e26a320f77f10b thali/thalicryptomanager.js 18'></a> <img src='http://www.codereviewhub.com/site/github-remaining.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r36769327'>File: thali/thalicryptomanager.js:L1-114</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> Although this use of module.exports is technically correct it is not idiomatic. When a module exports multiple functions this is usually handled by having each function individually declared using exports.x = function() (e.g. look at the Exporting a module section of http://www.sitepoint.com/understanding-module-exports-exports-node-js/). Please update accordingly.\nThe reason for this, btw, is to make it easy to intersperse exported code with non-exports content like purely local functions.\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Fixed.\n- [ ] <a href='#crh-comment-Pull c01494eb5e4129540d703f0c35e26a320f77f10b thali/thalicryptomanager.js 20'></a> <img src='http://www.codereviewhub.com/site/github-remaining.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r36774522'>File: thali/thalicryptomanager.js:L1-114</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> We should never be exporting local variables. That just isn't right. At a minimum they should be wrapped in getter functions. But why are these here at all? Are you having binding problems? Is this for testing? Even for testing we should have setter wrappers with big warnings on them that they are only for testing purposes.\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> These are local variables in cryptomanager.js that are needed when creating the pkcs12 package.\nvar pkcs12Content = crypto.pkcs12\n.createBundle(password, certname, country, organization);\n- [x] <a href='#crh-comment-Pull 698ba1fa9d67efe22e5656685e995b25bc42fa05 thali/thalicryptomanager.js 25'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r35162586'>File: thali/thalicryptomanager.js:L1-95</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> We should follow the usual node.js convention of returning an error in the first argument and success information in the second argument. So we should be returning an error string in the first argument here not null.\n- <a href='https://github.com/mattpodwysocki'><img border=0 src='https://avatars.githubusercontent.com/u/49051?v=3' height=16 width=16'></a> Correct, it must be in the form of `cb(err, ...args)` where the error is always first even if null/undefined, meaning `cb()` is perfectly valid if there are no errors and no return value.\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Fixed as per comments.\n- [x] <a href='#crh-comment-Pull 698ba1fa9d67efe22e5656685e995b25bc42fa05 thali/thalicryptomanager.js 27'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r35162646'>File: thali/thalicryptomanager.js:L1-95</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> Typically just concatenating paths isn't safe across OS's. I think Node.js has a function somewhere in FS to handle safe file concatenation. Can you please find it and use it?\n- <a href='https://github.com/mattpodwysocki'><img border=0 src='https://avatars.githubusercontent.com/u/49051?v=3' height=16 width=16'></a> Yes, use `path.join` https://nodejs.org/api/path.html#path_path_join_path1_path2\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Fixed as per comments.\n- [x] <a href='#crh-comment-Pull 698ba1fa9d67efe22e5656685e995b25bc42fa05 thali/thalicryptomanager.js 35'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r35162748'>File: thali/thalicryptomanager.js:L1-95</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> Same callback comment as above and again in line 42 and so on.\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Fixed.\n- [x] <a href='#crh-comment-Pull 698ba1fa9d67efe22e5656685e995b25bc42fa05 thali/thalicryptomanager.js 65'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r35163221'>File: thali/thalicryptomanager.js:L1-95</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> I would restructure this code so there is one function that checks if the file exists and if not creates it and if so returns it. So in either case the function will return the file contents. Then I would have code that takes the returned value and gets the public key and generates the hash. that way we wouldn't have identical code in two places like we have in 39-46 and 65-72 and I think the code would be easier to read.\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Fixed as suggested.\n- [x] <a href='#crh-comment-Pull 698ba1fa9d67efe22e5656685e995b25bc42fa05 thali/thalicryptomanager.js 92'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r35163357'>File: thali/thalicryptomanager.js:L1-95</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> Why did you go through all the trouble to create a Buffer when you end up only using the value as a string? In fact, when would it ever be used as a buffer?\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Fixed by returning a string.\n- [x] <a href='#crh-comment-Pull 3a38f2bfffb4b26172d4c0ce9864a2ddd1d2c750 thali/thalicryptomanager.js 8'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r35377318'>File: thali/thalicryptomanager.js:L1-103</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> Please put in a comment specifying that we use a bogus password because using a password at all is bogus. Anyone who can get to the file can get to the app and thus can get the password. So we just include something because the API expects it. If and when mobile devices start having secure key stores that are tagged to app IDs then we can discuss using a real password.\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> I'll go file an issue that we really should be using the key stores on both iOS and Android. But keep in mind that this only provides a nominal security benefit since no secure hardware is being used. Instead what it does it store the keys in an encrypted file based off the device's key. This does provide some (tiny) level of protection for unencrypted devices. For devices that encrypt their drives it provides no meaningful protection. As such I think adding in support for local keystores is low priority.\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> I don't see a comment.\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> The comment was added in a different place. Now moved it here.\n- [x] <a href='#crh-comment-Pull 3a38f2bfffb4b26172d4c0ce9864a2ddd1d2c750 thali/thalicryptomanager.js 18'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r35378189'>File: thali/thalicryptomanager.js:L1-103</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> This description is not correct. It would be better to use a correct description which is that this function looks for a pkcs12 file in a known location and will create it if it doesn't exist and then extract the public key and return its SHA256 hash.\n- [x] <a href='#crh-comment-Pull 3a38f2bfffb4b26172d4c0ce9864a2ddd1d2c750 thali/thalicryptomanager.js 40'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r35378331'>File: thali/thalicryptomanager.js:L1-103</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> Is this really necessary in the log? Please review your console.log statements and ask yourself \"Will anyone benefit by adding all of this to the log?\" The more stuff is in the log the harder it is to use for much of anything. We already have a work item to add some kind of log leveling but we aren't there yet.\n- [x] <a href='#crh-comment-Pull 3a38f2bfffb4b26172d4c0ce9864a2ddd1d2c750 thali/thalicryptomanager.js 19'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r35378404'>File: thali/thalicryptomanager.js:L1-103</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> Why doesn't the JSDoc specify the callback? See http://usejsdoc.org/tags-callback.html\n- [x] <a href='#crh-comment-Pull 3a38f2bfffb4b26172d4c0ce9864a2ddd1d2c750 thali/thalireplicationmanager.js 15'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r35378529'>File: thali/thalireplicationmanager.js:L39-109</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> Where is the jsdoc for deviceName?\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> The deviceName parameter is not being passed to the thalireplicationmanager's start function anymore. The device-name/device-identity is already available in the thalireplicationmanager.\n- [x] <a href='#crh-comment-Pull 3a38f2bfffb4b26172d4c0ce9864a2ddd1d2c750 thali/thalireplicationmanager.js 4'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r35378731'>File: thali/thalireplicationmanager.js:L6-13</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> Why is addressPrefix in the thalireplicationmanager? That is something that is specific to the postcardapp. It is not generic to Thali at all. It shouldn't be Thali_CordovaPlugin, it should be in postcardapp.\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Fixed as part of the redesign where the thalireplicationmanager does not add anything o the DB.\n- [x] <a href='#crh-comment-Pull 3a38f2bfffb4b26172d4c0ce9864a2ddd1d2c750 thali/thalireplicationmanager.js 43'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r35379003'>File: thali/thalireplicationmanager.js:L39-109</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> This should not be here per my previous comment. I think it makes sense for the cryptomanager to be here. I think it makes sense for the cryptomanager to be part of start up (after all, you can't do replication with an identity). I even think it makes sense for the cryptomanager to get the publickeyhash. But that is where it ends. That publickeyhash should be available as a property identifying the current device but that's it. It should be up to the postcardapp to then get that publickeyhash and use it for something.\nPlease propose a design for how we can expose the publickeyhash all the way to the postcardapp in a manner that makes logical sense.\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Completed the redesign as proposed.\n- [x] <a href='#crh-comment-Pull 3a38f2bfffb4b26172d4c0ce9864a2ddd1d2c750 thali/thalireplicationmanager.js 61'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r35379157'>File: thali/thalireplicationmanager.js:L39-109</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> Again, this is postcardapp specific. It's not generic to Thali. I do believe that eventually Thali should have a central address book store and when we work on ACLs and identity exchange we will add one. But for now the thali replication manager can only handle one DB at a time so we agreed to put the addressbook entries in it but that should be an app level (e.g. postcardapp) consideration, not a Thali_CordovaPlugin consideration.\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Fixed as part of the redesign.\n- [x] <a href='#crh-comment-Pull 3a38f2bfffb4b26172d4c0ce9864a2ddd1d2c750 thali/thalireplicationmanager.js 60'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r35379212'>File: thali/thalireplicationmanager.js:L39-109</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> There should be 2, not 3 ds in Addr. Actually it's generally not recommended to use abbreviations. Now that we have auto-complete in our IDEs it's better to just use the full word, e.g. currentAddressFound.\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> I am not using abbreviations anymore.\n- [x] <a href='#crh-comment-Pull 3a38f2bfffb4b26172d4c0ce9864a2ddd1d2c750 thali/thalireplicationmanager.js 70'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r35379283'>File: thali/thalireplicationmanager.js:L39-109</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> Please don't check into story main with a todo like this. Please add in the error handler!\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> This entire DB operation has been moved to the app. I also handled the DB operation error there.\n- [x] <a href='#crh-comment-Pull 798cc92aa9292c2a0b542ef7a65abdfe897f3890 thali/thalicryptomanager.js 95'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r35883211'>File: thali/thalicryptomanager.js:L1-105</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> /piblic/public\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> fixed.\n- [x] <a href='#crh-comment-Pull 798cc92aa9292c2a0b542ef7a65abdfe897f3890 thali/thalicryptomanager.js 93'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r35883387'>File: thali/thalicryptomanager.js:L1-105</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> In general you don't need to document internal functions and you especially don't need to document such a short function. Typically headers like this are only needed on public functions or on functions that do something really confusing and so could benefit from extra explanation. Remember, comments rot. So we only want to use them when the value they bring is greater than the cost of maintaining them.\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Removed the documentation.\n- [x] <a href='#crh-comment-Pull fe52ed1cc48102a338cad41f60d4f612e94e36c2 thali/thalireplicationmanager.js 4'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r36202862'>File: thali/thalireplicationmanager.js:L7-15</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> Why introduce currentDeviceIdentity if we already have _deviceName?\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Fixed.\n- [x] <a href='#crh-comment-Pull fe52ed1cc48102a338cad41f60d4f612e94e36c2 thali/thalireplicationmanager.js 48'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r36202957'>File: thali/thalireplicationmanager.js:L67-75</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> Please remove the comment on line 70 and 71. This is just the kind of comment that rots really quickly as soon as there is an edit. We have IDEs to handle matching squiggly braces.\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Fixed.\n- [x] <a href='#crh-comment-Pull fe52ed1cc48102a338cad41f60d4f612e94e36c2 thali/thalireplicationmanager.js 66'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r36203065'>File: thali/thalireplicationmanager.js:L113-141</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> Why are you requiring this down here rather than at the top of the file?\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Moved the getDeviceIdentity function to the top of the file.\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> I wasn't referring to the function definition. I was referring to your use of require('./thalicryptomanager'). Generally it is considered good practice to put require statements at the top of the file. See http://justbuildsomething.com/node-js-best-practices/#2 for an example why.\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> I declared the \"require\" here as it  is used only one time here. But you are right, it is better to put it at the top. I moved it now.\n- [x] <a href='#crh-comment-Pull fe52ed1cc48102a338cad41f60d4f612e94e36c2 thali/thalireplicationmanager.js 67'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r36203092'>File: thali/thalireplicationmanager.js:L113-141</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> Please remove this comment. When the function is called 'getPublicKeyHash' it's pretty clear what's going on.\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Done.\n- [x] <a href='#crh-comment-Pull fe52ed1cc48102a338cad41f60d4f612e94e36c2 thali/thalicryptomanager.js 92'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r36204257'>File: thali/thalicryptomanager.js:L1-111</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> I believe this code suffers from a very nasty race condition! Imagine that two people call getPKCS12Content at the same time (this can easily happen if two calls to getDeviceIdentity are made) and the PKCS12 file doesn't exist yet. In that case both calls can get false on line 70 (since exists is an async function) and both calls can successfully get to line 92 and both will succeed on line 92 (since writeFile is async and explicitly overwrites if the file already exists) and so there will be two callbacks with two difference public keys for the same device!\nThankfully I think there is a pretty easy fix. If you pass in the \"wx\" flag to writeFile then it should fail if the file already exists. In that case exactly one of the two calls would succeed on the write, the other would get a file exists error.\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> The fix will not work entirely... The 2nd call to writeFile will fail as you explained. But the 2nd guy who called getPKCS12Content will not get the content and thus will not get the public key hash.\nThis is better than having two different public keys for the same device but the 2nd guy will have to retry by calling getPublicKeyHash again.\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Please ignore my above comment. You already mentioned the issue below.\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Fixed as suggested.\n- [x] <a href='#crh-comment-Pull fe52ed1cc48102a338cad41f60d4f612e94e36c2 thali/thalireplicationmanager.js 68'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r36205733'>File: thali/thalireplicationmanager.js:L113-141</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> Assuming you make the change I talked about in the the crypto file to deal with the race condition we still have a problem with this code. Which is that if the function gets called twice when there is no existing PKCS12 file then one of the two calls can end up with an error because the underlying write failed. That sort of thing shouldn't be visible (or be a concern) for someone calling getDeviceIdentity.\nThe problem is that fixing this is tricky because it's possible that when the error is returned the PKCS12 file may have been created but currentDeviceIdentity hasn't been set yet.\nThere are several traditional ways to deal with this in Node.js land -\nPromises - We could use promises to work around this by creating a promise to retrieve the public key from the file and then adding any cbs to a then on that promise. They will then automatically be run once the ID is returned. But I don't think it's worth adding the promises library (we are using lie) just to solve this one issue.\nFlags - Another traditional approach is some kind of state flag. You set the flag initially to 'noDeviceIdentitySet' and then when the first call is made to getDeviceIdentity this will cause you to set the flag to 'gettingDeviceKey' and you will then make the call to getPublicKeyHash. Any calls to getDeviceIdentity while the flag is set to 'gettingDeviceKey' will just have their cb added to a cb array. When getPublicKeyHash returns then you would set the flag to 'deviceKeyAvailable' and you would call all the cbs in the arrays. Any future calls to getDeviceIdentity would just immediately return the value since the state is 'deviceKeyAvailable'.\nEvent Emitter - The third approach is to use an event emitter. This is a bit more complicated but basically you could attach the CBs as a listener to the event emitter and once the key is available then you would emit the event which would trigger the CBs. You would also need to check if the device identity is already available and skip the emitter all together in that case. Honestly I think this is more work than it's worth.\nSo my suggestion would be the flag approach.\n@mattpodwysocki - What do you think is the best way to handle this race condition? Or is there no race condition and I'm just hallucinating?\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Fixed using flags.\n- [x] <a href='#crh-comment-Pull 9d917e15deeebffdf5e86405cb7dbf3189ad2022 thali/thalireplicationmanager.js 82'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r36434831'>File: thali/thalireplicationmanager.js:L47-101</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> I apologize if I'm missing something but I don't see a check anywhere here that this._deviceName is actually set. There seems to be an assumption that getDeviceIdentity will always be called before start. That seems like a dangerous assumption to make. If in fact we are making that assumption then I would suggest that code should be 'fail safe'. That is, either start should fail if getDeviceIdentity hasn't been called or we should build getDeviceIdentity into start just to make sure. The later seems preferable.\nSorry if I missed where deviceName was guaranteed to be set.\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Fixed by building getDeviceIdentity if user has not done it before calling start.\n- [x] <a href='#crh-comment-Pull 9d917e15deeebffdf5e86405cb7dbf3189ad2022 thali/thalireplicationmanager.js 35'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r36435760'>File: thali/thalireplicationmanager.js:L47-101</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> It is generally considered best coding practice to avoid implementing the equivalent of case statements as nested if-then-elses. It is hard to read and keep track of state. A much cleaner solution, in my opinion, is to just use return statements. In other words\nif (..deviceIdentityAvailable...) {\ncb();\nreturn;\n}\nif (...noDeviceIdentitySet...) {\nstuff...\nreturn;\n}\nif (...gettingDeviceIdentity...) {\nblah...\nreturn;\n}\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Fixed.\n- [x] <a href='#crh-comment-Pull 9d917e15deeebffdf5e86405cb7dbf3189ad2022 thali/thalireplicationmanager.js 101'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r36436016'>File: thali/thalireplicationmanager.js:L148-166</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> Shouldn't this code be hanging out with the rest of the identity set code? It's odd to separate them. But I realize this was probably a consequence of my comment about moving the require not being clear enough. Sorry. But could you please re-unite informDeviceIdentityListeners and clearDeviceIdentityListeners with getDeviceIdentity?\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Actually, Matt had all the external functions at the top followed by all the internal functions. So I was following that pattern. But I have reunited the functions now.\n- [x] <a href='#crh-comment-Pull 9d917e15deeebffdf5e86405cb7dbf3189ad2022 thali/thalireplicationmanager.js 108'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r36436343'>File: thali/thalireplicationmanager.js:L148-166</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> Wouldn't it be easier to just set this._deviceIdentityListeners = []?\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Learned a new thing today :). Also removed the function as it only has one line now.\n- [x] <a href='#crh-comment-Pull 8088c23025ee4f6f4b8675fede79a9902c7b455e thali/thalireplicationmanager.js 95'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r36552905'>File: thali/thalireplicationmanager.js:L43-136</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> Shouldn't you be checking the flag's state rather than the _deviceName?\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> Now your state machine is stretched across two different places, getDeviceIdentity and here. Why would you do that? It just increases the probability of screwing something up. Wouldn't it be simpler to just call getDeviceIdentity and in the callback call startReplicationManager? Since start doesn't have a return value (it instead emits an event when things get going) it doesn't matter that you point an asynchronous call in here and it simplifies the heck out of your code.\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Fixed.\n- [x] <a href='#crh-comment-Pull 8088c23025ee4f6f4b8675fede79a9902c7b455e thali/thalireplicationmanager.js 56'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r36553068'>File: thali/thalireplicationmanager.js:L43-136</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> All switches should always have a catch to find errors. Can you please put in a return on line 66 and then put in a throw if we get past line 67?\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Fixed.\n- [x] <a href='#crh-comment-Pull 8088c23025ee4f6f4b8675fede79a9902c7b455e thali/thalireplicationmanager.js 60'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r36553649'>File: thali/thalireplicationmanager.js:L43-136</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> I have several suggestions here.\n1. I would suggest that when getDeviceIdentity is called above and you end up in line 66 that you immediately just add cb to _deviceIdentityListeners. Otherwise you end up with the code below where you have to remember (in two different places) to call informDeviceIdentityListeners as well as to clean up the cb. If you just add cb to _deviceIdentityListeners then you won't have to remember anything.\n2. Why do you set this_deviceIdentityListeners = [] on both 75 and 81? Since you have to do it in both places why not just set that line after line 83?\n3. If you implement the two suggestions above then this function gets small enough that I would suggest just getting rid of it and putting the smaller code straight into line 61.\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> I fixed #2 & #3. But I do not understand #1. I am already adding cb to _deviceIdentityListeners at line 66. Please clarify.\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> Sorry, on comment 1 I meant line 61 not line 66! I had a typo.\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Fixed all 3.\n- [x] <a href='#crh-comment-Pull 8088c23025ee4f6f4b8675fede79a9902c7b455e test/www/jxcore/test/mockmobilegetdocpath.js 17'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r36554519'>File: test/www/jxcore/test/mockmobilegetdocpath.js:L1-18</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> Why do you kill the entire mobile object? Wouldn't it make much more sense to move this into the mockmobile file above and just take over storeGetDocumentsPathReturnArguments and GetDocumentsPath?\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Actually realized my mistake and fixed this before seeing the comment.\n- [x] <a href='#crh-comment-Pull 8088c23025ee4f6f4b8675fede79a9902c7b455e test/www/jxcore/test/mockmobilegetdocpath.js 9'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r36554586'>File: test/www/jxcore/test/mockmobilegetdocpath.js:L1-18</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> Why are you using arguments? Why not just put errArg and fileLocationArg into the function signature?\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Fixed.\n- [x] <a href='#crh-comment-Pull 8088c23025ee4f6f4b8675fede79a9902c7b455e test/www/jxcore/test/thalicryptomanagertests.js 17'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r36555153'>File: test/www/jxcore/test/thalicryptomanagertests.js:L1-62</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> How do you know that you are actually getting back the proper hash of a properly generated certificate? At a minimum you should read in the pkcs12 file yourself and run the hash function and compare the results so you can be sure.\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Fixed.\n- [x] <a href='#crh-comment-Pull 8088c23025ee4f6f4b8675fede79a9902c7b455e test/www/jxcore/test/thalicryptomanagertests.js 22'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41#discussion_r36555320'>File: test/www/jxcore/test/thalicryptomanagertests.js:L1-62</a></b>\n- <a href='https://github.com/yaronyg'><img border=0 src='https://avatars.githubusercontent.com/u/1480964?v=3' height=16 width=16'></a> It's not safe to rely on test execution order. If the tests get moved around or the test running decides to run the tests in a different order (happens all the time) then this test will look like it passed but in fact it didn't do what you want. What you really need to do is first call the PKCS12 generation function yourself directly. Then read in the file and generate the hash. Then call getPublicKeyHash and makes sure it returns the same hash so you know it read the same document.\n- <a href='https://github.com/srichal'><img border=0 src='https://avatars.githubusercontent.com/u/11357884?v=3' height=16 width=16'></a> Fixed.\n\n\n<a href='https://www.codereviewhub.com/thaliproject/Thali_CordovaPlugin/pull/41?mark_as_completed=1'><img src='http://www.codereviewhub.com/site/github-mark-as-completed.png' height=26></a>&nbsp;<a href='https://www.codereviewhub.com/thaliproject/Thali_CordovaPlugin/pull/41?approve=1'><img src='http://www.codereviewhub.com/site/github-approve.png' height=26></a>&nbsp;<a href='https://github.com/thaliproject/Thali_CordovaPlugin/pull/41'><img src='http://www.codereviewhub.com/site/github-refresh.png' height=26></a>\n<a href='#crh-end'></a>","created_at":"2015-07-21T22:26:41Z","updated_at":"2015-08-11T19:57:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ba4535eb092c2bdf05f229f73048292ec7778073","assignee":null,"milestone":{"url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/milestones/3","html_url":"https://github.com/thaliproject/Thali_CordovaPlugin/milestones/0.0%20-%20Bring%20in%20the%20public%20keys","labels_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/milestones/3/labels","id":1224751,"number":3,"title":"0.0 - Bring in the public keys","description":"","creator":{"login":"yaronyg","id":1480964,"avatar_url":"https://avatars.githubusercontent.com/u/1480964?v=3","gravatar_id":"","url":"https://api.github.com/users/yaronyg","html_url":"https://github.com/yaronyg","followers_url":"https://api.github.com/users/yaronyg/followers","following_url":"https://api.github.com/users/yaronyg/following{/other_user}","gists_url":"https://api.github.com/users/yaronyg/gists{/gist_id}","starred_url":"https://api.github.com/users/yaronyg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yaronyg/subscriptions","organizations_url":"https://api.github.com/users/yaronyg/orgs","repos_url":"https://api.github.com/users/yaronyg/repos","events_url":"https://api.github.com/users/yaronyg/events{/privacy}","received_events_url":"https://api.github.com/users/yaronyg/received_events","type":"User","site_admin":false},"open_issues":5,"closed_issues":0,"state":"open","created_at":"2015-07-24T20:06:48Z","updated_at":"2015-08-07T18:41:33Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/pulls/41/commits","review_comments_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/pulls/41/comments","review_comment_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/issues/41/comments","statuses_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/statuses/c01494eb5e4129540d703f0c35e26a320f77f10b","head":{"label":"thaliproject:story_00_srichal","ref":"story_00_srichal","sha":"c01494eb5e4129540d703f0c35e26a320f77f10b","user":{"login":"thaliproject","id":7918300,"avatar_url":"https://avatars.githubusercontent.com/u/7918300?v=3","gravatar_id":"","url":"https://api.github.com/users/thaliproject","html_url":"https://github.com/thaliproject","followers_url":"https://api.github.com/users/thaliproject/followers","following_url":"https://api.github.com/users/thaliproject/following{/other_user}","gists_url":"https://api.github.com/users/thaliproject/gists{/gist_id}","starred_url":"https://api.github.com/users/thaliproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thaliproject/subscriptions","organizations_url":"https://api.github.com/users/thaliproject/orgs","repos_url":"https://api.github.com/users/thaliproject/repos","events_url":"https://api.github.com/users/thaliproject/events{/privacy}","received_events_url":"https://api.github.com/users/thaliproject/received_events","type":"Organization","site_admin":false},"repo":{"id":36732493,"name":"Thali_CordovaPlugin","full_name":"thaliproject/Thali_CordovaPlugin","owner":{"login":"thaliproject","id":7918300,"avatar_url":"https://avatars.githubusercontent.com/u/7918300?v=3","gravatar_id":"","url":"https://api.github.com/users/thaliproject","html_url":"https://github.com/thaliproject","followers_url":"https://api.github.com/users/thaliproject/followers","following_url":"https://api.github.com/users/thaliproject/following{/other_user}","gists_url":"https://api.github.com/users/thaliproject/gists{/gist_id}","starred_url":"https://api.github.com/users/thaliproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thaliproject/subscriptions","organizations_url":"https://api.github.com/users/thaliproject/orgs","repos_url":"https://api.github.com/users/thaliproject/repos","events_url":"https://api.github.com/users/thaliproject/events{/privacy}","received_events_url":"https://api.github.com/users/thaliproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/thaliproject/Thali_CordovaPlugin","description":"Thali p2p plugin ","fork":false,"url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin","forks_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/forks","keys_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/teams","hooks_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/hooks","issue_events_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/issues/events{/number}","events_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/events","assignees_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/assignees{/user}","branches_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/branches{/branch}","tags_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/tags","blobs_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/statuses/{sha}","languages_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/languages","stargazers_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/stargazers","contributors_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/contributors","subscribers_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/subscribers","subscription_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/subscription","commits_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/contents/{+path}","compare_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/merges","archive_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/downloads","issues_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/issues{/number}","pulls_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/pulls{/number}","milestones_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/milestones{/number}","notifications_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/labels{/name}","releases_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/releases{/id}","created_at":"2015-06-02T12:45:51Z","updated_at":"2015-08-06T22:35:27Z","pushed_at":"2015-08-11T16:51:35Z","git_url":"git://github.com/thaliproject/Thali_CordovaPlugin.git","ssh_url":"git@github.com:thaliproject/Thali_CordovaPlugin.git","clone_url":"https://github.com/thaliproject/Thali_CordovaPlugin.git","svn_url":"https://github.com/thaliproject/Thali_CordovaPlugin","homepage":null,"size":1285,"stargazers_count":8,"watchers_count":8,"language":"Objective-C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":29,"forks":2,"open_issues":29,"watchers":8,"default_branch":"master"}},"base":{"label":"thaliproject:story_00","ref":"story_00","sha":"44902025f1bd37a26394b15c4299b88fbc9cd895","user":{"login":"thaliproject","id":7918300,"avatar_url":"https://avatars.githubusercontent.com/u/7918300?v=3","gravatar_id":"","url":"https://api.github.com/users/thaliproject","html_url":"https://github.com/thaliproject","followers_url":"https://api.github.com/users/thaliproject/followers","following_url":"https://api.github.com/users/thaliproject/following{/other_user}","gists_url":"https://api.github.com/users/thaliproject/gists{/gist_id}","starred_url":"https://api.github.com/users/thaliproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thaliproject/subscriptions","organizations_url":"https://api.github.com/users/thaliproject/orgs","repos_url":"https://api.github.com/users/thaliproject/repos","events_url":"https://api.github.com/users/thaliproject/events{/privacy}","received_events_url":"https://api.github.com/users/thaliproject/received_events","type":"Organization","site_admin":false},"repo":{"id":36732493,"name":"Thali_CordovaPlugin","full_name":"thaliproject/Thali_CordovaPlugin","owner":{"login":"thaliproject","id":7918300,"avatar_url":"https://avatars.githubusercontent.com/u/7918300?v=3","gravatar_id":"","url":"https://api.github.com/users/thaliproject","html_url":"https://github.com/thaliproject","followers_url":"https://api.github.com/users/thaliproject/followers","following_url":"https://api.github.com/users/thaliproject/following{/other_user}","gists_url":"https://api.github.com/users/thaliproject/gists{/gist_id}","starred_url":"https://api.github.com/users/thaliproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thaliproject/subscriptions","organizations_url":"https://api.github.com/users/thaliproject/orgs","repos_url":"https://api.github.com/users/thaliproject/repos","events_url":"https://api.github.com/users/thaliproject/events{/privacy}","received_events_url":"https://api.github.com/users/thaliproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/thaliproject/Thali_CordovaPlugin","description":"Thali p2p plugin ","fork":false,"url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin","forks_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/forks","keys_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/teams","hooks_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/hooks","issue_events_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/issues/events{/number}","events_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/events","assignees_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/assignees{/user}","branches_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/branches{/branch}","tags_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/tags","blobs_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/statuses/{sha}","languages_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/languages","stargazers_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/stargazers","contributors_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/contributors","subscribers_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/subscribers","subscription_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/subscription","commits_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/contents/{+path}","compare_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/merges","archive_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/downloads","issues_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/issues{/number}","pulls_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/pulls{/number}","milestones_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/milestones{/number}","notifications_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/labels{/name}","releases_url":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/releases{/id}","created_at":"2015-06-02T12:45:51Z","updated_at":"2015-08-06T22:35:27Z","pushed_at":"2015-08-11T16:51:35Z","git_url":"git://github.com/thaliproject/Thali_CordovaPlugin.git","ssh_url":"git@github.com:thaliproject/Thali_CordovaPlugin.git","clone_url":"https://github.com/thaliproject/Thali_CordovaPlugin.git","svn_url":"https://github.com/thaliproject/Thali_CordovaPlugin","homepage":null,"size":1285,"stargazers_count":8,"watchers_count":8,"language":"Objective-C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":29,"forks":2,"open_issues":29,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/pulls/41"},"html":{"href":"https://github.com/thaliproject/Thali_CordovaPlugin/pull/41"},"issue":{"href":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/issues/41"},"comments":{"href":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/issues/41/comments"},"review_comments":{"href":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/pulls/41/comments"},"review_comment":{"href":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/pulls/41/commits"},"statuses":{"href":"https://api.github.com/repos/thaliproject/Thali_CordovaPlugin/statuses/c01494eb5e4129540d703f0c35e26a320f77f10b"}}}}