push.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. // Generated by IcedCoffeeScript 1.7.1-c
  2. (function() {
  3. var Command, E, KeyPatcher, add_option_dict, env, iced, key_select, load_key, make_esc, pg, __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. pg = require('./push_and_keygen');
  9. E = require('../err').E;
  10. make_esc = require('iced-error').make_esc;
  11. add_option_dict = require('./argparse').add_option_dict;
  12. env = require('../env').env;
  13. key_select = require('../keyselector').key_select;
  14. load_key = require('../keyring').load_key;
  15. KeyPatcher = require('../keypatch').KeyPatcher;
  16. exports.Command = Command = (function(_super) {
  17. __extends(Command, _super);
  18. function Command() {
  19. return Command.__super__.constructor.apply(this, arguments);
  20. }
  21. Command.prototype.OPTS = {
  22. g: {
  23. alias: "gen",
  24. action: "storeTrue",
  25. help: "generate a new key"
  26. },
  27. p: {
  28. alias: "show-public-only-keys",
  29. action: "storeTrue",
  30. help: "Allow picking of public keys for which no secret key is available (not recommended)"
  31. },
  32. "skip-add-email": {
  33. action: "storeTrue",
  34. help: "Skip the prompt asking if we want to store email to key; don't do it"
  35. },
  36. "add-email": {
  37. action: "storeTrue",
  38. help: "Add email to key by default, if needed"
  39. }
  40. };
  41. Command.prototype.add_subcommand_parser = function(scp) {
  42. var name, opts, sub;
  43. opts = {
  44. aliases: [],
  45. help: "push a PGP key from the client to the server"
  46. };
  47. name = "push";
  48. sub = scp.addParser(name, opts);
  49. add_option_dict(sub, this.OPTS);
  50. add_option_dict(sub, pg.Command.OPTS);
  51. sub.addArgument(["search"], {
  52. nargs: '?',
  53. help: "search parameter to find the right key"
  54. });
  55. return opts.aliases.concat([name]);
  56. };
  57. Command.prototype.check_args = function(cb) {
  58. var err;
  59. err = null;
  60. if (this.argv.search && this.argv.gen) {
  61. err = new E.ArgsError("Can't both search and generate; pick one or the other!");
  62. } else if (this.argv.search && this.secret_only()) {
  63. err = new E.ArgsError("Can't specify a search with secret-only-push; has to correspond to your public");
  64. }
  65. return cb(err);
  66. };
  67. Command.prototype.load_key = function(cb) {
  68. return cb(err);
  69. };
  70. Command.prototype.prepare_key = function(cb) {
  71. var did_patch, err, esc, kp, secret, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  72. __iced_k = __iced_k_noop;
  73. ___iced_passed_deferral = iced.findDeferral(arguments);
  74. err = null;
  75. esc = make_esc(cb, "Command::prepare_key");
  76. (function(_this) {
  77. return (function(__iced_k) {
  78. if (_this.argv.gen) {
  79. (function(__iced_k) {
  80. __iced_deferrals = new iced.Deferrals(__iced_k, {
  81. parent: ___iced_passed_deferral,
  82. filename: "/Users/max/src/keybase/node-client/src/command/push.iced",
  83. funcname: "Command.prepare_key"
  84. });
  85. _this.do_key_gen(esc(__iced_deferrals.defer({
  86. lineno: 64
  87. })));
  88. __iced_deferrals._fulfill();
  89. })(__iced_k);
  90. } else {
  91. (function(__iced_k) {
  92. if (_this.secret_only()) {
  93. (function(__iced_k) {
  94. __iced_deferrals = new iced.Deferrals(__iced_k, {
  95. parent: ___iced_passed_deferral,
  96. filename: "/Users/max/src/keybase/node-client/src/command/push.iced",
  97. funcname: "Command.prepare_key"
  98. });
  99. load_key({
  100. username: env().get_username(),
  101. fingerprint: _this.me.fingerprint()
  102. }, esc(__iced_deferrals.defer({
  103. assign_fn: (function(__slot_1) {
  104. return function() {
  105. return __slot_1.key = arguments[0];
  106. };
  107. })(_this),
  108. lineno: 66
  109. })));
  110. __iced_deferrals._fulfill();
  111. })(__iced_k);
  112. } else {
  113. if (!_this.argv.show_public_only_keys) {
  114. secret = true;
  115. }
  116. (function(__iced_k) {
  117. __iced_deferrals = new iced.Deferrals(__iced_k, {
  118. parent: ___iced_passed_deferral,
  119. filename: "/Users/max/src/keybase/node-client/src/command/push.iced",
  120. funcname: "Command.prepare_key"
  121. });
  122. key_select({
  123. username: env().get_username(),
  124. query: _this.argv.search,
  125. secret: secret
  126. }, esc(__iced_deferrals.defer({
  127. assign_fn: (function(__slot_1) {
  128. return function() {
  129. return __slot_1.key = arguments[0];
  130. };
  131. })(_this),
  132. lineno: 69
  133. })));
  134. __iced_deferrals._fulfill();
  135. })(function() {
  136. kp = new KeyPatcher({
  137. key: _this.key,
  138. opts: _this.argv
  139. });
  140. (function(__iced_k) {
  141. __iced_deferrals = new iced.Deferrals(__iced_k, {
  142. parent: ___iced_passed_deferral,
  143. filename: "/Users/max/src/keybase/node-client/src/command/push.iced",
  144. funcname: "Command.prepare_key"
  145. });
  146. kp.run({
  147. interactive: true
  148. }, esc(__iced_deferrals.defer({
  149. assign_fn: (function() {
  150. return function() {
  151. return did_patch = arguments[0];
  152. };
  153. })(),
  154. lineno: 71
  155. })));
  156. __iced_deferrals._fulfill();
  157. })(function() {
  158. return __iced_k(did_patch ? _this.key = kp.get_key() : void 0);
  159. });
  160. });
  161. }
  162. })(__iced_k);
  163. }
  164. });
  165. })(this)((function(_this) {
  166. return function() {
  167. return cb(err);
  168. };
  169. })(this));
  170. };
  171. return Command;
  172. })(pg.Command);
  173. }).call(this);