| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- // Generated by IcedCoffeeScript 1.7.1-c
- (function() {
- var E, ProxyCACert, ProxyCACerts, env, fs, iced, log, make_esc, __iced_k, __iced_k_noop, _pcc;
- iced = require('iced-runtime').iced;
- __iced_k = __iced_k_noop = function() {};
- env = require('./env').env;
- fs = require('fs');
- make_esc = require('iced-error').make_esc;
- E = require('./err').E;
- log = require('./log');
- ProxyCACert = (function() {
- function ProxyCACert(file) {
- this.file = file;
- }
- ProxyCACert.prototype.open = function(cb) {
- var err, ___iced_passed_deferral, __iced_deferrals, __iced_k;
- __iced_k = __iced_k_noop;
- ___iced_passed_deferral = iced.findDeferral(arguments);
- log.debug("| Load proxy CA: " + this.file);
- (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/proxyca.iced",
- funcname: "ProxyCACert.open"
- });
- fs.readFile(_this.file, __iced_deferrals.defer({
- assign_fn: (function(__slot_1) {
- return function() {
- err = arguments[0];
- return __slot_1.raw = arguments[1];
- };
- })(_this),
- lineno: 14
- }));
- __iced_deferrals._fulfill();
- });
- })(this)((function(_this) {
- return function() {
- return cb(err);
- };
- })(this));
- };
- ProxyCACert.prototype.to_string = function() {
- var _ref;
- return (_ref = this.raw) != null ? _ref.toString('utf8') : void 0;
- };
- return ProxyCACert;
- })();
- exports.ProxyCACerts = ProxyCACerts = (function() {
- function ProxyCACerts() {
- this._cas = [];
- this._arr = [];
- this._files = [];
- }
- ProxyCACerts.prototype.read_env = function(cb) {
- var e, err, o, v, _ref;
- o = env().get_proxy_ca_certs();
- v = null;
- err = null;
- if (o == null) {
- } else if (typeof o === 'string') {
- v = [o];
- } else if (typeof o === 'object' && Array.isArray(o)) {
- v = o;
- } else {
- err = new E.ArgsError("given CA list can't be parsed as list of files");
- }
- if (v != null) {
- this._files = (_ref = []).concat.apply(_ref, (function() {
- var _i, _len, _results;
- _results = [];
- for (_i = 0, _len = v.length; _i < _len; _i++) {
- e = v[_i];
- _results.push(e.split(/:/));
- }
- return _results;
- })());
- }
- return cb(err);
- };
- ProxyCACerts.prototype.open_files = function(cb) {
- var ca, esc, f, ___iced_passed_deferral, __iced_deferrals, __iced_k;
- __iced_k = __iced_k_noop;
- ___iced_passed_deferral = iced.findDeferral(arguments);
- esc = make_esc(cb, "CAs::open_files");
- this._cas = (function() {
- var _i, _len, _ref, _results;
- _ref = this._files;
- _results = [];
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- f = _ref[_i];
- _results.push(new ProxyCACert(f));
- }
- return _results;
- }).call(this);
- (function(_this) {
- return (function(__iced_k) {
- var _i, _len, _ref, _results, _while;
- _ref = _this._cas;
- _len = _ref.length;
- _i = 0;
- _results = [];
- _while = function(__iced_k) {
- var _break, _continue, _next;
- _break = function() {
- return __iced_k(_results);
- };
- _continue = function() {
- return iced.trampoline(function() {
- ++_i;
- return _while(__iced_k);
- });
- };
- _next = function(__iced_next_arg) {
- _results.push(__iced_next_arg);
- return _continue();
- };
- if (!(_i < _len)) {
- return _break();
- } else {
- ca = _ref[_i];
- (function(__iced_k) {
- __iced_deferrals = new iced.Deferrals(__iced_k, {
- parent: ___iced_passed_deferral,
- filename: "/Users/max/src/keybase/node-client/src/proxyca.iced",
- funcname: "ProxyCACerts.open_files"
- });
- ca.open(esc(__iced_deferrals.defer({
- lineno: 51
- })));
- __iced_deferrals._fulfill();
- })(_next);
- }
- };
- _while(__iced_k);
- });
- })(this)((function(_this) {
- return function() {
- return cb(null);
- };
- })(this));
- };
- ProxyCACerts.prototype.load = function(cb) {
- var c, esc, ___iced_passed_deferral, __iced_deferrals, __iced_k;
- __iced_k = __iced_k_noop;
- ___iced_passed_deferral = iced.findDeferral(arguments);
- log.debug("+ Load proxy CAs");
- esc = make_esc(cb, "CAs::init");
- (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/proxyca.iced",
- funcname: "ProxyCACerts.load"
- });
- _this.read_env(esc(__iced_deferrals.defer({
- lineno: 59
- })));
- __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/proxyca.iced",
- funcname: "ProxyCACerts.load"
- });
- _this.open_files(esc(__iced_deferrals.defer({
- lineno: 60
- })));
- __iced_deferrals._fulfill();
- })(function() {
- _this._ca_arr = (function() {
- var _i, _len, _ref, _results;
- _ref = this._cas;
- _results = [];
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- c = _ref[_i];
- _results.push(c.to_string());
- }
- return _results;
- }).call(_this);
- log.debug("- Loaded proxy CAs");
- return cb(null, _this._cas.length > 0);
- });
- };
- })(this));
- };
- ProxyCACerts.prototype.data = function() {
- return this._ca_arr;
- };
- ProxyCACerts.prototype.files = function() {
- return this._files;
- };
- return ProxyCACerts;
- })();
- _pcc = null;
- exports.init = function(cb) {
- var err, found, pcc, ___iced_passed_deferral, __iced_deferrals, __iced_k;
- __iced_k = __iced_k_noop;
- ___iced_passed_deferral = iced.findDeferral(arguments);
- pcc = new ProxyCACerts();
- (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/proxyca.iced",
- funcname: "init"
- });
- pcc.load(__iced_deferrals.defer({
- assign_fn: (function() {
- return function() {
- err = arguments[0];
- return found = arguments[1];
- };
- })(),
- lineno: 75
- }));
- __iced_deferrals._fulfill();
- });
- })(this)((function(_this) {
- return function() {
- if (found && (typeof err === "undefined" || err === null)) {
- _pcc = pcc;
- }
- return cb(err, _pcc);
- };
- })(this));
- };
- exports.get = function() {
- return _pcc;
- };
- }).call(this);
|