sigs.js 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103
  1. // Generated by IcedCoffeeScript 1.7.1-c
  2. (function() {
  3. var AnnouncementSigGen, BaseSigGen, CoinbaseProofGen, CryptocurrencySigGen, DnsProofGen, E, GenericWebSiteProofGen, GithubProofGen, HackerNewsProofGen, KeybaseProofGen, KeybasePushProofGen, RedditProofGen, RevokeProofSigGen, SignatureEngine, SocialNetworkProofGen, TrackerProofGen, TwitterProofGen, UntrackerProofGen, colors, constants, decode, env, iced, log, make_esc, master_ring, proofs, req, scrapers, session, strip_at, url_reencode, urlmod, __iced_k, __iced_k_noop,
  4. __hasProp = {}.hasOwnProperty,
  5. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  6. iced = require('iced-runtime').iced;
  7. __iced_k = __iced_k_noop = function() {};
  8. proofs = require('keybase-proofs');
  9. make_esc = require('iced-error').make_esc;
  10. req = require('./req');
  11. constants = require('./constants').constants;
  12. session = require('./session');
  13. env = require('./env').env;
  14. log = require('./log');
  15. master_ring = require('./keyring').master_ring;
  16. decode = require('pgp-utils').armor.decode;
  17. colors = require('./colors');
  18. E = require('./err').E;
  19. req = require('./req');
  20. urlmod = require('url');
  21. scrapers = require('./scrapers');
  22. url_reencode = function(url) {
  23. var pad2;
  24. pad2 = function(x) {
  25. if (x.length === 1) {
  26. return "0" + x;
  27. } else {
  28. return x;
  29. }
  30. };
  31. return url.replace(/%20/g, '+').replace(/[()']/g, function(c) {
  32. return "%" + pad2(c.charCodeAt(0).toString(16));
  33. });
  34. };
  35. BaseSigGen = (function() {
  36. function BaseSigGen(_arg) {
  37. this.km = _arg.km, this.eldest_kid = _arg.eldest_kid, this.client = _arg.client, this.supersede = _arg.supersede, this.merkle_root = _arg.merkle_root, this.revoke_sig_ids = _arg.revoke_sig_ids;
  38. }
  39. BaseSigGen.prototype._get_seqno_type = function() {
  40. return "PUBLIC";
  41. };
  42. BaseSigGen.prototype._get_announce_number = function(cb) {
  43. var body, err, type, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  44. __iced_k = __iced_k_noop;
  45. ___iced_passed_deferral = iced.findDeferral(arguments);
  46. type = this._get_seqno_type();
  47. (function(_this) {
  48. return (function(__iced_k) {
  49. __iced_deferrals = new iced.Deferrals(__iced_k, {
  50. parent: ___iced_passed_deferral,
  51. filename: "/home/jacko/node-client/src/sigs.iced",
  52. funcname: "BaseSigGen._get_announce_number"
  53. });
  54. req.get({
  55. endpoint: "sig/next_seqno",
  56. args: {
  57. type: type
  58. }
  59. }, __iced_deferrals.defer({
  60. assign_fn: (function() {
  61. return function() {
  62. err = arguments[0];
  63. return body = arguments[1];
  64. };
  65. })(),
  66. lineno: 40
  67. }));
  68. __iced_deferrals._fulfill();
  69. });
  70. })(this)((function(_this) {
  71. return function() {
  72. if (typeof err === "undefined" || err === null) {
  73. _this.seqno = body.seqno;
  74. _this.prev = body.prev;
  75. }
  76. return cb(err);
  77. };
  78. })(this));
  79. };
  80. BaseSigGen.prototype._get_binding_eng = function() {
  81. var arg, sig_ids;
  82. arg = {
  83. sig_eng: new SignatureEngine({
  84. km: this.km
  85. }),
  86. seqno: this.seqno,
  87. prev: this.prev,
  88. host: constants.canonical_host,
  89. user: {
  90. local: {
  91. uid: session.get_uid(),
  92. username: env().get_username()
  93. }
  94. },
  95. client: this.client,
  96. merkle_root: this.merkle_root,
  97. eldest_kid: this.eldest_kid
  98. };
  99. if ((sig_ids = this.revoke_sig_ids) != null) {
  100. arg.revoke = {
  101. sig_ids: sig_ids
  102. };
  103. }
  104. return this._make_binding_eng(arg);
  105. };
  106. BaseSigGen.prototype._do_signature = function(cb) {
  107. var err, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  108. __iced_k = __iced_k_noop;
  109. ___iced_passed_deferral = iced.findDeferral(arguments);
  110. this.eng = this._get_binding_eng();
  111. (function(_this) {
  112. return (function(__iced_k) {
  113. __iced_deferrals = new iced.Deferrals(__iced_k, {
  114. parent: ___iced_passed_deferral,
  115. filename: "/home/jacko/node-client/src/sigs.iced",
  116. funcname: "BaseSigGen._do_signature"
  117. });
  118. _this.eng.generate(__iced_deferrals.defer({
  119. assign_fn: (function(__slot_1) {
  120. return function() {
  121. err = arguments[0];
  122. return __slot_1.sig = arguments[1];
  123. };
  124. })(_this),
  125. lineno: 70
  126. }));
  127. __iced_deferrals._fulfill();
  128. });
  129. })(this)((function(_this) {
  130. return function() {
  131. return cb(err);
  132. };
  133. })(this));
  134. };
  135. BaseSigGen.prototype._v_modify_store_arg = function(arg) {};
  136. BaseSigGen.prototype._get_api_endpoint = function() {
  137. return "sig/post";
  138. };
  139. BaseSigGen.prototype.expect_proof_text = function() {
  140. return false;
  141. };
  142. BaseSigGen.prototype._store_signature = function(cb) {
  143. var args, body, endpoint, err, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  144. __iced_k = __iced_k_noop;
  145. ___iced_passed_deferral = iced.findDeferral(arguments);
  146. args = {
  147. sig: this.sig.pgp,
  148. sig_id_base: this.sig.id,
  149. sig_id_short: this.sig.short_id,
  150. is_remote_proof: true,
  151. supersede: this.supersede
  152. };
  153. this._v_modify_store_arg(args);
  154. endpoint = this._get_api_endpoint();
  155. log.debug("+ storing signature:");
  156. log.debug("| writing to " + endpoint);
  157. log.debug("| with args " + (JSON.stringify(args)));
  158. (function(_this) {
  159. return (function(__iced_k) {
  160. __iced_deferrals = new iced.Deferrals(__iced_k, {
  161. parent: ___iced_passed_deferral,
  162. filename: "/home/jacko/node-client/src/sigs.iced",
  163. funcname: "BaseSigGen._store_signature"
  164. });
  165. req.post({
  166. need_cookie: true,
  167. endpoint: endpoint,
  168. args: args
  169. }, __iced_deferrals.defer({
  170. assign_fn: (function() {
  171. return function() {
  172. err = arguments[0];
  173. return body = arguments[1];
  174. };
  175. })(),
  176. lineno: 97
  177. }));
  178. __iced_deferrals._fulfill();
  179. });
  180. })(this)((function(_this) {
  181. return function() {
  182. if (typeof err === "undefined" || err === null) {
  183. _this.proof_text = body.proof_text, _this.proof_id = body.proof_id, _this.sig_id = body.sig_id, _this.proof_metadata = body.proof_metadata;
  184. log.debug("| reply with value: " + (JSON.stringify(body)));
  185. }
  186. (function(__iced_k) {
  187. if (!(typeof err !== "undefined" && err !== null) && _this.expect_proof_text()) {
  188. (function(__iced_k) {
  189. if (_this.proof_text == null) {
  190. return __iced_k(err = new Error("Server didn't reply with proof text"));
  191. } else {
  192. (function(__iced_k) {
  193. __iced_deferrals = new iced.Deferrals(__iced_k, {
  194. parent: ___iced_passed_deferral,
  195. filename: "/home/jacko/node-client/src/sigs.iced",
  196. funcname: "BaseSigGen._store_signature"
  197. });
  198. _this.eng.sanity_check_proof_text({
  199. args: args,
  200. proof_text: _this.proof_text
  201. }, __iced_deferrals.defer({
  202. assign_fn: (function() {
  203. return function() {
  204. return err = arguments[0];
  205. };
  206. })(),
  207. lineno: 107
  208. }));
  209. __iced_deferrals._fulfill();
  210. })(function() {
  211. return __iced_k(err != null ? log.warn("Server replied with a suspect proof text") : void 0);
  212. });
  213. }
  214. })(__iced_k);
  215. } else {
  216. return __iced_k();
  217. }
  218. })(function() {
  219. log.debug("- stored signature (err = " + (typeof err !== "undefined" && err !== null ? err.message : void 0) + ")");
  220. return cb(err);
  221. });
  222. };
  223. })(this));
  224. };
  225. BaseSigGen.prototype.run = function(cb) {
  226. var esc, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  227. __iced_k = __iced_k_noop;
  228. ___iced_passed_deferral = iced.findDeferral(arguments);
  229. esc = make_esc(cb, "BaseSigGen::run");
  230. (function(_this) {
  231. return (function(__iced_k) {
  232. __iced_deferrals = new iced.Deferrals(__iced_k, {
  233. parent: ___iced_passed_deferral,
  234. filename: "/home/jacko/node-client/src/sigs.iced",
  235. funcname: "BaseSigGen.run"
  236. });
  237. _this._get_announce_number(esc(__iced_deferrals.defer({
  238. lineno: 118
  239. })));
  240. __iced_deferrals._fulfill();
  241. });
  242. })(this)((function(_this) {
  243. return function() {
  244. (function(__iced_k) {
  245. __iced_deferrals = new iced.Deferrals(__iced_k, {
  246. parent: ___iced_passed_deferral,
  247. filename: "/home/jacko/node-client/src/sigs.iced",
  248. funcname: "BaseSigGen.run"
  249. });
  250. _this._do_signature(esc(__iced_deferrals.defer({
  251. lineno: 119
  252. })));
  253. __iced_deferrals._fulfill();
  254. })(function() {
  255. (function(__iced_k) {
  256. __iced_deferrals = new iced.Deferrals(__iced_k, {
  257. parent: ___iced_passed_deferral,
  258. filename: "/home/jacko/node-client/src/sigs.iced",
  259. funcname: "BaseSigGen.run"
  260. });
  261. _this._store_signature(esc(__iced_deferrals.defer({
  262. lineno: 120
  263. })));
  264. __iced_deferrals._fulfill();
  265. })(function() {
  266. return cb(null, _this.sig);
  267. });
  268. });
  269. };
  270. })(this));
  271. };
  272. BaseSigGen.prototype.normalize_name = function(n, cb) {
  273. var klass, ret;
  274. klass = this._binding_klass();
  275. ret = klass.normalize_name(n);
  276. return cb(null, ret);
  277. };
  278. BaseSigGen.prototype.show_proof_text = function() {
  279. return this.proof_text;
  280. };
  281. BaseSigGen.prototype.check_name = function(s) {
  282. return this._binding_klass().check_name(s);
  283. };
  284. BaseSigGen.prototype.check_name_input = function(s) {
  285. return this.check_name(s);
  286. };
  287. BaseSigGen.prototype.single_occupancy = function() {
  288. return this._binding_klass().single_occupancy();
  289. };
  290. BaseSigGen.prototype.get_warnings = function(_arg) {
  291. _arg;
  292. return [];
  293. };
  294. BaseSigGen.prototype.do_recheck = function(i) {
  295. return true;
  296. };
  297. BaseSigGen.prototype.do_precheck = function(_arg, cb) {
  298. var remote_name_normalized;
  299. remote_name_normalized = _arg.remote_name_normalized;
  300. return cb(null);
  301. };
  302. BaseSigGen.prototype.make_retry_msg = function(code) {
  303. return "Didn't find the posted proof.";
  304. };
  305. return BaseSigGen;
  306. })();
  307. exports.KeybaseProofGen = KeybaseProofGen = (function(_super) {
  308. __extends(KeybaseProofGen, _super);
  309. function KeybaseProofGen() {
  310. return KeybaseProofGen.__super__.constructor.apply(this, arguments);
  311. }
  312. KeybaseProofGen.prototype._v_modify_store_arg = function(arg) {
  313. arg.type = "web_service_binding.keybase";
  314. return arg.is_remote_proof = false;
  315. };
  316. KeybaseProofGen.prototype._make_binding_eng = function(arg) {
  317. return new proofs.KeybaseBinding(arg);
  318. };
  319. return KeybaseProofGen;
  320. })(BaseSigGen);
  321. exports.KeybasePushProofGen = KeybasePushProofGen = (function(_super) {
  322. __extends(KeybasePushProofGen, _super);
  323. function KeybasePushProofGen() {
  324. return KeybasePushProofGen.__super__.constructor.apply(this, arguments);
  325. }
  326. KeybasePushProofGen.prototype._store_signature = function(cb) {
  327. return cb(null);
  328. };
  329. KeybasePushProofGen.prototype._make_binding_eng = function(arg) {
  330. return new proofs.KeybaseBinding(arg);
  331. };
  332. return KeybasePushProofGen;
  333. })(BaseSigGen);
  334. exports.CryptocurrencySigGen = CryptocurrencySigGen = (function(_super) {
  335. __extends(CryptocurrencySigGen, _super);
  336. function CryptocurrencySigGen(args) {
  337. this.cryptocurrency = args.cryptocurrency;
  338. CryptocurrencySigGen.__super__.constructor.call(this, args);
  339. }
  340. CryptocurrencySigGen.prototype._make_binding_eng = function(arg) {
  341. arg.cryptocurrency = this.cryptocurrency;
  342. return new proofs.Cryptocurrency(arg);
  343. };
  344. CryptocurrencySigGen.prototype._v_modify_store_arg = function(arg) {
  345. arg.type = "cryptocurrency";
  346. return arg.is_remote_proof = false;
  347. };
  348. return CryptocurrencySigGen;
  349. })(BaseSigGen);
  350. exports.AnnouncementSigGen = AnnouncementSigGen = (function(_super) {
  351. __extends(AnnouncementSigGen, _super);
  352. function AnnouncementSigGen(args) {
  353. this.announcement = args.announcement;
  354. AnnouncementSigGen.__super__.constructor.call(this, args);
  355. }
  356. AnnouncementSigGen.prototype._make_binding_eng = function(arg) {
  357. arg.announcement = this.announcement;
  358. return new proofs.Announcement(arg);
  359. };
  360. AnnouncementSigGen.prototype._v_modify_store_arg = function(arg) {
  361. arg.type = "announcement";
  362. return arg.is_remote_proof = false;
  363. };
  364. return AnnouncementSigGen;
  365. })(BaseSigGen);
  366. exports.TrackerProofGen = TrackerProofGen = (function(_super) {
  367. __extends(TrackerProofGen, _super);
  368. function TrackerProofGen(args) {
  369. this.prev = args.prev, this.seqno = args.seqno, this.uid = args.uid, this.track = args.track;
  370. TrackerProofGen.__super__.constructor.call(this, args);
  371. }
  372. TrackerProofGen.prototype._get_announce_number = function(cb) {
  373. return cb(null);
  374. };
  375. TrackerProofGen.prototype._make_binding_eng = function(arg) {
  376. arg.track = this.track;
  377. return new proofs.Track(arg);
  378. };
  379. TrackerProofGen.prototype._v_modify_store_arg = function(arg) {
  380. arg.uid = this.uid;
  381. return arg.type = "track";
  382. };
  383. TrackerProofGen.prototype._get_api_endpoint = function() {
  384. return "follow";
  385. };
  386. return TrackerProofGen;
  387. })(BaseSigGen);
  388. exports.UntrackerProofGen = UntrackerProofGen = (function(_super) {
  389. __extends(UntrackerProofGen, _super);
  390. function UntrackerProofGen(args) {
  391. this.uid = args.uid, this.untrack = args.untrack, this.seqno = args.seqno, this.prev = args.prev;
  392. UntrackerProofGen.__super__.constructor.call(this, args);
  393. }
  394. UntrackerProofGen.prototype._get_announce_number = function(cb) {
  395. return cb(null);
  396. };
  397. UntrackerProofGen.prototype._make_binding_eng = function(arg) {
  398. arg.untrack = this.untrack;
  399. return new proofs.Untrack(arg);
  400. };
  401. UntrackerProofGen.prototype._v_modify_store_arg = function(arg) {
  402. arg.uid = this.uid;
  403. return arg.type = "untrack";
  404. };
  405. UntrackerProofGen.prototype._get_api_endpoint = function() {
  406. return "follow";
  407. };
  408. return UntrackerProofGen;
  409. })(BaseSigGen);
  410. strip_at = function(x) {
  411. if ((x != null) && x.length && x[0] === '@') {
  412. return x.slice(1);
  413. } else {
  414. return x;
  415. }
  416. };
  417. SocialNetworkProofGen = (function(_super) {
  418. __extends(SocialNetworkProofGen, _super);
  419. function SocialNetworkProofGen(args) {
  420. this.remote_username = args.remote_name_normalized;
  421. SocialNetworkProofGen.__super__.constructor.call(this, args);
  422. }
  423. SocialNetworkProofGen.prototype._make_binding_eng = function(args) {
  424. var klass;
  425. args.user.remote = this.remote_username;
  426. klass = this._binding_klass();
  427. return new klass(args);
  428. };
  429. SocialNetworkProofGen.prototype._v_modify_store_arg = function(arg) {
  430. arg.remote_username = this.remote_username;
  431. return arg.type = "web_service_binding." + this._remote_service_name();
  432. };
  433. SocialNetworkProofGen.prototype.get_prompt = function() {
  434. return "Your username on " + (this.display_name());
  435. };
  436. SocialNetworkProofGen.prototype.prompter = function() {
  437. var klass, ret;
  438. klass = this._binding_klass();
  439. ret = {
  440. prompt: this.get_prompt(),
  441. checker: {
  442. f: klass.check_name,
  443. hint: klass.name_hint(),
  444. normalize: klass.normalize_name
  445. }
  446. };
  447. return ret;
  448. };
  449. SocialNetworkProofGen.prototype.expect_proof_text = function() {
  450. return true;
  451. };
  452. return SocialNetworkProofGen;
  453. })(BaseSigGen);
  454. exports.RevokeProofSigGen = RevokeProofSigGen = (function(_super) {
  455. __extends(RevokeProofSigGen, _super);
  456. function RevokeProofSigGen(args) {
  457. this.revoke_sig_id = args.sig_id;
  458. RevokeProofSigGen.__super__.constructor.call(this, args);
  459. }
  460. RevokeProofSigGen.prototype._make_binding_eng = function(args) {
  461. args.revoke = {
  462. sig_id: this.revoke_sig_id
  463. };
  464. return new proofs.Revoke(args);
  465. };
  466. RevokeProofSigGen.prototype._v_modify_store_arg = function(arg) {
  467. return arg.revoke_sig_id = this.revoke_sig_id;
  468. };
  469. RevokeProofSigGen.prototype._get_api_endpoint = function() {
  470. return "sig/revoke";
  471. };
  472. return RevokeProofSigGen;
  473. })(BaseSigGen);
  474. exports.DnsProofGen = DnsProofGen = (function(_super) {
  475. __extends(DnsProofGen, _super);
  476. DnsProofGen.prototype._binding_klass = function() {
  477. return proofs.DnsBinding;
  478. };
  479. function DnsProofGen(args) {
  480. this.remote_host = args.remote_name_normalized;
  481. DnsProofGen.__super__.constructor.call(this, args);
  482. }
  483. DnsProofGen.prototype._make_binding_eng = function(args) {
  484. var klass;
  485. args.remote_host = this.remote_host;
  486. klass = this._binding_klass();
  487. return new klass(args);
  488. };
  489. DnsProofGen.prototype._v_modify_store_arg = function(arg) {
  490. arg.remote_host = this.remote_host;
  491. return arg.type = "web_service_binding.dns";
  492. };
  493. DnsProofGen.prototype.instructions = function() {
  494. var h, hosts, search;
  495. search = [this.remote_host, ["_keybase", this.remote_host].join(".")];
  496. hosts = ((function() {
  497. var _i, _len, _results;
  498. _results = [];
  499. for (_i = 0, _len = search.length; _i < _len; _i++) {
  500. h = search[_i];
  501. _results.push(colors.bold(h));
  502. }
  503. return _results;
  504. })()).join(" OR ");
  505. return "Please save the following as a DNS TXT entry for " + hosts;
  506. };
  507. DnsProofGen.prototype.display_name = function() {
  508. return this.remote_host;
  509. };
  510. DnsProofGen.prototype.prompter = function() {
  511. var klass;
  512. klass = this._binding_klass();
  513. return {
  514. prompt: "DNS Domain to check",
  515. checker: {
  516. f: (function(_this) {
  517. return function(i) {
  518. return _this.check_name_input(i);
  519. };
  520. })(this),
  521. hint: klass.name_hint()
  522. }
  523. };
  524. };
  525. DnsProofGen.prototype.check_name_input = function(i) {
  526. return this._binding_klass().check_name(i);
  527. };
  528. DnsProofGen.prototype.normalize_name = function(i, cb) {
  529. var err, u;
  530. u = this._binding_klass().parse(i);
  531. if (u == null) {
  532. err = new E.ArgsError("Failed to parse " + i + " as a DNS domain");
  533. }
  534. return cb(err, u);
  535. };
  536. DnsProofGen.prototype.do_recheck = function(i) {
  537. log.info("We couldn't find a DNS proof for " + this.remote_host + "....." + (colors.bold('yet')));
  538. log.info("DNS propagation can be slow; we'll keep trying and email you the result.");
  539. return false;
  540. };
  541. return DnsProofGen;
  542. })(BaseSigGen);
  543. exports.GenericWebSiteProofGen = GenericWebSiteProofGen = (function(_super) {
  544. __extends(GenericWebSiteProofGen, _super);
  545. GenericWebSiteProofGen.prototype._binding_klass = function() {
  546. return proofs.GenericWebSiteBinding;
  547. };
  548. function GenericWebSiteProofGen(args) {
  549. this.remote_host = args.remote_name_normalized;
  550. GenericWebSiteProofGen.__super__.constructor.call(this, args);
  551. }
  552. GenericWebSiteProofGen.prototype._make_binding_eng = function(args) {
  553. var klass;
  554. args.remote_host = this.remote_host;
  555. klass = this._binding_klass();
  556. return new klass(args);
  557. };
  558. GenericWebSiteProofGen.prototype._v_modify_store_arg = function(arg) {
  559. arg.remote_host = this.remote_host;
  560. return arg.type = "web_service_binding.generic";
  561. };
  562. GenericWebSiteProofGen.prototype.styled_filenames = function(h) {
  563. var f, files;
  564. files = this.filenames(h);
  565. return ((function() {
  566. var _i, _len, _results;
  567. _results = [];
  568. for (_i = 0, _len = files.length; _i < _len; _i++) {
  569. f = files[_i];
  570. _results.push(colors.bold(f));
  571. }
  572. return _results;
  573. })()).join("\n or ");
  574. };
  575. GenericWebSiteProofGen.prototype.instructions = function() {
  576. return "Please save the following file as " + (this.styled_filenames());
  577. };
  578. GenericWebSiteProofGen.prototype.display_name = function() {
  579. return this.filenames().join(' OR ');
  580. };
  581. GenericWebSiteProofGen.prototype.filenames = function(h) {
  582. var f, files, _i, _len, _results;
  583. files = proofs.GenericWebSiteScraper.FILES;
  584. _results = [];
  585. for (_i = 0, _len = files.length; _i < _len; _i++) {
  586. f = files[_i];
  587. _results.push((h || this.remote_host) + "/" + f);
  588. }
  589. return _results;
  590. };
  591. GenericWebSiteProofGen.prototype.prompter = function() {
  592. var klass;
  593. klass = this._binding_klass();
  594. return {
  595. prompt: "Hostname to check",
  596. checker: {
  597. f: (function(_this) {
  598. return function(i) {
  599. return _this.check_name_input(i);
  600. };
  601. })(this),
  602. hint: klass.name_hint()
  603. }
  604. };
  605. };
  606. GenericWebSiteProofGen.prototype.rewrite_hostname = function(i) {
  607. if (!i.match(/^https?:\/\//)) {
  608. i = "https://" + i;
  609. }
  610. return i;
  611. };
  612. GenericWebSiteProofGen.prototype.check_name_input = function(i) {
  613. return this._binding_klass().check_name(this.rewrite_hostname(i));
  614. };
  615. GenericWebSiteProofGen.prototype.get_warnings = function(_arg) {
  616. var remote_name_normalized;
  617. remote_name_normalized = _arg.remote_name_normalized;
  618. return ["You'll be asked to post a file available at", " " + this.styled_filenames(remote_name_normalized)];
  619. };
  620. GenericWebSiteProofGen.prototype.normalize_name = function(i, cb) {
  621. var args, err, hostname, n, protocol, res, ret, u, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  622. __iced_k = __iced_k_noop;
  623. ___iced_passed_deferral = iced.findDeferral(arguments);
  624. n = this.rewrite_hostname(i);
  625. u = this._binding_klass().parse(n);
  626. ret = null;
  627. (function(_this) {
  628. return (function(__iced_k) {
  629. if (u == null) {
  630. return __iced_k(err = new E.ArgsError("Failed to parse " + i + " is a valid internet host"));
  631. } else {
  632. hostname = u.hostname;
  633. args = {
  634. endpoint: "remotes/check",
  635. args: {
  636. hostname: hostname
  637. }
  638. };
  639. (function(__iced_k) {
  640. __iced_deferrals = new iced.Deferrals(__iced_k, {
  641. parent: ___iced_passed_deferral,
  642. filename: "/home/jacko/node-client/src/sigs.iced",
  643. funcname: "GenericWebSiteProofGen.normalize_name"
  644. });
  645. req.get(args, __iced_deferrals.defer({
  646. assign_fn: (function() {
  647. return function() {
  648. err = arguments[0];
  649. return res = arguments[1];
  650. };
  651. })(),
  652. lineno: 414
  653. }));
  654. __iced_deferrals._fulfill();
  655. })(function() {
  656. var _ref;
  657. return __iced_k(err != null ? void 0 : (protocol = typeof res !== "undefined" && res !== null ? (_ref = res.results) != null ? _ref.first : void 0 : void 0) == null ? err = new E.HostError("Host " + n + " is down; tried 'http' and 'https' protocols") : i.match(/^https:\/\//) && (protocol !== 'https:') ? err = new E.SecurityError("You specified HTTPS for " + i + " but only HTTP is available") : ret = urlmod.format({
  658. protocol: protocol,
  659. hostname: hostname
  660. }));
  661. });
  662. }
  663. });
  664. })(this)((function(_this) {
  665. return function() {
  666. return cb(err, ret);
  667. };
  668. })(this));
  669. };
  670. GenericWebSiteProofGen.prototype.expect_proof_text = function() {
  671. return true;
  672. };
  673. return GenericWebSiteProofGen;
  674. })(BaseSigGen);
  675. exports.TwitterProofGen = TwitterProofGen = (function(_super) {
  676. __extends(TwitterProofGen, _super);
  677. function TwitterProofGen() {
  678. return TwitterProofGen.__super__.constructor.apply(this, arguments);
  679. }
  680. TwitterProofGen.prototype._binding_klass = function() {
  681. return proofs.TwitterBinding;
  682. };
  683. TwitterProofGen.prototype._remote_service_name = function() {
  684. return "twitter";
  685. };
  686. TwitterProofGen.prototype.imperative_verb = function() {
  687. return "tweet";
  688. };
  689. TwitterProofGen.prototype.display_name = function() {
  690. return "Twitter";
  691. };
  692. TwitterProofGen.prototype.instructions = function() {
  693. return "Please " + (colors.bold('publicly')) + " tweet the following:";
  694. };
  695. TwitterProofGen.prototype.make_retry_msg = function(status) {
  696. switch (status) {
  697. case proofs.constants.v_codes.PERMISSION_DENIED:
  698. return "Permission denied! We can't support private feeds.";
  699. default:
  700. return TwitterProofGen.__super__.make_retry_msg.call(this);
  701. }
  702. };
  703. return TwitterProofGen;
  704. })(SocialNetworkProofGen);
  705. exports.RedditProofGen = RedditProofGen = (function(_super) {
  706. __extends(RedditProofGen, _super);
  707. function RedditProofGen() {
  708. return RedditProofGen.__super__.constructor.apply(this, arguments);
  709. }
  710. RedditProofGen.prototype._binding_klass = function() {
  711. return proofs.RedditBinding;
  712. };
  713. RedditProofGen.prototype._remote_service_name = function() {
  714. return "reddit";
  715. };
  716. RedditProofGen.prototype.imperative_verb = function() {
  717. return "post";
  718. };
  719. RedditProofGen.prototype.display_name = function() {
  720. return "Reddit";
  721. };
  722. RedditProofGen.prototype.instructions = function() {
  723. return "Please click on the following link to post to Reddit:";
  724. };
  725. RedditProofGen.prototype.show_proof_text = function() {
  726. var body, title;
  727. body = this.proof_text;
  728. title = this.proof_metadata.title;
  729. return url_reencode(urlmod.format({
  730. protocol: "https",
  731. host: "www.reddit.com",
  732. pathname: "/r/KeybaseProofs/submit",
  733. query: {
  734. title: this.proof_metadata.title,
  735. text: this.proof_text
  736. }
  737. }));
  738. };
  739. return RedditProofGen;
  740. })(SocialNetworkProofGen);
  741. exports.GithubProofGen = GithubProofGen = (function(_super) {
  742. __extends(GithubProofGen, _super);
  743. function GithubProofGen() {
  744. return GithubProofGen.__super__.constructor.apply(this, arguments);
  745. }
  746. GithubProofGen.prototype._binding_klass = function() {
  747. return proofs.GithubBinding;
  748. };
  749. GithubProofGen.prototype._remote_service_name = function() {
  750. return "github";
  751. };
  752. GithubProofGen.prototype.imperative_verb = function() {
  753. return "post a Gist with";
  754. };
  755. GithubProofGen.prototype.display_name = function() {
  756. return "GitHub";
  757. };
  758. GithubProofGen.prototype.instructions = function() {
  759. return "Please " + (colors.bold('publicly')) + " post the following Gist, and name it " + (colors.bold(colors.red('keybase.md'))) + ":";
  760. };
  761. GithubProofGen.prototype.make_retry_msg = function(status) {
  762. switch (status) {
  763. case proofs.constants.v_codes.PERMISSION_DENIED:
  764. return "Permission denied! Make sure your Gist is public";
  765. default:
  766. return GithubProofGen.__super__.make_retry_msg.call(this);
  767. }
  768. };
  769. return GithubProofGen;
  770. })(SocialNetworkProofGen);
  771. exports.HackerNewsProofGen = HackerNewsProofGen = (function(_super) {
  772. __extends(HackerNewsProofGen, _super);
  773. function HackerNewsProofGen() {
  774. return HackerNewsProofGen.__super__.constructor.apply(this, arguments);
  775. }
  776. HackerNewsProofGen.prototype._binding_klass = function() {
  777. return proofs.HackerNewsBinding;
  778. };
  779. HackerNewsProofGen.prototype._remote_service_name = function() {
  780. return "hackernews";
  781. };
  782. HackerNewsProofGen.prototype.imperative_verb = function() {
  783. return "update your profile with";
  784. };
  785. HackerNewsProofGen.prototype.display_name = function() {
  786. return "HackerNews";
  787. };
  788. HackerNewsProofGen.prototype.instructions = function() {
  789. return "Please edit your HackerNews profile to contain the following text. Click here: https://news.ycombinator.com/user?id=" + this.remote_username;
  790. };
  791. HackerNewsProofGen.prototype.do_recheck = function(i) {
  792. log.info("We couldn't find a posted proof for " + this.remote_username + "....." + (colors.bold('yet')));
  793. if (i < 3) {
  794. log.info("HackerNews's API is slow to update, so be patient...try again?");
  795. return true;
  796. } else {
  797. log.info("We'll keep trying and let you know!");
  798. return false;
  799. }
  800. };
  801. HackerNewsProofGen.prototype.get_warnings = function(_arg) {
  802. var remote_name_normalized;
  803. remote_name_normalized = _arg.remote_name_normalized;
  804. return [];
  805. };
  806. HackerNewsProofGen.prototype.do_precheck = function(_arg, cb) {
  807. var err, json, remote_name_normalized, scraper, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  808. __iced_k = __iced_k_noop;
  809. ___iced_passed_deferral = iced.findDeferral(arguments);
  810. remote_name_normalized = _arg.remote_name_normalized;
  811. scraper = (new scrapers.HackerNews).make_scraper();
  812. (function(_this) {
  813. return (function(__iced_k) {
  814. __iced_deferrals = new iced.Deferrals(__iced_k, {
  815. parent: ___iced_passed_deferral,
  816. filename: "/home/jacko/node-client/src/sigs.iced",
  817. funcname: "HackerNewsProofGen.do_precheck"
  818. });
  819. scraper.get_karma(remote_name_normalized, __iced_deferrals.defer({
  820. assign_fn: (function() {
  821. return function() {
  822. err = arguments[0];
  823. return json = arguments[1];
  824. };
  825. })(),
  826. lineno: 504
  827. }));
  828. __iced_deferrals._fulfill();
  829. });
  830. })(this)((function(_this) {
  831. return function() {
  832. if (typeof err !== "undefined" && err !== null) {
  833. } else if (!(typeof json !== "undefined" && json !== null)) {
  834. log.warn("" + (colors.bold("ATTENTION")) + ": HackerNews only publishes users to their API with " + (colors.bold("karma > 1")) + ".");
  835. log.warn("Your account " + (colors.bold(remote_name_normalized)) + " doesn't qualify, or doesn't exist!");
  836. err = new E.KarmaError("Insufficient HackerNews karma (>= 2 needed) or bad username (case sensitive!)");
  837. }
  838. return cb(err);
  839. };
  840. })(this));
  841. };
  842. HackerNewsProofGen.prototype.get_prompt = function() {
  843. return "Your username on " + (this.display_name()) + " (**case sensitive**)";
  844. };
  845. return HackerNewsProofGen;
  846. })(SocialNetworkProofGen);
  847. exports.CoinbaseProofGen = CoinbaseProofGen = (function(_super) {
  848. __extends(CoinbaseProofGen, _super);
  849. function CoinbaseProofGen() {
  850. return CoinbaseProofGen.__super__.constructor.apply(this, arguments);
  851. }
  852. CoinbaseProofGen.prototype._binding_klass = function() {
  853. return proofs.CoinbaseBinding;
  854. };
  855. CoinbaseProofGen.prototype._remote_service_name = function() {
  856. return "coinbase";
  857. };
  858. CoinbaseProofGen.prototype.imperative_verb = function() {
  859. return "update your Coinbase profile with";
  860. };
  861. CoinbaseProofGen.prototype.display_name = function() {
  862. return "coinbase";
  863. };
  864. CoinbaseProofGen.prototype.instructions = function() {
  865. return "Please update your Coinbase profile to show this proof. Click here: https://coinbase.com/" + this.remote_username + "/public-key";
  866. };
  867. return CoinbaseProofGen;
  868. })(SocialNetworkProofGen);
  869. exports.SignatureEngine = SignatureEngine = (function() {
  870. function SignatureEngine(_arg) {
  871. this.km = _arg.km;
  872. }
  873. SignatureEngine.prototype.get_km = function() {
  874. return this.km;
  875. };
  876. SignatureEngine.prototype.box = function(msg, cb) {
  877. var arg, err, out, pgp, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  878. __iced_k = __iced_k_noop;
  879. ___iced_passed_deferral = iced.findDeferral(arguments);
  880. out = {};
  881. arg = {
  882. stdin: new Buffer(msg, 'utf8'),
  883. args: ["-u", this.km.get_pgp_key_id(), "--sign", "-a", "--keyid-format", "long"],
  884. quiet: true
  885. };
  886. (function(_this) {
  887. return (function(__iced_k) {
  888. __iced_deferrals = new iced.Deferrals(__iced_k, {
  889. parent: ___iced_passed_deferral,
  890. filename: "/home/jacko/node-client/src/sigs.iced",
  891. funcname: "SignatureEngine.box"
  892. });
  893. master_ring().gpg(arg, __iced_deferrals.defer({
  894. assign_fn: (function() {
  895. return function() {
  896. err = arguments[0];
  897. return pgp = arguments[1];
  898. };
  899. })(),
  900. lineno: 544
  901. }));
  902. __iced_deferrals._fulfill();
  903. });
  904. })(this)((function(_this) {
  905. return function() {
  906. var _ref;
  907. if (typeof err === "undefined" || err === null) {
  908. out.pgp = pgp = pgp.toString('utf8');
  909. _ref = decode(pgp), err = _ref[0], msg = _ref[1];
  910. if (err == null) {
  911. out.raw = msg.body;
  912. }
  913. }
  914. return cb(err, out);
  915. };
  916. })(this));
  917. };
  918. return SignatureEngine;
  919. })();
  920. }).call(this);