| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- // Generated by IcedCoffeeScript 1.7.1-c
- (function() {
- var PasswordManager, crypto, iced, log, read, __iced_k, __iced_k_noop;
- iced = require('iced-runtime').iced;
- __iced_k = __iced_k_noop = function() {};
- read = require('read');
- log = require('./log');
- crypto = require('crypto');
- exports.PasswordManager = PasswordManager = (function() {
- function PasswordManager() {}
- PasswordManager.prototype.init = function(opts) {
- this.opts = opts;
- return true;
- };
- PasswordManager.prototype.get_opts = function() {
- return this.opts;
- };
- PasswordManager.prototype._prompt_1 = function(prompt, cb) {
- var err, res, ___iced_passed_deferral, __iced_deferrals, __iced_k;
- __iced_k = __iced_k_noop;
- ___iced_passed_deferral = iced.findDeferral(arguments);
- (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/pw.iced",
- funcname: "PasswordManager._prompt_1"
- });
- read({
- prompt: "" + prompt + "> ",
- silent: true
- }, __iced_deferrals.defer({
- assign_fn: (function() {
- return function() {
- err = arguments[0];
- return res = arguments[1];
- };
- })(),
- lineno: 24
- }));
- __iced_deferrals._fulfill();
- });
- })(this)((function(_this) {
- return function() {
- if (err) {
- log.error("In prompt: " + err);
- res = null;
- } else if (res != null) {
- res = (res.split(/\s+/)).join('');
- if (res.length === 0) {
- res = null;
- }
- }
- return cb(res);
- };
- })(this));
- };
- PasswordManager.prototype.prompt_for_old_pw = function(cb) {
- var pw, ___iced_passed_deferral, __iced_deferrals, __iced_k;
- __iced_k = __iced_k_noop;
- ___iced_passed_deferral = iced.findDeferral(arguments);
- (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/pw.iced",
- funcname: "PasswordManager.prompt_for_old_pw"
- });
- _this._prompt_1('password', __iced_deferrals.defer({
- assign_fn: (function() {
- return function() {
- return pw = arguments[0];
- };
- })(),
- lineno: 36
- }));
- __iced_deferrals._fulfill();
- });
- })(this)((function(_this) {
- return function() {
- return cb(pw);
- };
- })(this));
- };
- PasswordManager.prototype.prompt_for_pw = function(is_new, cb) {
- if (is_new) {
- return this.prompt_for_new_pw(cb);
- } else {
- return this.prompt_for_old_pw(cb);
- }
- };
- PasswordManager.prototype.prompt_for_new_pw = function(cb) {
- var go, pw1, pw2, res, ___iced_passed_deferral, __iced_deferrals, __iced_k;
- __iced_k = __iced_k_noop;
- ___iced_passed_deferral = iced.findDeferral(arguments);
- go = true;
- res = null;
- (function(_this) {
- return (function(__iced_k) {
- var _results, _while;
- _results = [];
- _while = function(__iced_k) {
- var _break, _continue, _next;
- _break = function() {
- return __iced_k(_results);
- };
- _continue = function() {
- return iced.trampoline(function() {
- return _while(__iced_k);
- });
- };
- _next = function(__iced_next_arg) {
- _results.push(__iced_next_arg);
- return _continue();
- };
- if (!(go && !res)) {
- return _break();
- } else {
- (function(__iced_k) {
- __iced_deferrals = new iced.Deferrals(__iced_k, {
- parent: ___iced_passed_deferral,
- filename: "/Users/max/src/keybase/node-client/src/pw.iced",
- funcname: "PasswordManager.prompt_for_new_pw"
- });
- _this._prompt_1('passwrd', __iced_deferrals.defer({
- assign_fn: (function() {
- return function() {
- return pw1 = arguments[0];
- };
- })(),
- lineno: 50
- }));
- __iced_deferrals._fulfill();
- })(function() {
- (function(__iced_k) {
- if (typeof pw1 !== "undefined" && pw1 !== null) {
- (function(__iced_k) {
- __iced_deferrals = new iced.Deferrals(__iced_k, {
- parent: ___iced_passed_deferral,
- filename: "/Users/max/src/keybase/node-client/src/pw.iced",
- funcname: "PasswordManager.prompt_for_new_pw"
- });
- _this._prompt_1('confirm', __iced_deferrals.defer({
- assign_fn: (function() {
- return function() {
- return pw2 = arguments[0];
- };
- })(),
- lineno: 52
- }));
- __iced_deferrals._fulfill();
- })(function() {
- return __iced_k(pw1 === pw2 ? res = pw1 : log.warn("Password didn't match"));
- });
- } else {
- return __iced_k(go = false);
- }
- })(_next);
- });
- }
- };
- _while(__iced_k);
- });
- })(this)((function(_this) {
- return function() {
- return cb(res);
- };
- })(this));
- };
- PasswordManager.prototype.get_password = function(is_new, cb) {
- var pw, ___iced_passed_deferral, __iced_deferrals, __iced_k;
- __iced_k = __iced_k_noop;
- ___iced_passed_deferral = iced.findDeferral(arguments);
- (function(_this) {
- return (function(__iced_k) {
- if (_this._pw == null) {
- (function(__iced_k) {
- if (((pw = _this.opts.password) == null) && _this.opts.interactive && !_this.opts.bg) {
- (function(__iced_k) {
- __iced_deferrals = new iced.Deferrals(__iced_k, {
- parent: ___iced_passed_deferral,
- filename: "/Users/max/src/keybase/node-client/src/pw.iced",
- funcname: "PasswordManager.get_password"
- });
- _this.prompt_for_pw(is_new, __iced_deferrals.defer({
- assign_fn: (function() {
- return function() {
- return pw = arguments[0];
- };
- })(),
- lineno: 64
- }));
- __iced_deferrals._fulfill();
- })(__iced_k);
- } else {
- return __iced_k();
- }
- })(function() {
- return __iced_k(_this._pw = pw);
- });
- } else {
- return __iced_k();
- }
- });
- })(this)((function(_this) {
- return function() {
- return cb(_this._pw);
- };
- })(this));
- };
- return PasswordManager;
- })();
- }).call(this);
|