revoke_sig.js 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. // Generated by IcedCoffeeScript 1.7.1-c
  2. (function() {
  3. var ArgumentParser, Base, Command, E, PackageJson, RevokeProofSigGen, S, ST, User, add_option_dict, assert, constants, iced, log, make_esc, prompt_yn, proofs, req, session, __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. Base = require('./base').Base;
  9. log = require('../log');
  10. ArgumentParser = require('argparse').ArgumentParser;
  11. add_option_dict = require('./argparse').add_option_dict;
  12. PackageJson = require('../package').PackageJson;
  13. E = require('../err').E;
  14. make_esc = require('iced-error').make_esc;
  15. prompt_yn = require('../prompter').prompt_yn;
  16. RevokeProofSigGen = require('../sigs').RevokeProofSigGen;
  17. User = require('../user').User;
  18. req = require('../req').req;
  19. assert = require('assert');
  20. session = require('../session');
  21. S = require('../services');
  22. constants = require('../constants').constants;
  23. ST = constants.signature_types;
  24. prompt_yn = require('../prompter').prompt_yn;
  25. proofs = require('keybase-proofs');
  26. assert = require('assert');
  27. exports.Command = Command = (function(_super) {
  28. __extends(Command, _super);
  29. function Command() {
  30. return Command.__super__.constructor.apply(this, arguments);
  31. }
  32. Command.prototype.OPTS = {
  33. q: {
  34. alias: 'seqno',
  35. action: 'storeTrue',
  36. help: 'specify signature as a sequence number'
  37. }
  38. };
  39. Command.prototype.use_session = function() {
  40. return true;
  41. };
  42. Command.prototype.needs_configuration = function() {
  43. return true;
  44. };
  45. Command.prototype.parse_args = function(cb) {
  46. var err, key;
  47. key = this.argv.sig[0];
  48. err = null;
  49. if (this.argv.seqno) {
  50. if (key.match(/^\d+$/)) {
  51. this.seqno = parseInt(key, 10);
  52. } else {
  53. err = new E.ArgsError("bad integer: " + key);
  54. }
  55. } else if (!key.match(/^[A-Fa-f0-9]+$/)) {
  56. err = new E.ArgsError("bad signature ID: " + key);
  57. } else if (key.length < 4) {
  58. err = new E.ArgsError("bad signature ID " + key + "; must provide at least a 4-char prefix");
  59. } else {
  60. this.sig_id = key.toLowerCase();
  61. }
  62. return cb(err);
  63. };
  64. Command.prototype.add_subcommand_parser = function(scp) {
  65. var name, opts, sub;
  66. opts = {
  67. help: "revoke a proof or signature",
  68. aliases: ["revoke-sig"]
  69. };
  70. name = "revoke-signatures";
  71. sub = scp.addParser(name, opts);
  72. sub.addArgument(["sig"], {
  73. nargs: 1,
  74. help: "the ID or seqno of the sig the revoke"
  75. });
  76. add_option_dict(sub, this.OPTS);
  77. return [name].concat(opts.aliases);
  78. };
  79. Command.prototype.allocate_proof_gen = function(cb) {
  80. var err, klass, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  81. __iced_k = __iced_k_noop;
  82. ___iced_passed_deferral = iced.findDeferral(arguments);
  83. klass = RevokeProofSigGen;
  84. (function(_this) {
  85. return (function(__iced_k) {
  86. __iced_deferrals = new iced.Deferrals(__iced_k, {
  87. parent: ___iced_passed_deferral,
  88. filename: "/Users/max/src/keybase/node-client/src/command/revoke_sig.iced",
  89. funcname: "Command.allocate_proof_gen"
  90. });
  91. _this.me.gen_remote_proof_gen({
  92. klass: klass,
  93. sig_id: _this.sig_id
  94. }, __iced_deferrals.defer({
  95. assign_fn: (function(__slot_1) {
  96. return function() {
  97. err = arguments[0];
  98. return __slot_1.gen = arguments[1];
  99. };
  100. })(_this),
  101. lineno: 69
  102. }));
  103. __iced_deferrals._fulfill();
  104. });
  105. })(this)((function(_this) {
  106. return function() {
  107. return cb(err);
  108. };
  109. })(this));
  110. };
  111. Command.prototype.find_sig_by_prefix = function(p) {
  112. var err, found, k, v, _ref;
  113. found = null;
  114. err = null;
  115. _ref = this.me.sig_chain.index;
  116. for (k in _ref) {
  117. v = _ref[k];
  118. if (k.indexOf(p) !== 0) {
  119. } else if (found != null) {
  120. err = new E.DuplicateError("Key '" + p + "' matches more than one signature");
  121. found = null;
  122. break;
  123. } else {
  124. found = v;
  125. }
  126. }
  127. return [err, found];
  128. };
  129. Command.prototype.find_sig = function(cb) {
  130. var err, key, sig, _ref;
  131. key = this.argv.sig[0];
  132. if (this.seqno) {
  133. sig = this.me.sig_chain.seq[this.seqno];
  134. } else {
  135. _ref = this.find_sig_by_prefix(this.sig_id), err = _ref[0], sig = _ref[1];
  136. }
  137. err = err != null ? err : sig == null ? new E.NotFoundError("Signature not found (key=" + key + ")") : sig.is_revoked() ? new E.RevokedError("Signature already revoked") : !sig.is_revocable() ? new E.RevokeError("signature is not revocable") : null;
  138. if (err == null) {
  139. this.sig_id = sig.sig_id();
  140. }
  141. return cb(err);
  142. };
  143. Command.prototype.run = function(cb) {
  144. var esc, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  145. __iced_k = __iced_k_noop;
  146. ___iced_passed_deferral = iced.findDeferral(arguments);
  147. esc = make_esc(cb, "Command::run");
  148. (function(_this) {
  149. return (function(__iced_k) {
  150. __iced_deferrals = new iced.Deferrals(__iced_k, {
  151. parent: ___iced_passed_deferral,
  152. filename: "/Users/max/src/keybase/node-client/src/command/revoke_sig.iced",
  153. funcname: "Command.run"
  154. });
  155. _this.parse_args(esc(__iced_deferrals.defer({
  156. lineno: 105
  157. })));
  158. __iced_deferrals._fulfill();
  159. });
  160. })(this)((function(_this) {
  161. return function() {
  162. (function(__iced_k) {
  163. __iced_deferrals = new iced.Deferrals(__iced_k, {
  164. parent: ___iced_passed_deferral,
  165. filename: "/Users/max/src/keybase/node-client/src/command/revoke_sig.iced",
  166. funcname: "Command.run"
  167. });
  168. session.login(esc(__iced_deferrals.defer({
  169. lineno: 106
  170. })));
  171. __iced_deferrals._fulfill();
  172. })(function() {
  173. (function(__iced_k) {
  174. __iced_deferrals = new iced.Deferrals(__iced_k, {
  175. parent: ___iced_passed_deferral,
  176. filename: "/Users/max/src/keybase/node-client/src/command/revoke_sig.iced",
  177. funcname: "Command.run"
  178. });
  179. User.load_me({
  180. secret: true,
  181. verify_opts: {
  182. show_perm_failures: true
  183. }
  184. }, esc(__iced_deferrals.defer({
  185. assign_fn: (function(__slot_1) {
  186. return function() {
  187. return __slot_1.me = arguments[0];
  188. };
  189. })(_this),
  190. lineno: 107
  191. })));
  192. __iced_deferrals._fulfill();
  193. })(function() {
  194. (function(__iced_k) {
  195. __iced_deferrals = new iced.Deferrals(__iced_k, {
  196. parent: ___iced_passed_deferral,
  197. filename: "/Users/max/src/keybase/node-client/src/command/revoke_sig.iced",
  198. funcname: "Command.run"
  199. });
  200. _this.find_sig(esc(__iced_deferrals.defer({
  201. lineno: 108
  202. })));
  203. __iced_deferrals._fulfill();
  204. })(function() {
  205. (function(__iced_k) {
  206. __iced_deferrals = new iced.Deferrals(__iced_k, {
  207. parent: ___iced_passed_deferral,
  208. filename: "/Users/max/src/keybase/node-client/src/command/revoke_sig.iced",
  209. funcname: "Command.run"
  210. });
  211. _this.allocate_proof_gen(esc(__iced_deferrals.defer({
  212. lineno: 109
  213. })));
  214. __iced_deferrals._fulfill();
  215. })(function() {
  216. (function(__iced_k) {
  217. __iced_deferrals = new iced.Deferrals(__iced_k, {
  218. parent: ___iced_passed_deferral,
  219. filename: "/Users/max/src/keybase/node-client/src/command/revoke_sig.iced",
  220. funcname: "Command.run"
  221. });
  222. _this.gen.run(esc(__iced_deferrals.defer({
  223. lineno: 110
  224. })));
  225. __iced_deferrals._fulfill();
  226. })(function() {
  227. log.info("Success!");
  228. return cb(null);
  229. });
  230. });
  231. });
  232. });
  233. });
  234. };
  235. })(this));
  236. };
  237. return Command;
  238. })(Base);
  239. }).call(this);