// Generated by IcedCoffeeScript 1.7.1-c (function() { var ACCTYPES, AnnouncementSigGen, ArgumentParser, Base, C, Command, E, PackageJson, S, ST, User, a_json_parse, add_option_dict, assert, bitcoyne, dict_union, drain, fs, iced, iutils, log, make_esc, prompt_remote_name, prompt_yn, proofs, req, session, stream_open, util, __iced_k, __iced_k_noop, _ref, __hasProp = {}.hasOwnProperty, __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; }; iced = require('iced-runtime').iced; __iced_k = __iced_k_noop = function() {}; Base = require('./base').Base; log = require('../log'); ArgumentParser = require('argparse').ArgumentParser; add_option_dict = require('./argparse').add_option_dict; C = require('../constants').constants; ST = C.signature_types; ACCTYPES = C.allowed_cryptocurrency_types; PackageJson = require('../package').PackageJson; E = require('../err').E; make_esc = require('iced-error').make_esc; _ref = require('../prompter'), prompt_yn = _ref.prompt_yn, prompt_remote_name = _ref.prompt_remote_name; User = require('../user').User; req = require('../req').req; assert = require('assert'); session = require('../session'); S = require('../services'); dict_union = require('../util').dict_union; iutils = require('iced-utils'); drain = iutils.drain.drain; a_json_parse = iutils.util.a_json_parse; util = require('util'); fs = require('fs'); proofs = require('keybase-proofs'); bitcoyne = require('bitcoyne'); AnnouncementSigGen = require('../sigs').AnnouncementSigGen; stream_open = function(f, cb) { var ret; ret = fs.createReadStream(f); ret.on('error', function(err) { err = new E.NotFoundError("Could not open file '" + f + "': " + err.code); return cb(err, null); }); return ret.on('open', function() { return cb(null, ret); }); }; exports.Command = Command = (function(_super) { __extends(Command, _super); function Command() { return Command.__super__.constructor.apply(this, arguments); } Command.prototype.OPTS = { j: { alias: 'json', action: 'storeTrue', help: 'interpret the announcement as JSON object' }, e: { alias: 'encode', action: 'storeTrue', help: 'encode the announcement with base64-encoding' }, f: { alias: 'file', help: 'Specify a file as the announcment' }, m: { alias: 'message', help: 'Specify a message as the announcement"' } }; Command.prototype.use_session = function() { return true; }; Command.prototype.needs_configuration = function() { return true; }; Command.prototype.add_subcommand_parser = function(scp) { var name, opts, sub; opts = { aliases: [], help: "make an announcement, stored to your signature chain" }; name = "announce"; sub = scp.addParser(name, opts); add_option_dict(sub, this.OPTS); return opts.aliases.concat([name]); }; Command.prototype.parse_args = function(cb) { var err; err = null; if (this.argv.encode && this.argv.json) { err = new E.ArgsError("can't specify both -j/--json and -e/--encode"); } else if (this.argv.file && this.argv.message) { err = new E.ArgsError("can't specify both -f/--file and -m/--message"); } return cb(err); }; Command.prototype.allocate_proof_gen = function(cb) { var arg, err, klass, ___iced_passed_deferral, __iced_deferrals, __iced_k; __iced_k = __iced_k_noop; ___iced_passed_deferral = iced.findDeferral(arguments); klass = AnnouncementSigGen; arg = { announcement: this.announcement }; (function(_this) { return (function(__iced_k) { __iced_deferrals = new iced.Deferrals(__iced_k, { parent: ___iced_passed_deferral, filename: "/Users/max/src/keybase/node-client/src/command/announce.iced", funcname: "Command.allocate_proof_gen" }); _this.me.gen_sig_base({ klass: klass, arg: arg }, __iced_deferrals.defer({ assign_fn: (function(__slot_1) { return function() { err = arguments[0]; return __slot_1.gen = arguments[1]; }; })(_this), lineno: 88 })); __iced_deferrals._fulfill(); }); })(this)((function(_this) { return function() { return cb(err); }; })(this)); }; Command.prototype.load_announcement = function(cb) { var esc, f, m, stream, ___iced_passed_deferral, __iced_deferrals, __iced_k; __iced_k = __iced_k_noop; ___iced_passed_deferral = iced.findDeferral(arguments); stream = null; esc = make_esc(cb, "Command::load_announcement"); (function(_this) { return (function(__iced_k) { if ((m = _this.argv.message) != null) { return __iced_k(_this.raw = new Buffer(m, 'utf8')); } else { (function(__iced_k) { if ((f = _this.argv.file) != null) { (function(__iced_k) { __iced_deferrals = new iced.Deferrals(__iced_k, { parent: ___iced_passed_deferral, filename: "/Users/max/src/keybase/node-client/src/command/announce.iced", funcname: "Command.load_announcement" }); stream_open(f, esc(__iced_deferrals.defer({ assign_fn: (function() { return function() { return stream = arguments[0]; }; })(), lineno: 98 }))); __iced_deferrals._fulfill(); })(__iced_k); } else { return __iced_k(stream = process.stdin); } })(__iced_k); } }); })(this)((function(_this) { return function() { (function(__iced_k) { if (stream != null) { (function(__iced_k) { __iced_deferrals = new iced.Deferrals(__iced_k, { parent: ___iced_passed_deferral, filename: "/Users/max/src/keybase/node-client/src/command/announce.iced", funcname: "Command.load_announcement" }); drain(stream, esc(__iced_deferrals.defer({ assign_fn: (function(__slot_1) { return function() { return __slot_1.raw = arguments[0]; }; })(_this), lineno: 102 }))); __iced_deferrals._fulfill(); })(__iced_k); } else { return __iced_k(); } })(function() { return cb(null); }); }; })(this)); }; Command.prototype.encode_ennouncement = function(cb) { var data, encoding, esc, ___iced_passed_deferral, __iced_deferrals, __iced_k; __iced_k = __iced_k_noop; ___iced_passed_deferral = iced.findDeferral(arguments); esc = make_esc(cb, "Command::encode_announcement"); (function(_this) { return (function(__iced_k) { if (_this.argv.json) { (function(__iced_k) { __iced_deferrals = new iced.Deferrals(__iced_k, { parent: ___iced_passed_deferral, filename: "/Users/max/src/keybase/node-client/src/command/announce.iced", funcname: "Command.encode_ennouncement" }); a_json_parse(_this.raw.toString('utf8'), esc(__iced_deferrals.defer({ assign_fn: (function() { return function() { return data = arguments[0]; }; })(), lineno: 110 }))); __iced_deferrals._fulfill(); })(function() { return __iced_k(encoding = "json"); }); } else { return __iced_k(_this.argv.encode ? (data = _this.raw.toString('base64'), encoding = "base64") : (encoding = "utf8", data = _this.raw.toString('utf8'))); } }); })(this)((function(_this) { return function() { _this.announcement = { data: data, encoding: encoding }; return cb(null); }; })(this)); }; Command.prototype.run = function(cb) { var esc, ___iced_passed_deferral, __iced_deferrals, __iced_k; __iced_k = __iced_k_noop; ___iced_passed_deferral = iced.findDeferral(arguments); esc = make_esc(cb, "Command::run"); (function(_this) { return (function(__iced_k) { __iced_deferrals = new iced.Deferrals(__iced_k, { parent: ___iced_passed_deferral, filename: "/Users/max/src/keybase/node-client/src/command/announce.iced", funcname: "Command.run" }); _this.parse_args(esc(__iced_deferrals.defer({ lineno: 125 }))); __iced_deferrals._fulfill(); }); })(this)((function(_this) { return function() { (function(__iced_k) { __iced_deferrals = new iced.Deferrals(__iced_k, { parent: ___iced_passed_deferral, filename: "/Users/max/src/keybase/node-client/src/command/announce.iced", funcname: "Command.run" }); session.login(esc(__iced_deferrals.defer({ lineno: 126 }))); __iced_deferrals._fulfill(); })(function() { (function(__iced_k) { __iced_deferrals = new iced.Deferrals(__iced_k, { parent: ___iced_passed_deferral, filename: "/Users/max/src/keybase/node-client/src/command/announce.iced", funcname: "Command.run" }); User.load_me({ secret: true }, esc(__iced_deferrals.defer({ assign_fn: (function(__slot_1) { return function() { return __slot_1.me = arguments[0]; }; })(_this), lineno: 127 }))); __iced_deferrals._fulfill(); })(function() { (function(__iced_k) { __iced_deferrals = new iced.Deferrals(__iced_k, { parent: ___iced_passed_deferral, filename: "/Users/max/src/keybase/node-client/src/command/announce.iced", funcname: "Command.run" }); _this.load_announcement(esc(__iced_deferrals.defer({ lineno: 128 }))); __iced_deferrals._fulfill(); })(function() { (function(__iced_k) { __iced_deferrals = new iced.Deferrals(__iced_k, { parent: ___iced_passed_deferral, filename: "/Users/max/src/keybase/node-client/src/command/announce.iced", funcname: "Command.run" }); _this.encode_ennouncement(esc(__iced_deferrals.defer({ lineno: 129 }))); __iced_deferrals._fulfill(); })(function() { (function(__iced_k) { __iced_deferrals = new iced.Deferrals(__iced_k, { parent: ___iced_passed_deferral, filename: "/Users/max/src/keybase/node-client/src/command/announce.iced", funcname: "Command.run" }); _this.allocate_proof_gen(esc(__iced_deferrals.defer({ lineno: 130 }))); __iced_deferrals._fulfill(); })(function() { (function(__iced_k) { __iced_deferrals = new iced.Deferrals(__iced_k, { parent: ___iced_passed_deferral, filename: "/Users/max/src/keybase/node-client/src/command/announce.iced", funcname: "Command.run" }); _this.gen.run(esc(__iced_deferrals.defer({ lineno: 131 }))); __iced_deferrals._fulfill(); })(function() { log.info("Success!"); return cb(null); }); }); }); }); }); }); }; })(this)); }; return Command; })(Base); }).call(this);