base.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. // Generated by IcedCoffeeScript 1.7.1-c
  2. (function() {
  3. var Base, E, EscOk, FN, Infile, Outfile, PasswordManager, SC, SRV, add_option_dict, base58, constants, crypto, env, fs, iced, join, log, make_esc, myfs, pick, req, rmkey, triplesec, __iced_k, __iced_k_noop, _ref,
  4. __slice = [].slice;
  5. iced = require('iced-runtime').iced;
  6. __iced_k = __iced_k_noop = function() {};
  7. log = require('../log');
  8. PasswordManager = require('../pw').PasswordManager;
  9. base58 = require('../basex').base58;
  10. crypto = require('crypto');
  11. myfs = require('../fs');
  12. fs = require('fs');
  13. rmkey = require('../util').rmkey;
  14. add_option_dict = require('./argparse').add_option_dict;
  15. _ref = require('../file'), Infile = _ref.Infile, Outfile = _ref.Outfile;
  16. EscOk = require('iced-error').EscOk;
  17. E = require('../err').E;
  18. constants = require('../constants').constants;
  19. join = require('path').join;
  20. FN = constants.filenames;
  21. SRV = constants.server;
  22. SC = constants.security;
  23. triplesec = require('triplesec');
  24. req = require('../req');
  25. env = require('../env').env;
  26. make_esc = require('iced-error').make_esc;
  27. pick = function() {
  28. var a, args, _i, _len;
  29. args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
  30. for (_i = 0, _len = args.length; _i < _len; _i++) {
  31. a = args[_i];
  32. if (a != null) {
  33. return a;
  34. }
  35. }
  36. return null;
  37. };
  38. exports.Base = Base = (function() {
  39. function Base(parent) {
  40. this.parent = parent;
  41. this.batch = false;
  42. }
  43. Base.prototype.set_argv = function(a) {
  44. this.argv = a;
  45. return null;
  46. };
  47. Base.OPTS = {
  48. p: {
  49. alias: 'passphrase',
  50. help: 'passphrase used to log into keybase'
  51. },
  52. c: {
  53. alias: 'config',
  54. help: "a configuration file (" + (join('~', FN.config_dir, FN.config_file)) + ")"
  55. },
  56. i: {
  57. alias: "interactive",
  58. action: "storeTrue",
  59. help: "interactive mode"
  60. },
  61. d: {
  62. alias: "debug",
  63. action: "storeTrue",
  64. help: "debug mode"
  65. },
  66. q: {
  67. alias: "quiet",
  68. action: "storeTrue",
  69. help: "quiet mode; only show errors, suppress info and warnings"
  70. },
  71. C: {
  72. alias: "no-color",
  73. action: "storeTrue",
  74. help: "disable logging colors"
  75. },
  76. port: {
  77. help: 'which port to connect to'
  78. },
  79. "no-tls": {
  80. action: "storeTrue",
  81. help: "turn off HTTPS/TLS (on by default)"
  82. },
  83. "host": {
  84. help: 'which host to connect to'
  85. },
  86. "api-uri-prefix": {
  87. help: "the API prefix to use (" + SRV.api_uri_prefix + ")"
  88. },
  89. B: {
  90. alias: "batch",
  91. action: "storeTrue",
  92. help: "batch mode; disable all prompts"
  93. },
  94. "preserve-tmp-keyring": {
  95. action: "storeTrue",
  96. help: "preserve the temporary keyring; don't clean it up"
  97. },
  98. "homedir": {
  99. help: "specify a non-standard home directory; look for GPG keychain there"
  100. },
  101. g: {
  102. alias: "gpg",
  103. help: "specify an alternate gpg command"
  104. },
  105. x: {
  106. alias: 'proxy',
  107. help: 'specify a proxy server to all HTTPS requests'
  108. },
  109. "proxy-ca-certs": {
  110. action: "append",
  111. help: "specify 1 or more CA certs (in a file)"
  112. },
  113. O: {
  114. alias: "no-gpg-options",
  115. action: "storeTrue",
  116. help: "disable the GPG options file for temporary keyring operations"
  117. },
  118. M: {
  119. alias: "merkle-checks",
  120. help: "check that users' chains are reflected in sitewide state, one of {none,soft,strict}; soft by default"
  121. },
  122. "tor-proxy": {
  123. help: "specify a Tor SOCKS proxy"
  124. },
  125. "tor-hidden-address": {
  126. help: "specify the Tor hidden address for keybase.io"
  127. },
  128. "tor-leaky": {
  129. help: "override Tor strict mode",
  130. action: "storeTrue"
  131. },
  132. S: {
  133. alias: "tor-strict",
  134. help: "Don't show any user-identifiable information to server; might break some features",
  135. action: "storeTrue"
  136. },
  137. T: {
  138. alias: 'tor',
  139. action: "storeTrue",
  140. help: "enable Tor proxying with default settings; requires Tor Socks5 proxy on port 9050"
  141. }
  142. };
  143. Base.prototype.use_config = function() {
  144. return true;
  145. };
  146. Base.prototype.use_session = function() {
  147. return false;
  148. };
  149. Base.prototype.use_db = function() {
  150. return true;
  151. };
  152. Base.prototype.use_gpg = function() {
  153. return true;
  154. };
  155. Base.prototype.config_opts = function() {
  156. return {};
  157. };
  158. Base.prototype.needs_configuration = function() {
  159. return false;
  160. };
  161. Base.prototype.needs_cookies = function() {
  162. return false;
  163. };
  164. Base.prototype.make_outfile = function(cb) {
  165. var err, file, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  166. __iced_k = __iced_k_noop;
  167. ___iced_passed_deferral = iced.findDeferral(arguments);
  168. (function(_this) {
  169. return (function(__iced_k) {
  170. __iced_deferrals = new iced.Deferrals(__iced_k, {
  171. parent: ___iced_passed_deferral,
  172. filename: "/Users/max/src/keybase/node-client/src/command/base.iced",
  173. funcname: "Base.make_outfile"
  174. });
  175. Outfile.open({
  176. target: _this.output_filename()
  177. }, __iced_deferrals.defer({
  178. assign_fn: (function() {
  179. return function() {
  180. err = arguments[0];
  181. return file = arguments[1];
  182. };
  183. })(),
  184. lineno: 132
  185. }));
  186. __iced_deferrals._fulfill();
  187. });
  188. })(this)((function(_this) {
  189. return function() {
  190. return cb(err, file);
  191. };
  192. })(this));
  193. };
  194. Base.prototype._init_pwmgr = function() {
  195. var pwopts;
  196. pwopts = {
  197. password: this.password(),
  198. salt: this.salt_or_email(),
  199. interactive: this.argv.interactive
  200. };
  201. return this.pwmgr.init(pwopts);
  202. };
  203. Base.prototype.password = function() {
  204. return pick(this.argv.password, this.config.password());
  205. };
  206. Base.prototype.assertions = function(cb) {
  207. var esc, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  208. __iced_k = __iced_k_noop;
  209. ___iced_passed_deferral = iced.findDeferral(arguments);
  210. esc = make_esc(cb, "Base::assertions");
  211. (function(_this) {
  212. return (function(__iced_k) {
  213. __iced_deferrals = new iced.Deferrals(__iced_k, {
  214. parent: ___iced_passed_deferral,
  215. filename: "/Users/max/src/keybase/node-client/src/command/base.iced",
  216. funcname: "Base.assertions"
  217. });
  218. _this.assert_configured(esc(__iced_deferrals.defer({
  219. lineno: 153
  220. })));
  221. __iced_deferrals._fulfill();
  222. });
  223. })(this)((function(_this) {
  224. return function() {
  225. return cb(null);
  226. };
  227. })(this));
  228. };
  229. Base.prototype.assert_configured = function(cb) {
  230. var err;
  231. err = null;
  232. if (this.needs_configuration() && !(env().is_configured())) {
  233. err = new E.NotConfiguredError("you're not logged in. Please run `keybase login` or `keybase join`");
  234. }
  235. return cb(err);
  236. };
  237. return Base;
  238. })();
  239. }).call(this);