tracksubsub.js 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983
  1. // Generated by IcedCoffeeScript 1.7.1-c
  2. (function() {
  3. var E, GE, ST, TrackSubSubCommand, TrackWrapper, User, assertion, athrow, chain_err, colors, constants, db, deq, env, iced, keypull, log, make_esc, master_ring, prompt_yn, proof_type_to_string, proofs, session, tor, unix_time, util, __iced_k, __iced_k_noop, _ref, _ref1, _ref2;
  4. iced = require('iced-runtime').iced;
  5. __iced_k = __iced_k_noop = function() {};
  6. db = require('./db').db;
  7. constants = require('./constants').constants;
  8. log = require('./log');
  9. proofs = require('keybase-proofs');
  10. proof_type_to_string = proofs.proof_type_to_string;
  11. ST = constants.signature_types;
  12. deq = require('deep-equal');
  13. _ref = require('./err'), GE = _ref.GE, E = _ref.E;
  14. _ref1 = require('pgp-utils').util, athrow = _ref1.athrow, unix_time = _ref1.unix_time;
  15. _ref2 = require('iced-error'), chain_err = _ref2.chain_err, make_esc = _ref2.make_esc;
  16. prompt_yn = require('./prompter').prompt_yn;
  17. session = require('./session').session;
  18. User = require('./user').User;
  19. db = require('./db');
  20. util = require('util');
  21. env = require('./env').env;
  22. TrackWrapper = require('./trackwrapper').TrackWrapper;
  23. master_ring = require('./keyring').master_ring;
  24. assertion = require('libkeybase').assertion;
  25. keypull = require('./keypull').keypull;
  26. colors = require('./colors');
  27. tor = require('./tor');
  28. exports.TrackSubSubCommand = TrackSubSubCommand = (function() {
  29. TrackSubSubCommand.OPTS = {
  30. r: {
  31. alias: "track-remote",
  32. action: "storeTrue",
  33. help: "remotely track by default"
  34. },
  35. l: {
  36. alias: "track-local",
  37. action: "storeTrue",
  38. help: "don't prompt for remote tracking"
  39. },
  40. a: {
  41. alias: "assert",
  42. help: "provide an identity assertion"
  43. },
  44. batch: {
  45. action: 'storeTrue',
  46. help: "batch-mode without interactivity"
  47. },
  48. "prompt-remote": {
  49. action: 'storeTrue',
  50. help: "prompt for remote tracking"
  51. }
  52. };
  53. function TrackSubSubCommand(_arg) {
  54. this.args = _arg.args, this.opts = _arg.opts, this.tmp_keyring = _arg.tmp_keyring, this.batch = _arg.batch, this.track_local = _arg.track_local, this.ran_keypull = _arg.ran_keypull, this.assertions = _arg.assertions;
  55. this.opts || (this.opts = {});
  56. }
  57. TrackSubSubCommand.prototype.is_batch = function() {
  58. return this.opts.batch || this.batch;
  59. };
  60. TrackSubSubCommand.prototype.prompt_ok = function(warnings, proofs, cb) {
  61. var err, prompt, ret, them, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  62. __iced_k = __iced_k_noop;
  63. ___iced_passed_deferral = iced.findDeferral(arguments);
  64. them = this.args.them;
  65. prompt = warnings ? (log.console.error(colors.red("Some remote proofs failed!")), "Still verify this user as " + them + "?") : proofs === 0 ? "We found an account for " + them + ", but they haven't proved their identity. Still accept them?" : "Is this the " + them + " you wanted?";
  66. (function(_this) {
  67. return (function(__iced_k) {
  68. __iced_deferrals = new iced.Deferrals(__iced_k, {
  69. parent: ___iced_passed_deferral,
  70. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  71. funcname: "TrackSubSubCommand.prompt_ok"
  72. });
  73. prompt_yn({
  74. prompt: prompt,
  75. defval: false
  76. }, __iced_deferrals.defer({
  77. assign_fn: (function() {
  78. return function() {
  79. err = arguments[0];
  80. return ret = arguments[1];
  81. };
  82. })(),
  83. lineno: 67
  84. }));
  85. __iced_deferrals._fulfill();
  86. });
  87. })(this)((function(_this) {
  88. return function() {
  89. return cb(err, ret);
  90. };
  91. })(this));
  92. };
  93. TrackSubSubCommand.prototype.prompt_track = function(proofs, cb) {
  94. var err, prompt, ret, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  95. __iced_k = __iced_k_noop;
  96. ___iced_passed_deferral = iced.findDeferral(arguments);
  97. ret = err = null;
  98. (function(_this) {
  99. return (function(__iced_k) {
  100. if (_this.opts.track_remote) {
  101. return __iced_k(ret = true);
  102. } else {
  103. (function(__iced_k) {
  104. if (_this.is_batch()) {
  105. return __iced_k(ret = false);
  106. } else {
  107. (function(__iced_k) {
  108. if (!_this.me.have_secret_key()) {
  109. return __iced_k(ret = false);
  110. } else {
  111. (function(__iced_k) {
  112. if ((_this.opts.track_local || _this.track_local) && !_this.opts.prompt_remote) {
  113. return __iced_k(ret = false);
  114. } else {
  115. prompt = "Permanently track this user, and write proof to server?";
  116. (function(__iced_k) {
  117. __iced_deferrals = new iced.Deferrals(__iced_k, {
  118. parent: ___iced_passed_deferral,
  119. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  120. funcname: "TrackSubSubCommand.prompt_track"
  121. });
  122. prompt_yn({
  123. prompt: prompt,
  124. defval: true
  125. }, __iced_deferrals.defer({
  126. assign_fn: (function() {
  127. return function() {
  128. err = arguments[0];
  129. return ret = arguments[1];
  130. };
  131. })(),
  132. lineno: 84
  133. }));
  134. __iced_deferrals._fulfill();
  135. })(__iced_k);
  136. }
  137. })(__iced_k);
  138. }
  139. })(__iced_k);
  140. }
  141. })(__iced_k);
  142. }
  143. });
  144. })(this)((function(_this) {
  145. return function() {
  146. return cb(err, ret);
  147. };
  148. })(this));
  149. };
  150. TrackSubSubCommand.prototype.on_loggedout_verify = function(cb) {
  151. var esc, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  152. __iced_k = __iced_k_noop;
  153. ___iced_passed_deferral = iced.findDeferral(arguments);
  154. esc = make_esc(cb, "TrackSubSub::on_loggedout_verify");
  155. (function(_this) {
  156. return (function(__iced_k) {
  157. __iced_deferrals = new iced.Deferrals(__iced_k, {
  158. parent: ___iced_passed_deferral,
  159. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  160. funcname: "TrackSubSubCommand.on_loggedout_verify"
  161. });
  162. User.load({
  163. username: _this.args.them
  164. }, esc(__iced_deferrals.defer({
  165. assign_fn: (function(__slot_1) {
  166. return function() {
  167. return __slot_1.them = arguments[0];
  168. };
  169. })(_this),
  170. lineno: 91
  171. })));
  172. __iced_deferrals._fulfill();
  173. });
  174. })(this)((function(_this) {
  175. return function() {
  176. return cb(null);
  177. };
  178. })(this));
  179. };
  180. TrackSubSubCommand.prototype.on_decrypt = function(cb) {
  181. var esc, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  182. __iced_k = __iced_k_noop;
  183. ___iced_passed_deferral = iced.findDeferral(arguments);
  184. esc = make_esc(cb, "TrackSubSub::on_decrypt");
  185. (function(_this) {
  186. return (function(__iced_k) {
  187. __iced_deferrals = new iced.Deferrals(__iced_k, {
  188. parent: ___iced_passed_deferral,
  189. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  190. funcname: "TrackSubSubCommand.on_decrypt"
  191. });
  192. _this.keypull(esc(__iced_deferrals.defer({
  193. lineno: 98
  194. })));
  195. __iced_deferrals._fulfill();
  196. });
  197. })(this)((function(_this) {
  198. return function() {
  199. (function(__iced_k) {
  200. __iced_deferrals = new iced.Deferrals(__iced_k, {
  201. parent: ___iced_passed_deferral,
  202. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  203. funcname: "TrackSubSubCommand.on_decrypt"
  204. });
  205. User.load({
  206. username: _this.args.them
  207. }, esc(__iced_deferrals.defer({
  208. assign_fn: (function(__slot_1) {
  209. return function() {
  210. return __slot_1.them = arguments[0];
  211. };
  212. })(_this),
  213. lineno: 99
  214. })));
  215. __iced_deferrals._fulfill();
  216. })(function() {
  217. (function(__iced_k) {
  218. __iced_deferrals = new iced.Deferrals(__iced_k, {
  219. parent: ___iced_passed_deferral,
  220. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  221. funcname: "TrackSubSubCommand.on_decrypt"
  222. });
  223. User.load_me({
  224. maybe_secret: true
  225. }, esc(__iced_deferrals.defer({
  226. assign_fn: (function(__slot_1) {
  227. return function() {
  228. return __slot_1.me = arguments[0];
  229. };
  230. })(_this),
  231. lineno: 100
  232. })));
  233. __iced_deferrals._fulfill();
  234. })(function() {
  235. (function(__iced_k) {
  236. __iced_deferrals = new iced.Deferrals(__iced_k, {
  237. parent: ___iced_passed_deferral,
  238. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  239. funcname: "TrackSubSubCommand.on_decrypt"
  240. });
  241. _this.check_not_self(esc(__iced_deferrals.defer({
  242. lineno: 101
  243. })));
  244. __iced_deferrals._fulfill();
  245. })(function() {
  246. (function(__iced_k) {
  247. __iced_deferrals = new iced.Deferrals(__iced_k, {
  248. parent: ___iced_passed_deferral,
  249. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  250. funcname: "TrackSubSubCommand.on_decrypt"
  251. });
  252. TrackWrapper.load({
  253. tracker: _this.me,
  254. trackee: _this.them
  255. }, esc(__iced_deferrals.defer({
  256. assign_fn: (function(__slot_1) {
  257. return function() {
  258. return __slot_1.trackw = arguments[0];
  259. };
  260. })(_this),
  261. lineno: 102
  262. })));
  263. __iced_deferrals._fulfill();
  264. })(function() {
  265. return cb(null);
  266. });
  267. });
  268. });
  269. });
  270. };
  271. })(this));
  272. };
  273. TrackSubSubCommand.prototype.check_remote_proofs = function(skip, cb) {
  274. var err, esc, n_proofs, opts, warnings, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  275. __iced_k = __iced_k_noop;
  276. ___iced_passed_deferral = iced.findDeferral(arguments);
  277. esc = make_esc(cb, "TrackSubSub::check_remote_proofs");
  278. log.debug("+ TrackSubSub::check_remote_proofs");
  279. (function(_this) {
  280. return (function(__iced_k) {
  281. __iced_deferrals = new iced.Deferrals(__iced_k, {
  282. parent: ___iced_passed_deferral,
  283. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  284. funcname: "TrackSubSubCommand.check_remote_proofs"
  285. });
  286. _this.parse_assertions(esc(__iced_deferrals.defer({
  287. lineno: 110
  288. })));
  289. __iced_deferrals._fulfill();
  290. });
  291. })(this)((function(_this) {
  292. return function() {
  293. opts = {
  294. skip: skip,
  295. assertions: _this.assertions
  296. };
  297. (function(__iced_k) {
  298. __iced_deferrals = new iced.Deferrals(__iced_k, {
  299. parent: ___iced_passed_deferral,
  300. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  301. funcname: "TrackSubSubCommand.check_remote_proofs"
  302. });
  303. _this.them.check_remote_proofs(opts, esc(__iced_deferrals.defer({
  304. assign_fn: (function() {
  305. return function() {
  306. warnings = arguments[0];
  307. return n_proofs = arguments[1];
  308. };
  309. })(),
  310. lineno: 112
  311. })));
  312. __iced_deferrals._fulfill();
  313. })(function() {
  314. err = null;
  315. log.debug("- TrackSubSub::check_remote_proofs -> " + (err != null ? err.message : void 0));
  316. return cb(err, warnings, n_proofs);
  317. });
  318. };
  319. })(this));
  320. };
  321. TrackSubSubCommand.prototype.resolve_them = function(cb) {
  322. var err, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  323. __iced_k = __iced_k_noop;
  324. ___iced_passed_deferral = iced.findDeferral(arguments);
  325. (function(_this) {
  326. return (function(__iced_k) {
  327. __iced_deferrals = new iced.Deferrals(__iced_k, {
  328. parent: ___iced_passed_deferral,
  329. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  330. funcname: "TrackSubSubCommand.resolve_them"
  331. });
  332. User.resolve_user_name({
  333. username: _this.args.them
  334. }, __iced_deferrals.defer({
  335. assign_fn: (function(__slot_1, __slot_2) {
  336. return function() {
  337. err = arguments[0];
  338. __slot_1.them = arguments[1];
  339. return __slot_2.assertion = arguments[2];
  340. };
  341. })(_this.args, _this),
  342. lineno: 120
  343. }));
  344. __iced_deferrals._fulfill();
  345. });
  346. })(this)((function(_this) {
  347. return function() {
  348. return cb(err);
  349. };
  350. })(this));
  351. };
  352. TrackSubSubCommand.prototype.id = function(cb) {
  353. var accept, esc, warnings, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  354. __iced_k = __iced_k_noop;
  355. ___iced_passed_deferral = iced.findDeferral(arguments);
  356. esc = make_esc(cb, "TrackSubSub:id");
  357. log.debug("+ id");
  358. accept = false;
  359. (function(_this) {
  360. return (function(__iced_k) {
  361. __iced_deferrals = new iced.Deferrals(__iced_k, {
  362. parent: ___iced_passed_deferral,
  363. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  364. funcname: "TrackSubSubCommand.id"
  365. });
  366. _this.resolve_them(esc(__iced_deferrals.defer({
  367. lineno: 129
  368. })));
  369. __iced_deferrals._fulfill();
  370. });
  371. })(this)((function(_this) {
  372. return function() {
  373. (function(__iced_k) {
  374. __iced_deferrals = new iced.Deferrals(__iced_k, {
  375. parent: ___iced_passed_deferral,
  376. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  377. funcname: "TrackSubSubCommand.id"
  378. });
  379. User.load({
  380. username: _this.args.them,
  381. require_public_key: true
  382. }, esc(__iced_deferrals.defer({
  383. assign_fn: (function(__slot_1) {
  384. return function() {
  385. return __slot_1.them = arguments[0];
  386. };
  387. })(_this),
  388. lineno: 130
  389. })));
  390. __iced_deferrals._fulfill();
  391. })(function() {
  392. (function(__iced_k) {
  393. __iced_deferrals = new iced.Deferrals(__iced_k, {
  394. parent: ___iced_passed_deferral,
  395. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  396. funcname: "TrackSubSubCommand.id"
  397. });
  398. _this.check_remote_proofs(false, esc(__iced_deferrals.defer({
  399. assign_fn: (function() {
  400. return function() {
  401. return warnings = arguments[0];
  402. };
  403. })(),
  404. lineno: 131
  405. })));
  406. __iced_deferrals._fulfill();
  407. })(function() {
  408. (function(__iced_k) {
  409. __iced_deferrals = new iced.Deferrals(__iced_k, {
  410. parent: ___iced_passed_deferral,
  411. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  412. funcname: "TrackSubSubCommand.id"
  413. });
  414. _this.them.display_cryptocurrency_addresses({}, esc(__iced_deferrals.defer({
  415. lineno: 132
  416. })));
  417. __iced_deferrals._fulfill();
  418. })(function() {
  419. log.debug("- id");
  420. return cb(null);
  421. });
  422. });
  423. });
  424. };
  425. })(this));
  426. };
  427. TrackSubSubCommand.prototype.pre_encrypt = function(cb) {
  428. var err, logged_in, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  429. __iced_k = __iced_k_noop;
  430. ___iced_passed_deferral = iced.findDeferral(arguments);
  431. (function(_this) {
  432. return (function(__iced_k) {
  433. if (!env().is_configured()) {
  434. (function(__iced_k) {
  435. __iced_deferrals = new iced.Deferrals(__iced_k, {
  436. parent: ___iced_passed_deferral,
  437. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  438. funcname: "TrackSubSubCommand.pre_encrypt"
  439. });
  440. _this.id(__iced_deferrals.defer({
  441. assign_fn: (function() {
  442. return function() {
  443. return err = arguments[0];
  444. };
  445. })(),
  446. lineno: 140
  447. }));
  448. __iced_deferrals._fulfill();
  449. })(__iced_k);
  450. } else {
  451. (function(__iced_k) {
  452. __iced_deferrals = new iced.Deferrals(__iced_k, {
  453. parent: ___iced_passed_deferral,
  454. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  455. funcname: "TrackSubSubCommand.pre_encrypt"
  456. });
  457. session.load_and_check(__iced_deferrals.defer({
  458. assign_fn: (function() {
  459. return function() {
  460. err = arguments[0];
  461. return logged_in = arguments[1];
  462. };
  463. })(),
  464. lineno: 142
  465. }));
  466. __iced_deferrals._fulfill();
  467. })(function() {
  468. (function(__iced_k) {
  469. if (err == null) {
  470. _this.skip_keypull = !logged_in;
  471. _this.track_local = !logged_in;
  472. (function(__iced_k) {
  473. __iced_deferrals = new iced.Deferrals(__iced_k, {
  474. parent: ___iced_passed_deferral,
  475. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  476. funcname: "TrackSubSubCommand.pre_encrypt"
  477. });
  478. _this.run(__iced_deferrals.defer({
  479. assign_fn: (function() {
  480. return function() {
  481. return err = arguments[0];
  482. };
  483. })(),
  484. lineno: 146
  485. }));
  486. __iced_deferrals._fulfill();
  487. })(__iced_k);
  488. } else {
  489. return __iced_k();
  490. }
  491. })(__iced_k);
  492. });
  493. }
  494. });
  495. })(this)((function(_this) {
  496. return function() {
  497. return cb(err);
  498. };
  499. })(this));
  500. };
  501. TrackSubSubCommand.prototype.parse_assertions = function(cb) {
  502. var a, ca, e, err;
  503. err = null;
  504. ca = null;
  505. try {
  506. if ((a = this.opts.assert) != null) {
  507. ca = assertion.parse(a);
  508. }
  509. } catch (_error) {
  510. e = _error;
  511. err = new E.ParseAssertionError("Error parsing assertion '" + a + "': " + e.message);
  512. }
  513. if ((this.assertions != null) && (ca != null)) {
  514. this.assertions = new assertion.AND(this.assertions, ca);
  515. } else if (ca != null) {
  516. this.assertions = ca;
  517. }
  518. return cb(err);
  519. };
  520. TrackSubSubCommand.prototype.check_not_self = function(cb) {
  521. var err, t;
  522. err = null;
  523. if ((((t = this.args.them) != null) && (t === this.me.username())) || (((t = this.args.them_ki64) != null) && (t === this.me.key_id_64()))) {
  524. err = new E.SelfError("Cannot track yourself");
  525. }
  526. return cb(err);
  527. };
  528. TrackSubSubCommand.prototype.keypull = function(cb) {
  529. var err, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  530. __iced_k = __iced_k_noop;
  531. ___iced_passed_deferral = iced.findDeferral(arguments);
  532. err = null;
  533. (function(_this) {
  534. return (function(__iced_k) {
  535. if (!_this.ran_keypull && !_this.skip_keypull && !tor.enabled()) {
  536. (function(__iced_k) {
  537. __iced_deferrals = new iced.Deferrals(__iced_k, {
  538. parent: ___iced_passed_deferral,
  539. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  540. funcname: "TrackSubSubCommand.keypull"
  541. });
  542. keypull({
  543. need_secret: false,
  544. stdin_blocked: _this.is_batch()
  545. }, __iced_deferrals.defer({
  546. assign_fn: (function() {
  547. return function() {
  548. return err = arguments[0];
  549. };
  550. })(),
  551. lineno: 182
  552. }));
  553. __iced_deferrals._fulfill();
  554. })(function() {
  555. return __iced_k(_this.ran_keypull = true);
  556. });
  557. } else {
  558. return __iced_k();
  559. }
  560. });
  561. })(this)((function(_this) {
  562. return function() {
  563. return cb(err);
  564. };
  565. })(this));
  566. };
  567. TrackSubSubCommand.prototype.save_their_keys = function(cb) {
  568. var esc, key, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  569. __iced_k = __iced_k_noop;
  570. ___iced_passed_deferral = iced.findDeferral(arguments);
  571. esc = make_esc(cb, "TrackSubSub::save_their_keys");
  572. (function(_this) {
  573. return (function(__iced_k) {
  574. var _i, _len, _ref3, _results, _while;
  575. _ref3 = _this.them.gpg_keys;
  576. _len = _ref3.length;
  577. _i = 0;
  578. _results = [];
  579. _while = function(__iced_k) {
  580. var _break, _continue, _next;
  581. _break = function() {
  582. return __iced_k(_results);
  583. };
  584. _continue = function() {
  585. return iced.trampoline(function() {
  586. ++_i;
  587. return _while(__iced_k);
  588. });
  589. };
  590. _next = function(__iced_next_arg) {
  591. _results.push(__iced_next_arg);
  592. return _continue();
  593. };
  594. if (!(_i < _len)) {
  595. return _break();
  596. } else {
  597. key = _ref3[_i];
  598. (function(__iced_k) {
  599. __iced_deferrals = new iced.Deferrals(__iced_k, {
  600. parent: ___iced_passed_deferral,
  601. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  602. funcname: "TrackSubSubCommand.save_their_keys"
  603. });
  604. key.copy_to_keyring(master_ring()).save(esc(__iced_deferrals.defer({
  605. lineno: 191
  606. })));
  607. __iced_deferrals._fulfill();
  608. })(_next);
  609. }
  610. };
  611. _while(__iced_k);
  612. });
  613. })(this)((function(_this) {
  614. return function() {
  615. return cb(null);
  616. };
  617. })(this));
  618. };
  619. TrackSubSubCommand.prototype.run = function(cb) {
  620. var accept, ckres, esc, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  621. __iced_k = __iced_k_noop;
  622. ___iced_passed_deferral = iced.findDeferral(arguments);
  623. esc = make_esc(cb, "TrackSubSub::run");
  624. log.debug("+ run");
  625. (function(_this) {
  626. return (function(__iced_k) {
  627. __iced_deferrals = new iced.Deferrals(__iced_k, {
  628. parent: ___iced_passed_deferral,
  629. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  630. funcname: "TrackSubSubCommand.run"
  631. });
  632. _this.keypull(esc(__iced_deferrals.defer({
  633. lineno: 202
  634. })));
  635. __iced_deferrals._fulfill();
  636. });
  637. })(this)((function(_this) {
  638. return function() {
  639. (function(__iced_k) {
  640. __iced_deferrals = new iced.Deferrals(__iced_k, {
  641. parent: ___iced_passed_deferral,
  642. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  643. funcname: "TrackSubSubCommand.run"
  644. });
  645. User.load_me({
  646. maybe_secret: true
  647. }, esc(__iced_deferrals.defer({
  648. assign_fn: (function(__slot_1) {
  649. return function() {
  650. return __slot_1.me = arguments[0];
  651. };
  652. })(_this),
  653. lineno: 204
  654. })));
  655. __iced_deferrals._fulfill();
  656. })(function() {
  657. (function(__iced_k) {
  658. __iced_deferrals = new iced.Deferrals(__iced_k, {
  659. parent: ___iced_passed_deferral,
  660. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  661. funcname: "TrackSubSubCommand.run"
  662. });
  663. _this.check_not_self(esc(__iced_deferrals.defer({
  664. lineno: 205
  665. })));
  666. __iced_deferrals._fulfill();
  667. })(function() {
  668. (function(__iced_k) {
  669. __iced_deferrals = new iced.Deferrals(__iced_k, {
  670. parent: ___iced_passed_deferral,
  671. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  672. funcname: "TrackSubSubCommand.run"
  673. });
  674. _this.resolve_them(esc(__iced_deferrals.defer({
  675. lineno: 207
  676. })));
  677. __iced_deferrals._fulfill();
  678. })(function() {
  679. (function(__iced_k) {
  680. __iced_deferrals = new iced.Deferrals(__iced_k, {
  681. parent: ___iced_passed_deferral,
  682. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  683. funcname: "TrackSubSubCommand.run"
  684. });
  685. User.load({
  686. username: _this.args.them,
  687. ki64: _this.args.them_ki64,
  688. require_public_key: true
  689. }, esc(__iced_deferrals.defer({
  690. assign_fn: (function(__slot_1) {
  691. return function() {
  692. return __slot_1.them = arguments[0];
  693. };
  694. })(_this),
  695. lineno: 208
  696. })));
  697. __iced_deferrals._fulfill();
  698. })(function() {
  699. (function(__iced_k) {
  700. __iced_deferrals = new iced.Deferrals(__iced_k, {
  701. parent: ___iced_passed_deferral,
  702. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  703. funcname: "TrackSubSubCommand.run"
  704. });
  705. TrackWrapper.load({
  706. tracker: _this.me,
  707. trackee: _this.them
  708. }, esc(__iced_deferrals.defer({
  709. assign_fn: (function(__slot_1) {
  710. return function() {
  711. return __slot_1.trackw = arguments[0];
  712. };
  713. })(_this),
  714. lineno: 210
  715. })));
  716. __iced_deferrals._fulfill();
  717. })(function() {
  718. (function(__iced_k) {
  719. __iced_deferrals = new iced.Deferrals(__iced_k, {
  720. parent: ___iced_passed_deferral,
  721. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  722. funcname: "TrackSubSubCommand.run"
  723. });
  724. _this.all_prompts(esc(__iced_deferrals.defer({
  725. assign_fn: (function() {
  726. return function() {
  727. return accept = arguments[0];
  728. };
  729. })(),
  730. lineno: 211
  731. })));
  732. __iced_deferrals._fulfill();
  733. })(function() {
  734. (function(__iced_k) {
  735. __iced_deferrals = new iced.Deferrals(__iced_k, {
  736. parent: ___iced_passed_deferral,
  737. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  738. funcname: "TrackSubSubCommand.run"
  739. });
  740. _this.them.check_key({
  741. secret: false,
  742. store: true
  743. }, esc(__iced_deferrals.defer({
  744. assign_fn: (function() {
  745. return function() {
  746. return ckres = arguments[0];
  747. };
  748. })(),
  749. lineno: 215
  750. })));
  751. __iced_deferrals._fulfill();
  752. })(function() {
  753. (function(__iced_k) {
  754. if (accept && !ckres.local) {
  755. (function(__iced_k) {
  756. __iced_deferrals = new iced.Deferrals(__iced_k, {
  757. parent: ___iced_passed_deferral,
  758. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  759. funcname: "TrackSubSubCommand.run"
  760. });
  761. _this.save_their_keys(esc(__iced_deferrals.defer({
  762. lineno: 217
  763. })));
  764. __iced_deferrals._fulfill();
  765. })(__iced_k);
  766. } else {
  767. return __iced_k();
  768. }
  769. })(function() {
  770. log.debug("- run");
  771. return cb(null);
  772. });
  773. });
  774. });
  775. });
  776. });
  777. });
  778. });
  779. });
  780. };
  781. })(this));
  782. };
  783. TrackSubSubCommand.prototype.all_prompts = function(cb) {
  784. var accept, approve, check, do_remote, err, esc, n_proofs, n_warnings, skp, warnings, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  785. __iced_k = __iced_k_noop;
  786. ___iced_passed_deferral = iced.findDeferral(arguments);
  787. esc = make_esc(cb, "TrackSubSub::all_prompts");
  788. log.debug("+ TrackSubSub::all_prompts");
  789. check = this.trackw.skip_remote_check();
  790. if (check === constants.skip.NONE) {
  791. log.info("...checking identity proofs");
  792. skp = false;
  793. } else {
  794. log.info("...all remote checks are up-to-date");
  795. skp = true;
  796. }
  797. (function(_this) {
  798. return (function(__iced_k) {
  799. __iced_deferrals = new iced.Deferrals(__iced_k, {
  800. parent: ___iced_passed_deferral,
  801. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  802. funcname: "TrackSubSubCommand.all_prompts"
  803. });
  804. _this.check_remote_proofs(skp, esc(__iced_deferrals.defer({
  805. assign_fn: (function() {
  806. return function() {
  807. warnings = arguments[0];
  808. return n_proofs = arguments[1];
  809. };
  810. })(),
  811. lineno: 236
  812. })));
  813. __iced_deferrals._fulfill();
  814. });
  815. })(this)((function(_this) {
  816. return function() {
  817. n_warnings = warnings.warnings().length;
  818. (function(__iced_k) {
  819. if ((approve = _this.trackw.skip_approval()) !== constants.skip.NONE) {
  820. log.debug("| skipping approval, since remote services & key are unchanged");
  821. return __iced_k(accept = true);
  822. } else {
  823. (function(__iced_k) {
  824. if (_this.assertions != null) {
  825. log.info("Identity accepted due to clean and complete assertions");
  826. log.debug("| We can approve due to clean assertions");
  827. return __iced_k(accept = true);
  828. } else {
  829. (function(__iced_k) {
  830. if (_this.is_batch()) {
  831. log.warn("Interactive approval is needed");
  832. log.debug("| We needed approval, but we were in batch mode");
  833. return __iced_k(accept = false);
  834. } else {
  835. (function(__iced_k) {
  836. __iced_deferrals = new iced.Deferrals(__iced_k, {
  837. parent: ___iced_passed_deferral,
  838. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  839. funcname: "TrackSubSubCommand.all_prompts"
  840. });
  841. _this.prompt_ok(n_warnings, n_proofs, esc(__iced_deferrals.defer({
  842. assign_fn: (function() {
  843. return function() {
  844. return accept = arguments[0];
  845. };
  846. })(),
  847. lineno: 251
  848. })));
  849. __iced_deferrals._fulfill();
  850. })(__iced_k);
  851. }
  852. })(__iced_k);
  853. }
  854. })(__iced_k);
  855. }
  856. })(function() {
  857. err = null;
  858. (function(__iced_k) {
  859. if (!accept) {
  860. log.warn("Bailing out; proofs were not accepted");
  861. return __iced_k(err = new E.CancelError("operation was canceled"));
  862. } else {
  863. (function(__iced_k) {
  864. if ((check === constants.skip.REMOTE) && (approve === constants.skip.REMOTE)) {
  865. return __iced_k(log.info("Nothing to do; tracking is up-to-date"));
  866. } else {
  867. (function(__iced_k) {
  868. if (approve === constants.skip.REMOTE) {
  869. return __iced_k(do_remote = false);
  870. } else {
  871. (function(__iced_k) {
  872. if (tor.strict()) {
  873. return __iced_k(log.warn("Can't write tracking statement to server in strict Tor mode"));
  874. } else {
  875. (function(__iced_k) {
  876. __iced_deferrals = new iced.Deferrals(__iced_k, {
  877. parent: ___iced_passed_deferral,
  878. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  879. funcname: "TrackSubSubCommand.all_prompts"
  880. });
  881. _this.prompt_track(n_proofs, esc(__iced_deferrals.defer({
  882. assign_fn: (function() {
  883. return function() {
  884. return do_remote = arguments[0];
  885. };
  886. })(),
  887. lineno: 265
  888. })));
  889. __iced_deferrals._fulfill();
  890. })(function() {
  891. (function(__iced_k) {
  892. if (do_remote) {
  893. (function(__iced_k) {
  894. __iced_deferrals = new iced.Deferrals(__iced_k, {
  895. parent: ___iced_passed_deferral,
  896. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  897. funcname: "TrackSubSubCommand.all_prompts"
  898. });
  899. session.load_and_login(esc(__iced_deferrals.defer({
  900. lineno: 267
  901. })));
  902. __iced_deferrals._fulfill();
  903. })(__iced_k);
  904. } else {
  905. return __iced_k();
  906. }
  907. })(__iced_k);
  908. });
  909. }
  910. })(__iced_k);
  911. }
  912. })(function() {
  913. (function(__iced_k) {
  914. __iced_deferrals = new iced.Deferrals(__iced_k, {
  915. parent: ___iced_passed_deferral,
  916. filename: "/home/jacko/node-client/src/tracksubsub.iced",
  917. funcname: "TrackSubSubCommand.all_prompts"
  918. });
  919. _this.trackw.store_track({
  920. do_remote: do_remote
  921. }, esc(__iced_deferrals.defer({
  922. lineno: 268
  923. })));
  924. __iced_deferrals._fulfill();
  925. })(__iced_k);
  926. });
  927. }
  928. })(__iced_k);
  929. }
  930. })(function() {
  931. log.debug("- TrackSubSub::all_prompts");
  932. return cb(err, accept);
  933. });
  934. });
  935. };
  936. })(this));
  937. };
  938. return TrackSubSubCommand;
  939. })();
  940. }).call(this);