env.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886
  1. // Generated by IcedCoffeeScript 1.7.1-c
  2. (function() {
  3. var Env, FN, RunMode, SRV, Strictness, V1, V2, constants, fs, iced, join, kbpath, make_email, make_full_username, __iced_k, __iced_k_noop, _env, _ref;
  4. iced = require('iced-runtime').iced;
  5. __iced_k = __iced_k_noop = function() {};
  6. kbpath = require('keybase-path');
  7. join = require('path').join;
  8. constants = require('./constants').constants;
  9. _ref = require('./util'), make_full_username = _ref.make_full_username, make_email = _ref.make_email;
  10. FN = constants.filenames;
  11. SRV = constants.server;
  12. fs = require('fs');
  13. RunMode = (function() {
  14. RunMode.prototype.DEVEL = 0;
  15. RunMode.prototype.PROD = 1;
  16. function RunMode(s) {
  17. var m, t, _ref1;
  18. t = {
  19. devel: this.DEVEL,
  20. prod: this.PROD
  21. };
  22. _ref1 = (s != null) && ((m = t[s]) != null) ? [m, s, true] : [this.PROD, "prod", false], this._v = _ref1[0], this._name = _ref1[1], this._chosen = _ref1[2];
  23. }
  24. RunMode.prototype.is_devel = function() {
  25. return this._v === this.DEVEL;
  26. };
  27. RunMode.prototype.is_prod = function() {
  28. return this._v === this.PROD;
  29. };
  30. RunMode.prototype.toString = function() {
  31. return this._name;
  32. };
  33. RunMode.prototype.chosen = function() {
  34. return this._chosen;
  35. };
  36. RunMode.prototype.config_dir = function() {
  37. return this._name;
  38. };
  39. return RunMode;
  40. })();
  41. Strictness = (function() {
  42. Strictness.prototype.NONE = 0;
  43. Strictness.prototype.SOFT = 1;
  44. Strictness.prototype.STRICT = 2;
  45. function Strictness(s, def) {
  46. var m, t, _chosen, _ref1;
  47. if (def == null) {
  48. def = "soft";
  49. }
  50. t = {
  51. none: this.NONE,
  52. soft: this.SOFT,
  53. strict: this.STRICT
  54. };
  55. _ref1 = (s != null) && ((m = t[s]) != null) ? [m, s, true] : [t[def], def, false], this._v = _ref1[0], this._name = _ref1[1], _chosen = _ref1[2];
  56. }
  57. Strictness.prototype.is_soft = function() {
  58. return this._v === this.SOFT;
  59. };
  60. Strictness.prototype.is_none = function() {
  61. return this._v === this.NONE;
  62. };
  63. Strictness.prototype.is_strict = function() {
  64. return this._v === this.STRICT;
  65. };
  66. Strictness.prototype.toString = function() {
  67. return this._name;
  68. };
  69. Strictness.prototype.chosen = function() {
  70. return this._chosen;
  71. };
  72. return Strictness;
  73. })();
  74. V1 = 1;
  75. V2 = 2;
  76. Env = (function() {
  77. function Env() {
  78. this.env = process.env;
  79. this.argv = null;
  80. this.config = null;
  81. this.session = null;
  82. this._gpg_cmd = null;
  83. this.kbpath = kbpath.new_eng({
  84. hooks: {
  85. get_home: (function(_this) {
  86. return function(opts) {
  87. return _this._get_home(opts);
  88. };
  89. })(this)
  90. },
  91. name: "keybase"
  92. });
  93. }
  94. Env.prototype.set_config = function(c) {
  95. return this.config = c;
  96. };
  97. Env.prototype.set_session = function(s) {
  98. return this.session = s;
  99. };
  100. Env.prototype.set_argv = function(a) {
  101. return this.argv = a;
  102. };
  103. Env.prototype.get_opt = function(_arg) {
  104. var arg, co, config, dflt, env, _ref1;
  105. env = _arg.env, arg = _arg.arg, config = _arg.config, dflt = _arg.dflt;
  106. co = (_ref1 = this.config) != null ? _ref1.obj() : void 0;
  107. return (typeof env === "function" ? env(this.env) : void 0) || (typeof arg === "function" ? arg(this.argv) : void 0) || ((co != null) && (typeof config === "function" ? config(co) : void 0)) || (typeof dflt === "function" ? dflt() : void 0) || null;
  108. };
  109. Env.prototype.get_config_dir = function(version) {
  110. if (version == null) {
  111. version = V2;
  112. }
  113. if (version === V1) {
  114. return this.kbpath.config_dir_v1();
  115. } else {
  116. return this.kbpath.config_dir();
  117. }
  118. };
  119. Env.prototype.get_data_dir = function() {
  120. return this.kbpath.data_dir();
  121. };
  122. Env.prototype.get_cache_dir = function() {
  123. return this.kbpath.cache_dir();
  124. };
  125. Env.prototype.maybe_fallback_to_layout_v1 = function(cb) {
  126. var err, old_config, res, stat, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  127. __iced_k = __iced_k_noop;
  128. ___iced_passed_deferral = iced.findDeferral(arguments);
  129. err = null;
  130. res = false;
  131. (function(_this) {
  132. return (function(__iced_k) {
  133. if (!(_this.env.XDG_CONFIG_HOME || _this.env.XDG_CACHE_HOME || _this.env.XDG_DATA_HOME)) {
  134. old_config = _this.get_config_filename(V1);
  135. (function(__iced_k) {
  136. __iced_deferrals = new iced.Deferrals(__iced_k, {
  137. parent: ___iced_passed_deferral,
  138. filename: "/Users/max/src/keybase/node-client/src/env.iced",
  139. funcname: "Env.maybe_fallback_to_layout_v1"
  140. });
  141. fs.stat(old_config, __iced_deferrals.defer({
  142. assign_fn: (function() {
  143. return function() {
  144. err = arguments[0];
  145. return stat = arguments[1];
  146. };
  147. })(),
  148. lineno: 95
  149. }));
  150. __iced_deferrals._fulfill();
  151. })(function() {
  152. return __iced_k((err == null) && (typeof stat !== "undefined" && stat !== null ? stat.isFile() : void 0) ? (_this.kbpath = _this.kbpath.fallback_to_v1(), res = true) : err.code === 'ENOENT' ? err = null : void 0);
  153. });
  154. } else {
  155. return __iced_k();
  156. }
  157. });
  158. })(this)((function(_this) {
  159. return function() {
  160. return cb(err, res);
  161. };
  162. })(this));
  163. };
  164. Env.prototype.get_port = function() {
  165. return this.get_opt({
  166. env: function(e) {
  167. return e.KEYBASE_PORT;
  168. },
  169. arg: function(a) {
  170. return a.port;
  171. },
  172. config: function(c) {
  173. var _ref1;
  174. return (_ref1 = c.server) != null ? _ref1.port : void 0;
  175. },
  176. dflt: function() {
  177. return SRV.port;
  178. }
  179. });
  180. };
  181. Env.prototype.get_config_filename = function(version) {
  182. if (version == null) {
  183. version = V2;
  184. }
  185. return this.get_opt({
  186. env: function(e) {
  187. return e.KEYBASE_CONFIG_FILE;
  188. },
  189. arg: function(a) {
  190. return a.config;
  191. },
  192. dflt: (function(_this) {
  193. return function() {
  194. return join(_this.get_config_dir(version), FN.config_file);
  195. };
  196. })(this)
  197. });
  198. };
  199. Env.prototype.get_session_filename = function() {
  200. return this.get_opt({
  201. env: function(e) {
  202. return e.KEYBASE_SESSION_FILE;
  203. },
  204. arg: function(a) {
  205. return a.session_file;
  206. },
  207. config: function(c) {
  208. var _ref1;
  209. return c != null ? (_ref1 = c.files) != null ? _ref1.session : void 0 : void 0;
  210. },
  211. dflt: (function(_this) {
  212. return function() {
  213. return join(_this.get_cache_dir(), FN.session_file);
  214. };
  215. })(this)
  216. });
  217. };
  218. Env.prototype.get_db_filename = function() {
  219. return this.get_opt({
  220. env: function(e) {
  221. return e.KEYBASE_DB_FILE;
  222. },
  223. arg: function(a) {
  224. return a.db_file;
  225. },
  226. config: function(c) {
  227. var _ref1;
  228. return c != null ? (_ref1 = c.files) != null ? _ref1.db : void 0 : void 0;
  229. },
  230. dflt: (function(_this) {
  231. return function() {
  232. return join(_this.get_data_dir(), FN.db_file);
  233. };
  234. })(this)
  235. });
  236. };
  237. Env.prototype.get_nedb_filename = function() {
  238. return this.get_opt({
  239. config: function(c) {
  240. var _ref1;
  241. return c != null ? (_ref1 = c.files) != null ? _ref1.nedb : void 0 : void 0;
  242. },
  243. dflt: (function(_this) {
  244. return function() {
  245. return join(_this.get_home(), FN.config_dir, FN.nedb_file);
  246. };
  247. })(this)
  248. });
  249. };
  250. Env.prototype.get_tmp_keyring_dir = function() {
  251. return this.get_opt({
  252. env: function(e) {
  253. return e.KEYBASE_TMP_KEYRING_DIR;
  254. },
  255. arg: function(a) {
  256. return a.tmp_keyring_dir;
  257. },
  258. config: function(c) {
  259. var _ref1;
  260. return c != null ? (_ref1 = c.files) != null ? _ref1.tmp_keyring_dir : void 0 : void 0;
  261. },
  262. dflt: (function(_this) {
  263. return function() {
  264. return join(_this.get_cache_dir(), FN.tmp_keyring_dir);
  265. };
  266. })(this)
  267. });
  268. };
  269. Env.prototype.get_preserve_tmp_keyring = function() {
  270. return this.get_opt({
  271. env: function(e) {
  272. return e.KEYBASE_PRESERVE_TMP_KEYRING;
  273. },
  274. arg: function(a) {
  275. return a.preserve_tmp_keyring;
  276. },
  277. dflt: function() {
  278. return false;
  279. }
  280. });
  281. };
  282. Env.prototype.get_host = function() {
  283. return this.get_opt({
  284. env: function(e) {
  285. return e.KEYBASE_HOST;
  286. },
  287. arg: function(a) {
  288. return a.host;
  289. },
  290. config: function(c) {
  291. var _ref1;
  292. return (_ref1 = c.server) != null ? _ref1.host : void 0;
  293. },
  294. dflt: function() {
  295. return SRV.host;
  296. }
  297. });
  298. };
  299. Env.prototype.get_debug = function() {
  300. return this.get_opt({
  301. env: function(e) {
  302. return e.KEYBASE_DEBUG;
  303. },
  304. arg: function(a) {
  305. return a.debug;
  306. },
  307. config: function(c) {
  308. var _ref1;
  309. return (_ref1 = c.run) != null ? _ref1.d : void 0;
  310. },
  311. dflt: function() {
  312. return false;
  313. }
  314. });
  315. };
  316. Env.prototype.get_no_tls = function() {
  317. return this.get_opt({
  318. env: function(e) {
  319. return e.KEYBASE_NO_TLS;
  320. },
  321. arg: function(a) {
  322. return a.no_tls;
  323. },
  324. config: function(c) {
  325. var _ref1;
  326. return (_ref1 = c.server) != null ? _ref1.no_tls : void 0;
  327. },
  328. dflt: function() {
  329. return SRV.no_tls;
  330. }
  331. });
  332. };
  333. Env.prototype.get_api_uri_prefix = function() {
  334. return this.get_opt({
  335. env: function(e) {
  336. return e.KEYBASE_API_URI_PREFIX;
  337. },
  338. arg: function(a) {
  339. return a.api_uri_prefix;
  340. },
  341. config: function(c) {
  342. var _ref1;
  343. return (_ref1 = c.server) != null ? _ref1.api_uri_prefix : void 0;
  344. },
  345. dflt: function() {
  346. return SRV.api_uri_prefix;
  347. }
  348. });
  349. };
  350. Env.prototype.get_run_mode = function() {
  351. var raw;
  352. if (!this._run_mode) {
  353. raw = this.get_opt({
  354. env: function(e) {
  355. return e.KEYBASE_RUN_MODE;
  356. },
  357. arg: function(a) {
  358. return a.m;
  359. },
  360. config: function(c) {
  361. var _ref1;
  362. return (_ref1 = c.run) != null ? _ref1.mode : void 0;
  363. },
  364. dflt: null
  365. });
  366. this._run_mode = new RunMode(raw);
  367. }
  368. return this._run_mode;
  369. };
  370. Env.prototype.get_log_level = function() {
  371. return this.get_opt({
  372. env: function(e) {
  373. return e.KEYBASE_LOG_LEVEL;
  374. },
  375. arg: function(a) {
  376. return a.l;
  377. },
  378. config: function(c) {
  379. var _ref1;
  380. return (_ref1 = c.run) != null ? _ref1.log_level : void 0;
  381. },
  382. dflt: function() {
  383. return null;
  384. }
  385. });
  386. };
  387. Env.prototype.get_passphrase = function() {
  388. return this.get_opt({
  389. env: function(e) {
  390. return e.KEYBASE_PASSPHRASE;
  391. },
  392. arg: function(a) {
  393. return a.passphrase;
  394. },
  395. config: function(c) {
  396. var _ref1;
  397. return (_ref1 = c.user) != null ? _ref1.passphrase : void 0;
  398. },
  399. dflt: function() {
  400. return null;
  401. }
  402. });
  403. };
  404. Env.prototype.get_username = function() {
  405. return this.get_opt({
  406. env: function(e) {
  407. return e.KEYBASE_USERNAME;
  408. },
  409. arg: function(a) {
  410. return a.username;
  411. },
  412. config: function(c) {
  413. var _ref1;
  414. return (_ref1 = c.user) != null ? _ref1.name : void 0;
  415. },
  416. dflt: function() {
  417. return null;
  418. }
  419. });
  420. };
  421. Env.prototype.is_me = function(u2) {
  422. var u1;
  423. return (u2 != null) && ((u1 = this.get_username()) != null) && (u2.toLowerCase() === u1.toLowerCase());
  424. };
  425. Env.prototype.get_uid = function() {
  426. return this.get_opt({
  427. env: function(e) {
  428. return e.KEYBASE_UID;
  429. },
  430. arg: function(a) {
  431. return a.uid;
  432. },
  433. config: function(c) {
  434. var _ref1;
  435. return (_ref1 = c.user) != null ? _ref1.id : void 0;
  436. },
  437. dflt: function() {
  438. return null;
  439. }
  440. });
  441. };
  442. Env.prototype.get_email = function() {
  443. return this.get_opt({
  444. env: function(e) {
  445. return e.KEYBASE_EMAIL;
  446. },
  447. arg: function(a) {
  448. return a.email;
  449. },
  450. config: function(c) {
  451. var _ref1;
  452. return (_ref1 = c.user) != null ? _ref1.email : void 0;
  453. },
  454. dflt: function() {
  455. return null;
  456. }
  457. });
  458. };
  459. Env.prototype._get_home = function(_arg) {
  460. var null_ok;
  461. null_ok = _arg.null_ok;
  462. return this.get_opt({
  463. env: function(e) {
  464. return e.KEYBASE_HOME_DIR;
  465. },
  466. arg: function(a) {
  467. return a.homedir;
  468. },
  469. dflt: function() {
  470. return null;
  471. }
  472. });
  473. };
  474. Env.prototype.get_home = function(opts) {
  475. return this.kbpath.home(opts);
  476. };
  477. Env.prototype.get_home_gnupg_dir = function(null_ok) {
  478. var ret;
  479. if (null_ok == null) {
  480. null_ok = false;
  481. }
  482. ret = this.get_home({
  483. null_ok: true
  484. });
  485. if (ret != null) {
  486. ret = join(ret, ".gnupg");
  487. }
  488. return ret;
  489. };
  490. Env.prototype.get_gpg_cmd = function() {
  491. return this._gpg_cmd || this.get_opt({
  492. env: function(e) {
  493. return e.KEYBASE_GPG;
  494. },
  495. arg: function(a) {
  496. return a.gpg;
  497. },
  498. config: function(c) {
  499. return c.gpg;
  500. },
  501. dflt: function() {
  502. return null;
  503. }
  504. });
  505. };
  506. Env.prototype.set_gpg_cmd = function(c) {
  507. return this._gpg_cmd = c;
  508. };
  509. Env.prototype.get_proxy = function() {
  510. return this.get_opt({
  511. env: function(e) {
  512. return e.http_proxy || e.https_proxy;
  513. },
  514. arg: function(a) {
  515. return a.proxy;
  516. },
  517. config: function(c) {
  518. var _ref1;
  519. return (_ref1 = c.proxy) != null ? _ref1.url : void 0;
  520. },
  521. dflt: function() {
  522. return null;
  523. }
  524. });
  525. };
  526. Env.prototype.get_tor = function() {
  527. return this.get_opt({
  528. env: function(e) {
  529. return e.TOR_ENABLED;
  530. },
  531. arg: function(a) {
  532. return a.tor;
  533. },
  534. config: function(c) {
  535. var _ref1;
  536. return (_ref1 = c.tor) != null ? _ref1.enabled : void 0;
  537. },
  538. dflt: function() {
  539. return false;
  540. }
  541. });
  542. };
  543. Env.prototype.get_tor_strict = function() {
  544. return this.get_opt({
  545. env: function(e) {
  546. return e.TOR_STRICT;
  547. },
  548. arg: function(a) {
  549. return a.tor_strict;
  550. },
  551. config: function(c) {
  552. var _ref1;
  553. return (_ref1 = c.tor) != null ? _ref1.strict : void 0;
  554. },
  555. dflt: function() {
  556. return false;
  557. }
  558. });
  559. };
  560. Env.prototype.get_tor_leaky = function() {
  561. return this.get_opt({
  562. env: function(e) {
  563. return e.TOR_LEAKY;
  564. },
  565. arg: function(a) {
  566. return a.tor_leaky;
  567. },
  568. config: function(c) {
  569. var _ref1;
  570. return (_ref1 = c.tor) != null ? _ref1.leaky : void 0;
  571. },
  572. dflt: function() {
  573. return false;
  574. }
  575. });
  576. };
  577. Env.prototype.get_tor_proxy = function(null_ok) {
  578. return this.host_split(this.get_opt({
  579. env: function(e) {
  580. return e.TOR_PROXY;
  581. },
  582. arg: function(a) {
  583. return a.tor_proxy;
  584. },
  585. config: function(c) {
  586. var _ref1;
  587. return (_ref1 = c.tor) != null ? _ref1.proxy : void 0;
  588. },
  589. dflt: function() {
  590. if (null_ok) {
  591. return null;
  592. } else {
  593. return constants.tor.default_proxy;
  594. }
  595. }
  596. }));
  597. };
  598. Env.prototype.host_split = function(s) {
  599. var hostname, parts, port, ret;
  600. ret = s == null ? s : (parts = s.split(/:/), hostname = parts[0], port = parts.length > 1 ? parts[1] : null, {
  601. hostname: hostname,
  602. port: port
  603. });
  604. return ret;
  605. };
  606. Env.prototype.get_tor_hidden_address = function(null_ok) {
  607. return this.host_split(this.get_opt({
  608. env: function(e) {
  609. return e.TOR_HIDDEN_ADDRESS;
  610. },
  611. arg: function(a) {
  612. return a.tor_hidden_address;
  613. },
  614. config: function(c) {
  615. var _ref1;
  616. return (_ref1 = c.tor) != null ? _ref1.hidden_address : void 0;
  617. },
  618. dflt: function() {
  619. if (null_ok) {
  620. return null;
  621. } else {
  622. return constants.tor.hidden_address;
  623. }
  624. }
  625. }));
  626. };
  627. Env.prototype.get_proxy_ca_certs = function() {
  628. return this.get_opt({
  629. env: function(e) {
  630. return e.KEYBASE_PROXY_CA_CERTS;
  631. },
  632. arg: function(a) {
  633. return a.proxy_ca_certs;
  634. },
  635. config: function(c) {
  636. var _ref1;
  637. return (_ref1 = c.proxy) != null ? _ref1.ca_certs : void 0;
  638. },
  639. dflt: function() {
  640. return null;
  641. }
  642. });
  643. };
  644. Env.prototype.get_loopback_port_range = function() {
  645. var parse_range;
  646. parse_range = function(s) {
  647. var i, m, _i, _len, _ref1, _results;
  648. if (s == null) {
  649. return null;
  650. } else if (!(m = s.match(/^(\d+)-(\d+)$/))) {
  651. _ref1 = m.slice(1);
  652. _results = [];
  653. for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
  654. i = _ref1[_i];
  655. _results.push(parseInt(i, 10));
  656. }
  657. return _results;
  658. } else {
  659. return null;
  660. }
  661. };
  662. return this.get_opt({
  663. env: function(e) {
  664. return parse_range(e.KEYBASE_LOOPBACK_PORT_RANGE);
  665. },
  666. arg: function(a) {
  667. return parse_range(a.loopback_port_range);
  668. },
  669. config: function(c) {
  670. return c.loopback_port_range;
  671. },
  672. dflt: function() {
  673. return constants.loopback_port_range;
  674. }
  675. });
  676. };
  677. Env.prototype.get_no_gpg_options = function() {
  678. return this.get_opt({
  679. env: function(e) {
  680. return e.KEYBASE_NO_GPG_OPTIONS;
  681. },
  682. arg: function(a) {
  683. return a.no_gpg_options;
  684. },
  685. config: function(c) {
  686. return c.no_gpg_options;
  687. },
  688. dflt: function() {
  689. return false;
  690. }
  691. });
  692. };
  693. Env.prototype.get_merkle_checks = function() {
  694. var raw;
  695. if (!this._merkle_mode) {
  696. raw = this.get_opt({
  697. env: function(e) {
  698. return e.KEYBASE_MERKLE_CHECKS;
  699. },
  700. arg: function(a) {
  701. return a.merkle_checks;
  702. },
  703. config: function(c) {
  704. return c.merkle_checks;
  705. },
  706. dflt: function() {
  707. return false;
  708. }
  709. });
  710. this._merkle_mode = new Strictness(raw, (this.is_test() ? 'strict' : 'soft'));
  711. }
  712. return this._merkle_mode;
  713. };
  714. Env.prototype.get_merkle_key_fingerprints = function() {
  715. var split;
  716. split = function(x) {
  717. if (x != null) {
  718. return x.split(/:,/);
  719. } else {
  720. return null;
  721. }
  722. };
  723. return this.get_opt({
  724. env: function(e) {
  725. return split(e.KEYBASE_MERKLE_KEY_FINGERPRINTS);
  726. },
  727. arg: function(a) {
  728. return split(a.merkle_key_fingerprint);
  729. },
  730. config: function(c) {
  731. var _ref1;
  732. return c != null ? (_ref1 = c.keys) != null ? _ref1.merkle : void 0 : void 0;
  733. },
  734. dflt: (function(_this) {
  735. return function() {
  736. if (_this.is_test()) {
  737. return constants.testing_keys.merkle;
  738. } else {
  739. return constants.keys.merkle;
  740. }
  741. };
  742. })(this)
  743. });
  744. };
  745. Env.prototype.get_no_color = function() {
  746. return this.get_opt({
  747. env: function(e) {
  748. return e.KEYBASE_NO_COLOR;
  749. },
  750. arg: function(a) {
  751. return a.no_color;
  752. },
  753. config: function(c) {
  754. return c.no_color;
  755. },
  756. dflt: function() {
  757. return false;
  758. }
  759. });
  760. };
  761. Env.prototype.get_args = function() {
  762. return this.argv._;
  763. };
  764. Env.prototype.get_argv = function() {
  765. return this.argv;
  766. };
  767. Env.prototype.is_configured = function() {
  768. return this.get_username() != null;
  769. };
  770. Env.prototype.is_test = function() {
  771. var _ref1;
  772. return (this.get_run_mode().is_devel()) || ((_ref1 = this.get_host()) === 'localhost' || _ref1 === '127.0.0.1');
  773. };
  774. Env.prototype.keybase_email = function() {
  775. return make_email(this.get_username());
  776. };
  777. Env.prototype.keybase_full_username = function() {
  778. return make_full_username(this.get_username());
  779. };
  780. Env.prototype.init_home_scheme = function(cb) {};
  781. Env.prototype.make_pgp_uid = function() {
  782. return {
  783. username: this.keybase_full_username(),
  784. email: this.keybase_email()
  785. };
  786. };
  787. return Env;
  788. })();
  789. _env = null;
  790. exports.init_env = function(a) {
  791. return _env = new Env;
  792. };
  793. exports.env = function() {
  794. return _env;
  795. };
  796. }).call(this);