dir.js 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995
  1. // Generated by IcedCoffeeScript 1.7.1-c
  2. (function() {
  3. var Base, BufferInStream, Command, DecryptAndVerifyEngine, E, MyEngine, TrackSubSubCommand, User, add_option_dict, athrow, chain, codesign, fs, gpg, iced, keypull, log, make_esc, master_ring, path, write_tmp_file, __iced_k, __iced_k_noop, _ref,
  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. codesign = require('codesign');
  9. path = require('path');
  10. fs = require('fs');
  11. Base = require('./base').Base;
  12. log = require('../log');
  13. add_option_dict = require('./argparse').add_option_dict;
  14. E = require('../err').E;
  15. TrackSubSubCommand = require('../tracksubsub').TrackSubSubCommand;
  16. gpg = require('../gpg').gpg;
  17. _ref = require('iced-error'), make_esc = _ref.make_esc, chain = _ref.chain;
  18. athrow = require('iced-utils').util.athrow;
  19. User = require('../user').User;
  20. keypull = require('../keypull').keypull;
  21. BufferInStream = require('iced-spawn').BufferInStream;
  22. master_ring = require('../keyring').master_ring;
  23. write_tmp_file = require('iced-utils').fs.write_tmp_file;
  24. DecryptAndVerifyEngine = require('../dve').DecryptAndVerifyEngine;
  25. MyEngine = (function(_super) {
  26. __extends(MyEngine, _super);
  27. function MyEngine(_arg) {
  28. var argv;
  29. argv = _arg.argv;
  30. this._tmp_files = {};
  31. MyEngine.__super__.constructor.call(this, {
  32. argv: argv
  33. });
  34. }
  35. MyEngine.prototype.write_tmp = function(_arg, cb) {
  36. var data, err, file, nm, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  37. __iced_k = __iced_k_noop;
  38. ___iced_passed_deferral = iced.findDeferral(arguments);
  39. file = _arg.file, data = _arg.data;
  40. (function(_this) {
  41. return (function(__iced_k) {
  42. __iced_deferrals = new iced.Deferrals(__iced_k, {
  43. parent: ___iced_passed_deferral,
  44. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  45. funcname: "MyEngine.write_tmp"
  46. });
  47. write_tmp_file({
  48. data: data,
  49. base: file,
  50. mode: 0x180
  51. }, __iced_deferrals.defer({
  52. assign_fn: (function() {
  53. return function() {
  54. err = arguments[0];
  55. return nm = arguments[1];
  56. };
  57. })(),
  58. lineno: 29
  59. }));
  60. __iced_deferrals._fulfill();
  61. });
  62. })(this)((function(_this) {
  63. return function() {
  64. if (typeof err === "undefined" || err === null) {
  65. _this._tmp_files[file] = nm;
  66. log.debug("| writing " + file + " tmpfile " + nm);
  67. }
  68. return cb(err);
  69. };
  70. })(this));
  71. };
  72. MyEngine.prototype.cleanup_run1 = function(cb) {
  73. var err, k, v, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  74. __iced_k = __iced_k_noop;
  75. ___iced_passed_deferral = iced.findDeferral(arguments);
  76. (function(_this) {
  77. return (function(__iced_k) {
  78. if (_this.argv.preserve_tmp_files) {
  79. return __iced_k(log.debug("| preserving temporary files by command-line flag"));
  80. } else {
  81. (function(__iced_k) {
  82. var _i, _k, _keys, _ref1, _results, _while;
  83. _ref1 = _this._tmp_files;
  84. _keys = (function() {
  85. var _results1;
  86. _results1 = [];
  87. for (_k in _ref1) {
  88. _results1.push(_k);
  89. }
  90. return _results1;
  91. })();
  92. _i = 0;
  93. _results = [];
  94. _while = function(__iced_k) {
  95. var _break, _continue, _next;
  96. _break = function() {
  97. return __iced_k(_results);
  98. };
  99. _continue = function() {
  100. return iced.trampoline(function() {
  101. ++_i;
  102. return _while(__iced_k);
  103. });
  104. };
  105. _next = function(__iced_next_arg) {
  106. _results.push(__iced_next_arg);
  107. return _continue();
  108. };
  109. if (!(_i < _keys.length)) {
  110. return _break();
  111. } else {
  112. k = _keys[_i];
  113. v = _ref1[k];
  114. log.debug("| unlink " + v);
  115. (function(__iced_k) {
  116. __iced_deferrals = new iced.Deferrals(__iced_k, {
  117. parent: ___iced_passed_deferral,
  118. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  119. funcname: "MyEngine.cleanup_run1"
  120. });
  121. fs.unlink(v, __iced_deferrals.defer({
  122. assign_fn: (function() {
  123. return function() {
  124. return err = arguments[0];
  125. };
  126. })(),
  127. lineno: 43
  128. }));
  129. __iced_deferrals._fulfill();
  130. })(function() {
  131. return _next(typeof err !== "undefined" && err !== null ? log.warn("Could not remove tmp file " + v + ": " + err.message) : void 0);
  132. });
  133. }
  134. };
  135. _while(__iced_k);
  136. })(__iced_k);
  137. }
  138. });
  139. })(this)((function(_this) {
  140. return function() {
  141. return cb();
  142. };
  143. })(this));
  144. };
  145. MyEngine.prototype.patch_gpg_args = function(args) {
  146. return args.push("--verify");
  147. };
  148. MyEngine.prototype.get_files = function(args) {
  149. args.push(this._tmp_files.sig);
  150. return args.push(this._tmp_files.payload);
  151. };
  152. MyEngine.prototype.run1 = function(_arg, cb) {
  153. var err, esc, payload, signature, username, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  154. __iced_k = __iced_k_noop;
  155. ___iced_passed_deferral = iced.findDeferral(arguments);
  156. username = _arg.username, payload = _arg.payload, signature = _arg.signature;
  157. cb = chain(cb, this.cleanup_run1.bind(this));
  158. esc = make_esc(cb, "MyEngine::run_one");
  159. (function(_this) {
  160. return (function(__iced_k) {
  161. __iced_deferrals = new iced.Deferrals(__iced_k, {
  162. parent: ___iced_passed_deferral,
  163. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  164. funcname: "MyEngine.run1"
  165. });
  166. _this.write_tmp({
  167. file: "payload",
  168. data: payload
  169. }, esc(__iced_deferrals.defer({
  170. lineno: 64
  171. })));
  172. __iced_deferrals._fulfill();
  173. });
  174. })(this)((function(_this) {
  175. return function() {
  176. (function(__iced_k) {
  177. __iced_deferrals = new iced.Deferrals(__iced_k, {
  178. parent: ___iced_passed_deferral,
  179. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  180. funcname: "MyEngine.run1"
  181. });
  182. _this.write_tmp({
  183. file: "sig",
  184. data: signature
  185. }, esc(__iced_deferrals.defer({
  186. lineno: 65
  187. })));
  188. __iced_deferrals._fulfill();
  189. })(function() {
  190. (function(__iced_k) {
  191. __iced_deferrals = new iced.Deferrals(__iced_k, {
  192. parent: ___iced_passed_deferral,
  193. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  194. funcname: "MyEngine.run1"
  195. });
  196. _this.run(esc(__iced_deferrals.defer({
  197. lineno: 66
  198. })));
  199. __iced_deferrals._fulfill();
  200. })(function() {
  201. err = null;
  202. if (_this.username !== username) {
  203. err = E.UsernameMismatchError("bad username: wanted " + username + " but got " + _this.username);
  204. }
  205. return cb(err);
  206. });
  207. });
  208. };
  209. })(this));
  210. };
  211. return MyEngine;
  212. })(DecryptAndVerifyEngine);
  213. exports.Command = Command = (function(_super) {
  214. __extends(Command, _super);
  215. function Command() {
  216. return Command.__super__.constructor.apply(this, arguments);
  217. }
  218. Command.prototype.DIR_OPT = {
  219. nargs: '?',
  220. action: 'store',
  221. type: 'string',
  222. help: 'the directory to sign/verify',
  223. defaultValue: '.'
  224. };
  225. Command.prototype.SIGN_OPTS = {
  226. o: {
  227. alias: 'output',
  228. type: 'string',
  229. help: 'the output file'
  230. },
  231. p: {
  232. alias: 'presets',
  233. action: 'store',
  234. type: 'string',
  235. help: 'specify ignore presets, comma-separated',
  236. defaultValue: 'git,dropbox,kb'
  237. },
  238. q: {
  239. alias: 'quiet',
  240. action: 'storeTrue',
  241. help: 'withhold output unless an error'
  242. }
  243. };
  244. Command.prototype.VERIFY_OPTS = {
  245. i: {
  246. alias: 'input',
  247. type: 'string',
  248. help: 'the input file'
  249. },
  250. q: {
  251. alias: 'quiet',
  252. action: 'storeTrue',
  253. help: 'withhold output unless an error'
  254. },
  255. s: {
  256. alias: 'strict',
  257. action: 'storeTrue',
  258. help: 'fail on warnings (typically cross-platform problems)'
  259. },
  260. P: {
  261. alias: 'preserve-tmp-files',
  262. action: 'storeTrue',
  263. help: 'preserve temp files for debugging and inspection'
  264. },
  265. "ignore-verify-errors": {
  266. action: 'storeTrue',
  267. help: 'ignore verify errors and continue to tracking'
  268. }
  269. };
  270. Command.prototype.TOJSON_OPTS = {
  271. i: {
  272. alias: 'input',
  273. type: 'string',
  274. help: 'the input file to convert to JSON',
  275. defaultValue: codesign.constants.defaults.FILENAME
  276. }
  277. };
  278. Command.prototype.is_batch = function() {
  279. return false;
  280. };
  281. Command.prototype.set_argv = function(a) {
  282. return Command.__super__.set_argv.call(this, a);
  283. };
  284. Command.prototype.copy = function(d) {
  285. var k, v, x;
  286. x = {};
  287. for (k in d) {
  288. v = d[k];
  289. x[k] = v;
  290. }
  291. return x;
  292. };
  293. Command.prototype.add_subcommand_parser = function(scp) {
  294. var name, opts, ss1, ss2, sub, sub2;
  295. opts = {
  296. aliases: ["code-sign"],
  297. help: "sign or verify a directory's contents"
  298. };
  299. name = "dir";
  300. sub = scp.addParser(name, opts);
  301. sub2 = sub.addSubparsers({
  302. title: "dir subcommand",
  303. dest: "dir_subcommand"
  304. });
  305. ss1 = sub2.addParser("sign", {
  306. help: "sign a directory's contents"
  307. });
  308. add_option_dict(ss1, this.SIGN_OPTS);
  309. ss1.addArgument(['dir'], this.copy(this.DIR_OPT));
  310. ss2 = sub2.addParser("verify", {
  311. help: "verify a directory's contents"
  312. });
  313. add_option_dict(ss2, this.VERIFY_OPTS);
  314. add_option_dict(ss2, DecryptAndVerifyEngine.OPTS);
  315. ss2.addArgument(['dir'], this.copy(this.DIR_OPT));
  316. return opts.aliases.concat([name]);
  317. };
  318. Command.prototype.do_sign = function(payload, cb) {
  319. var esc, gargs, out, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  320. __iced_k = __iced_k_noop;
  321. ___iced_passed_deferral = iced.findDeferral(arguments);
  322. esc = make_esc(cb, "Command::do_sign");
  323. gargs = {
  324. args: ["--sign", "--detach-sign", "-a", "-u", this.me.fingerprint(true)],
  325. stdin: new BufferInStream(new Buffer(payload, 'utf8'))
  326. };
  327. (function(_this) {
  328. return (function(__iced_k) {
  329. __iced_deferrals = new iced.Deferrals(__iced_k, {
  330. parent: ___iced_passed_deferral,
  331. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  332. funcname: "Command.do_sign"
  333. });
  334. master_ring().gpg(gargs, esc(__iced_deferrals.defer({
  335. assign_fn: (function() {
  336. return function() {
  337. return out = arguments[0];
  338. };
  339. })(),
  340. lineno: 190
  341. })));
  342. __iced_deferrals._fulfill();
  343. });
  344. })(this)((function(_this) {
  345. return function() {
  346. return cb(null, out.toString('utf8'));
  347. };
  348. })(this));
  349. };
  350. Command.prototype.load_me = function(cb) {
  351. var err, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  352. __iced_k = __iced_k_noop;
  353. ___iced_passed_deferral = iced.findDeferral(arguments);
  354. (function(_this) {
  355. return (function(__iced_k) {
  356. __iced_deferrals = new iced.Deferrals(__iced_k, {
  357. parent: ___iced_passed_deferral,
  358. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  359. funcname: "Command.load_me"
  360. });
  361. User.load_me({
  362. secret: true
  363. }, __iced_deferrals.defer({
  364. assign_fn: (function(__slot_1) {
  365. return function() {
  366. err = arguments[0];
  367. return __slot_1.me = arguments[1];
  368. };
  369. })(_this),
  370. lineno: 196
  371. }));
  372. __iced_deferrals._fulfill();
  373. });
  374. })(this)((function(_this) {
  375. return function() {
  376. return cb(err);
  377. };
  378. })(this));
  379. };
  380. Command.prototype.get_preset_list = function(cb) {
  381. var err, k, presets, valid_presets, _i, _len;
  382. err = null;
  383. presets = this.argv.presets.split(',');
  384. valid_presets = (function() {
  385. var _results;
  386. _results = [];
  387. for (k in codesign.constants.presets) {
  388. _results.push(k);
  389. }
  390. return _results;
  391. })();
  392. for (_i = 0, _len = presets.length; _i < _len; _i++) {
  393. k = presets[_i];
  394. if (!codesign.CodeSign.is_valid_preset(k)) {
  395. err = new E.ArgsError("Unknown preset " + k + " (valid values = " + (valid_presets.join(',')) + ")");
  396. presets = null;
  397. break;
  398. }
  399. }
  400. return cb(err, presets);
  401. };
  402. Command.prototype.get_ignore_list = function() {
  403. var ignore, rel_ignore;
  404. rel_ignore = path.relative(this.argv.dir, this.signed_file()).split(path.sep).join('/');
  405. ignore = rel_ignore.slice(0, 2) !== '..' ? ["/" + rel_ignore] : [];
  406. return ignore;
  407. };
  408. Command.prototype.signed_file = function() {
  409. return this.argv.input || this.argv.output || path.join(this.argv.dir, codesign.constants.defaults.FILENAME);
  410. };
  411. Command.prototype.target_file_to_json = function(fname, cb) {
  412. var body, err, f_err, obj, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  413. __iced_k = __iced_k_noop;
  414. ___iced_passed_deferral = iced.findDeferral(arguments);
  415. /*
  416. returns null, null # if there is no target file,
  417. otherwise: err, obj
  418. */
  419. log.debug("+ Command::target_file_to_json");
  420. obj = null;
  421. err = null;
  422. (function(_this) {
  423. return (function(__iced_k) {
  424. __iced_deferrals = new iced.Deferrals(__iced_k, {
  425. parent: ___iced_passed_deferral,
  426. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  427. funcname: "Command.target_file_to_json"
  428. });
  429. fs.readFile(fname, 'utf8', __iced_deferrals.defer({
  430. assign_fn: (function() {
  431. return function() {
  432. f_err = arguments[0];
  433. return body = arguments[1];
  434. };
  435. })(),
  436. lineno: 235
  437. }));
  438. __iced_deferrals._fulfill();
  439. });
  440. })(this)((function(_this) {
  441. return function() {
  442. if (typeof body !== "undefined" && body !== null) {
  443. obj = codesign.markdown_to_obj(body);
  444. if (obj == null) {
  445. err = new E.CorruptionError("Could not parse file " + fname);
  446. }
  447. }
  448. log.debug("- Command::target_file_to_json");
  449. return cb(err, obj);
  450. };
  451. })(this));
  452. };
  453. Command.prototype.process_probs = function(probs, cb) {
  454. /*
  455. outputs warning and errors based on strict/quiet settings,
  456. and calls back with error if appropriate
  457. */
  458. var err, err_table, p, warn_table, _i, _j, _len, _len1, _ref1, _ref2;
  459. err_table = (function() {
  460. var _i, _len, _results;
  461. _results = [];
  462. for (_i = 0, _len = probs.length; _i < _len; _i++) {
  463. p = probs[_i];
  464. if ((p[0] >= 100) || this.argv.strict) {
  465. _results.push(p);
  466. }
  467. }
  468. return _results;
  469. }).call(this);
  470. warn_table = (function() {
  471. var _i, _len, _results;
  472. _results = [];
  473. for (_i = 0, _len = probs.length; _i < _len; _i++) {
  474. p = probs[_i];
  475. if ((p[0] < 100) && (!this.argv.strict) && (!this.argv.quiet)) {
  476. _results.push(p);
  477. }
  478. }
  479. return _results;
  480. }).call(this);
  481. err = null;
  482. if (warn_table.length) {
  483. for (_i = 0, _len = warn_table.length; _i < _len; _i++) {
  484. p = warn_table[_i];
  485. log.warn("" + p[0] + "\t" + (((_ref1 = p[1].expected) != null ? _ref1.path : void 0) || p[1].got.path) + ": " + p[1].msg);
  486. }
  487. }
  488. if (err_table.length) {
  489. for (_j = 0, _len1 = err_table.length; _j < _len1; _j++) {
  490. p = err_table[_j];
  491. log.error("" + p[0] + "\t" + (((_ref2 = p[1].expected) != null ? _ref2.path : void 0) || p[1].got.path) + ": " + p[1].msg);
  492. }
  493. if (!this.argv.ignore_verify_errors) {
  494. err = new Error("Exited after " + err_table.length + " error(s)");
  495. }
  496. }
  497. return cb(err, {
  498. warnings: warn_table.length,
  499. errors: err_table.length
  500. });
  501. };
  502. Command.prototype.keybase_username_from_signer = function(s, cb) {
  503. var m, rxx;
  504. rxx = /^https:\/\/keybase.io\/([^\s\n]+)$/g;
  505. if ((m = rxx.exec(s)) != null) {
  506. return cb(null, m[1]);
  507. } else {
  508. return cb(new Error('Could not extract a keybase username from signer'));
  509. }
  510. };
  511. Command.prototype.verify = function(cb) {
  512. var eng, err, err_dummy, esc, json_obj, payload, probs, signature, signer, summ, username, warnings, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  513. __iced_k = __iced_k_noop;
  514. ___iced_passed_deferral = iced.findDeferral(arguments);
  515. log.debug("+ Command::verify");
  516. esc = make_esc(cb, "Command::verify");
  517. eng = new MyEngine({
  518. argv: this.argv
  519. });
  520. (function(_this) {
  521. return (function(__iced_k) {
  522. __iced_deferrals = new iced.Deferrals(__iced_k, {
  523. parent: ___iced_passed_deferral,
  524. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  525. funcname: "Command.verify"
  526. });
  527. eng.global_init(esc(__iced_deferrals.defer({
  528. lineno: 278
  529. })));
  530. __iced_deferrals._fulfill();
  531. });
  532. })(this)((function(_this) {
  533. return function() {
  534. (function(__iced_k) {
  535. __iced_deferrals = new iced.Deferrals(__iced_k, {
  536. parent: ___iced_passed_deferral,
  537. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  538. funcname: "Command.verify"
  539. });
  540. _this.target_file_to_json(_this.signed_file(), esc(__iced_deferrals.defer({
  541. assign_fn: (function() {
  542. return function() {
  543. return json_obj = arguments[0];
  544. };
  545. })(),
  546. lineno: 281
  547. })));
  548. __iced_deferrals._fulfill();
  549. })(function() {
  550. (function(__iced_k) {
  551. if (typeof json_obj === "undefined" || json_obj === null) {
  552. err = new E.NotFoundError("Could not open " + (_this.signed_file()));
  553. (function(__iced_k) {
  554. __iced_deferrals = new iced.Deferrals(__iced_k, {
  555. parent: ___iced_passed_deferral,
  556. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  557. funcname: "Command.verify"
  558. });
  559. athrow(err, esc(__iced_deferrals.defer({
  560. lineno: 285
  561. })));
  562. __iced_deferrals._fulfill();
  563. })(__iced_k);
  564. } else {
  565. return __iced_k();
  566. }
  567. })(function() {
  568. payload = codesign.CodeSign.json_obj_to_signable_payload(json_obj);
  569. (function(__iced_k) {
  570. var _i, _len, _ref1, _results, _while;
  571. _ref1 = json_obj.signatures;
  572. _len = _ref1.length;
  573. _i = 0;
  574. _results = [];
  575. _while = function(__iced_k) {
  576. var _break, _continue, _next, _ref2;
  577. _break = function() {
  578. return __iced_k(_results);
  579. };
  580. _continue = function() {
  581. return iced.trampoline(function() {
  582. ++_i;
  583. return _while(__iced_k);
  584. });
  585. };
  586. _next = function(__iced_next_arg) {
  587. _results.push(__iced_next_arg);
  588. return _continue();
  589. };
  590. if (!(_i < _len)) {
  591. return _break();
  592. } else {
  593. _ref2 = _ref1[_i], signature = _ref2.signature, signer = _ref2.signer;
  594. (function(__iced_k) {
  595. __iced_deferrals = new iced.Deferrals(__iced_k, {
  596. parent: ___iced_passed_deferral,
  597. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  598. funcname: "Command.verify"
  599. });
  600. _this.keybase_username_from_signer(signer, esc(__iced_deferrals.defer({
  601. assign_fn: (function() {
  602. return function() {
  603. return username = arguments[0];
  604. };
  605. })(),
  606. lineno: 290
  607. })));
  608. __iced_deferrals._fulfill();
  609. })(function() {
  610. (function(__iced_k) {
  611. __iced_deferrals = new iced.Deferrals(__iced_k, {
  612. parent: ___iced_passed_deferral,
  613. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  614. funcname: "Command.verify"
  615. });
  616. eng.run1({
  617. payload: payload,
  618. username: username,
  619. signature: signature
  620. }, esc(__iced_deferrals.defer({
  621. lineno: 292
  622. })));
  623. __iced_deferrals._fulfill();
  624. })(_next);
  625. });
  626. }
  627. };
  628. _while(__iced_k);
  629. })(function() {
  630. (function(__iced_k) {
  631. __iced_deferrals = new iced.Deferrals(__iced_k, {
  632. parent: ___iced_passed_deferral,
  633. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  634. funcname: "Command.verify"
  635. });
  636. eng.global_cleanup(__iced_deferrals.defer({
  637. assign_fn: (function() {
  638. return function() {
  639. return err_dummy = arguments[0];
  640. };
  641. })(),
  642. lineno: 295
  643. }));
  644. __iced_deferrals._fulfill();
  645. })(function() {
  646. summ = new codesign.CodeSign(_this.argv.dir, {
  647. ignore: json_obj.ignore,
  648. presets: json_obj.presets
  649. });
  650. (function(__iced_k) {
  651. __iced_deferrals = new iced.Deferrals(__iced_k, {
  652. parent: ___iced_passed_deferral,
  653. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  654. funcname: "Command.verify"
  655. });
  656. summ.walk(esc(__iced_deferrals.defer({
  657. lineno: 299
  658. })));
  659. __iced_deferrals._fulfill();
  660. })(function() {
  661. (function(__iced_k) {
  662. __iced_deferrals = new iced.Deferrals(__iced_k, {
  663. parent: ___iced_passed_deferral,
  664. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  665. funcname: "Command.verify"
  666. });
  667. summ.compare_to_json_obj(json_obj, __iced_deferrals.defer({
  668. assign_fn: (function() {
  669. return function() {
  670. return probs = arguments[0];
  671. };
  672. })(),
  673. lineno: 300
  674. }));
  675. __iced_deferrals._fulfill();
  676. })(function() {
  677. (function(__iced_k) {
  678. __iced_deferrals = new iced.Deferrals(__iced_k, {
  679. parent: ___iced_passed_deferral,
  680. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  681. funcname: "Command.verify"
  682. });
  683. _this.process_probs(probs, esc(__iced_deferrals.defer({
  684. assign_fn: (function() {
  685. return function() {
  686. return warnings = arguments[0].warnings;
  687. };
  688. })(),
  689. lineno: 301
  690. })));
  691. __iced_deferrals._fulfill();
  692. })(function() {
  693. if (!_this.argv.quiet) {
  694. log.info("Success! " + json_obj.signatures.length + " signature(s) verified;" + (" " + json_obj.found.length + " items checked") + (warnings ? " with " + warnings + " warning(s); pass --strict to prevent success on warnings; --quiet to hide warnings" : ''));
  695. }
  696. log.debug("- Command::verify");
  697. return cb();
  698. });
  699. });
  700. });
  701. });
  702. });
  703. });
  704. });
  705. };
  706. })(this));
  707. };
  708. Command.prototype.sign = function(cb) {
  709. var cs, esc, json_obj, md, my_username, old_err, old_obj, preset_list, probs, sig, signature, signer, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  710. __iced_k = __iced_k_noop;
  711. ___iced_passed_deferral = iced.findDeferral(arguments);
  712. log.debug("+ Command::sign");
  713. esc = make_esc(cb, "Command::sign");
  714. (function(_this) {
  715. return (function(__iced_k) {
  716. __iced_deferrals = new iced.Deferrals(__iced_k, {
  717. parent: ___iced_passed_deferral,
  718. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  719. funcname: "Command.sign"
  720. });
  721. keypull({
  722. stdin_blocked: _this.is_batch(),
  723. need_secret: true
  724. }, esc(__iced_deferrals.defer({
  725. lineno: 320
  726. })));
  727. __iced_deferrals._fulfill();
  728. });
  729. })(this)((function(_this) {
  730. return function() {
  731. (function(__iced_k) {
  732. __iced_deferrals = new iced.Deferrals(__iced_k, {
  733. parent: ___iced_passed_deferral,
  734. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  735. funcname: "Command.sign"
  736. });
  737. _this.load_me(esc(__iced_deferrals.defer({
  738. lineno: 321
  739. })));
  740. __iced_deferrals._fulfill();
  741. })(function() {
  742. my_username = "https://keybase.io/" + (_this.me.username());
  743. (function(__iced_k) {
  744. __iced_deferrals = new iced.Deferrals(__iced_k, {
  745. parent: ___iced_passed_deferral,
  746. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  747. funcname: "Command.sign"
  748. });
  749. _this.get_preset_list(esc(__iced_deferrals.defer({
  750. assign_fn: (function() {
  751. return function() {
  752. return preset_list = arguments[0];
  753. };
  754. })(),
  755. lineno: 328
  756. })));
  757. __iced_deferrals._fulfill();
  758. })(function() {
  759. cs = new codesign.CodeSign(_this.argv.dir, {
  760. ignore: _this.get_ignore_list(),
  761. presets: preset_list
  762. });
  763. (function(__iced_k) {
  764. __iced_deferrals = new iced.Deferrals(__iced_k, {
  765. parent: ___iced_passed_deferral,
  766. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  767. funcname: "Command.sign"
  768. });
  769. cs.walk(esc(__iced_deferrals.defer({
  770. lineno: 330
  771. })));
  772. __iced_deferrals._fulfill();
  773. })(function() {
  774. (function(__iced_k) {
  775. __iced_deferrals = new iced.Deferrals(__iced_k, {
  776. parent: ___iced_passed_deferral,
  777. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  778. funcname: "Command.sign"
  779. });
  780. _this.target_file_to_json(_this.signed_file(), __iced_deferrals.defer({
  781. assign_fn: (function() {
  782. return function() {
  783. old_err = arguments[0];
  784. return old_obj = arguments[1];
  785. };
  786. })(),
  787. lineno: 336
  788. }));
  789. __iced_deferrals._fulfill();
  790. })(function() {
  791. (function(__iced_k) {
  792. if (typeof old_obj !== "undefined" && old_obj !== null) {
  793. (function(__iced_k) {
  794. __iced_deferrals = new iced.Deferrals(__iced_k, {
  795. parent: ___iced_passed_deferral,
  796. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  797. funcname: "Command.sign"
  798. });
  799. cs.compare_to_json_obj(old_obj, __iced_deferrals.defer({
  800. assign_fn: (function() {
  801. return function() {
  802. return probs = arguments[0];
  803. };
  804. })(),
  805. lineno: 338
  806. }));
  807. __iced_deferrals._fulfill();
  808. })(function() {
  809. var _i, _len, _ref1, _ref2;
  810. if (!probs.length) {
  811. if (!_this.argv.quiet) {
  812. log.info("Found existing " + (_this.signed_file()));
  813. }
  814. _ref1 = old_obj.signatures;
  815. for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
  816. _ref2 = _ref1[_i], signer = _ref2.signer, signature = _ref2.signature;
  817. if (!(signer !== my_username)) {
  818. continue;
  819. }
  820. cs.attach_sig(signer, signature);
  821. log.info("Re-attaching still-valid signature from " + signer);
  822. }
  823. } else {
  824. if (!_this.argv.quiet) {
  825. log.info("Will replace existing/obsolete " + (_this.signed_file()));
  826. }
  827. }
  828. return __iced_k();
  829. });
  830. } else {
  831. return __iced_k();
  832. }
  833. })(function() {
  834. (function(__iced_k) {
  835. __iced_deferrals = new iced.Deferrals(__iced_k, {
  836. parent: ___iced_passed_deferral,
  837. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  838. funcname: "Command.sign"
  839. });
  840. _this.do_sign(cs.signable_payload(), esc(__iced_deferrals.defer({
  841. assign_fn: (function() {
  842. return function() {
  843. return sig = arguments[0];
  844. };
  845. })(),
  846. lineno: 351
  847. })));
  848. __iced_deferrals._fulfill();
  849. })(function() {
  850. cs.attach_sig(my_username, sig);
  851. json_obj = cs.to_json_obj();
  852. md = codesign.obj_to_markdown(json_obj);
  853. (function(__iced_k) {
  854. __iced_deferrals = new iced.Deferrals(__iced_k, {
  855. parent: ___iced_passed_deferral,
  856. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  857. funcname: "Command.sign"
  858. });
  859. fs.writeFile(_this.signed_file(), md, {
  860. encoding: 'utf8'
  861. }, esc(__iced_deferrals.defer({
  862. lineno: 359
  863. })));
  864. __iced_deferrals._fulfill();
  865. })(function() {
  866. if (!_this.argv.quiet) {
  867. log.info("Success! Wrote " + (_this.signed_file()) + " from " + json_obj.found.length + " found items");
  868. }
  869. log.debug("- Command::sign");
  870. return cb();
  871. });
  872. });
  873. });
  874. });
  875. });
  876. });
  877. });
  878. };
  879. })(this));
  880. };
  881. Command.prototype.run = function(cb) {
  882. var esc, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  883. __iced_k = __iced_k_noop;
  884. ___iced_passed_deferral = iced.findDeferral(arguments);
  885. esc = make_esc(cb, "Command::run");
  886. log.debug("+ Command::run");
  887. (function(_this) {
  888. return (function(__iced_k) {
  889. switch (_this.argv.dir_subcommand) {
  890. case 'sign':
  891. (function(__iced_k) {
  892. __iced_deferrals = new iced.Deferrals(__iced_k, {
  893. parent: ___iced_passed_deferral,
  894. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  895. funcname: "Command.run"
  896. });
  897. _this.sign(esc(__iced_deferrals.defer({
  898. lineno: 372
  899. })));
  900. __iced_deferrals._fulfill();
  901. })(__iced_k);
  902. break;
  903. case 'verify':
  904. (function(__iced_k) {
  905. __iced_deferrals = new iced.Deferrals(__iced_k, {
  906. parent: ___iced_passed_deferral,
  907. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  908. funcname: "Command.run"
  909. });
  910. _this.verify(esc(__iced_deferrals.defer({
  911. lineno: 373
  912. })));
  913. __iced_deferrals._fulfill();
  914. })(__iced_k);
  915. break;
  916. case 'tojson':
  917. (function(__iced_k) {
  918. __iced_deferrals = new iced.Deferrals(__iced_k, {
  919. parent: ___iced_passed_deferral,
  920. filename: "/home/max/src/keybase/node-client/src/command/dir.iced",
  921. funcname: "Command.run"
  922. });
  923. _this.tojson(esc(__iced_deferrals.defer({
  924. lineno: 374
  925. })));
  926. __iced_deferrals._fulfill();
  927. })(__iced_k);
  928. break;
  929. default:
  930. return __iced_k();
  931. }
  932. });
  933. })(this)((function(_this) {
  934. return function() {
  935. log.debug("- Command::run");
  936. return cb(null);
  937. };
  938. })(this));
  939. };
  940. return Command;
  941. })(Base);
  942. }).call(this);