Beispiel #1
0
 deepDiff(one: Object, two: Object, path: string = ''): IDeepDiff[] {
     let result: IDeepDiff[] = [];
     for (var key of _.keys(one)) {
         let concatPath: string = path ? path + '.' + key : key;
         if (_.isPlainObject(one[key])) {
             if (!_.has(two, key)) {
                 result.push(new DeepDiff('deleted', concatPath, one[key], null));
             } else {
                 result = _.concat(result, this.deepDiff(one[key], two[key], path ? path + '.' + key : key));
             }
         } else if (_.isBoolean(one[key]) || _.isDate(one[key]) || _.isNumber(one[key])
             || _.isNull(one[key]) || _.isRegExp(one[key]) || _.isString(one[key])) {
             if (!_.has(two, key)) {
                 result.push(new DeepDiff('deleted', concatPath, one[key], null));
             } else if (_.get(one, key) !== _.get(two, key)) {
                 result.push(new DeepDiff('edited', concatPath, one[key], two[key]));
             }
         } else if (_.isArray(one[key]) && _.isArray(two[key]) && !_.isEqual(one[key], two[key])) {
             result.push(new DeepDiff('array', concatPath, one[key], two[key]));
         } else if (!_.has(two, key)) {
             result.push(new DeepDiff('deleted', concatPath, one[key], null));
         }
     }
     for (var key of _.keys(two)) {
         let concatPath: string = path ? path + '.' + key : key;
         if (!_.has(one, key)) {
             if (_.isPlainObject(two[key]) || _.isBoolean(two[key]) || _.isDate(two[key]) || _.isNumber(two[key])
                 || _.isNull(two[key]) || _.isRegExp(two[key]) || _.isString(two[key]) || _.isArray(two[key])) {
                 result.push(new DeepDiff('created', concatPath, null, two[key]));
             }
         }
     }
     return result;
 }
Beispiel #2
0
 return _.filter(configurations, (config) => {
     const validActiveLow = _.has(config, 'activeLow') ? _.isBoolean(config.activeLow) : true;
     const validDescription = _.has(config, 'description') ? _.isString(config.description) : true;
     const validApiPathAlias = _.has(config, 'apiPathAlias') ? _.isString(config.apiPathAlias) : true;
     const validGpioConfig = (_.isNumber(config.bcmPinNumber) && _.isBoolean(config.state));
     return validActiveLow && validDescription && validApiPathAlias && validGpioConfig;
 });
Beispiel #3
0
const _convert_simple_acl_search = ({ user_to_subv, ...other } : simple_acl_search): acl_search => ({
    ...other,
    async user_to_ldap_filter(user) {
        const or_subv = _normalize__or_subv(await user_to_subv(user));
        return _.isBoolean(or_subv) ? or_subv : filters.or(or_subv.map(l => filters.and(search_ldap.subv_to_eq_filters(l))));
    },
    async user_to_mongo_filter(user) {
        const or_subv = _normalize__or_subv(await user_to_subv(user));
        return _.isBoolean(or_subv) ? or_subv : db.or(or_subv.map(subv => _.mapKeys(subv, (_,k) => "v." + k)));
    },
})
Beispiel #4
0
Wallets.prototype.list = function(params, callback) {
  params = params || {};
  common.validateParams(params, [], [], callback);

  const queryObject: any = {};

  if (params.skip && params.prevId) {
    throw new Error('cannot specify both skip and prevId');
  }

  if (params.getbalances) {
    if (!_.isBoolean(params.getbalances)) {
      throw new Error('invalid getbalances argument, expecting boolean');
    }
    queryObject.getbalances = params.getbalances;
  }
  if (params.prevId) {
    if (!_.isString(params.prevId)) {
      throw new Error('invalid prevId argument, expecting string');
    }
    queryObject.prevId = params.prevId;
  }
  if (params.limit) {
    if (!_.isNumber(params.limit)) {
      throw new Error('invalid limit argument, expecting number');
    }
    queryObject.limit = params.limit;
  }

  if (params.allTokens) {
    if (!_.isBoolean(params.allTokens)) {
      throw new Error('invalid allTokens argument, expecting boolean');
    }
    queryObject.allTokens = params.allTokens;
  }

  const self = this;
  return this.bitgo.get(this.baseCoin.url('/wallet'))
  .query(queryObject)
  .result()
  .then(function(body) {
    body.wallets = body.wallets.map(function(w) {
      return new self.coinWallet(self.bitgo, self.baseCoin, w);
    });
    return body;
  })
  .nodeify(callback);
};
Beispiel #5
0
        return _.some(values, v => {
          if (!_.isBoolean(v)) {
            bp.logger.warn('Filter returned something other ' + 'than a boolean (or a Promise of a boolean)')
          }

          return typeof v !== 'undefined' && v !== null && v !== true
        })
Beispiel #6
0
      panelUpgrades.push(function(panel) {
        // rename panel type
        if (panel.type === 'graphite') {
          panel.type = 'graph';
        }

        if (panel.type !== 'graph') {
          return;
        }

        if (_.isBoolean(panel.legend)) { panel.legend = { show: panel.legend }; }

        if (panel.grid) {
          if (panel.grid.min) {
            panel.grid.leftMin = panel.grid.min;
            delete panel.grid.min;
          }

          if (panel.grid.max) {
            panel.grid.leftMax = panel.grid.max;
            delete panel.grid.max;
          }
        }

        if (panel.y_format) {
          panel.y_formats[0] = panel.y_format;
          delete panel.y_format;
        }

        if (panel.y2_format) {
          panel.y_formats[1] = panel.y2_format;
          delete panel.y2_format;
        }
      });
Beispiel #7
0
Keychains.prototype.add = function(params, callback) {
  params = params || {};
  common.validateParams(params, [], ['pub', 'encryptedPrv', 'type', 'source', 'originalPasscodeEncryptionCode', 'enterprise', 'derivedFromParentWithSeed'], callback);

  if (!_.isUndefined(params.disableKRSEmail)) {
    if (!_.isBoolean(params.disableKRSEmail)) {
      throw new Error('invalid disableKRSEmail argument, expecting boolean');
    }
  }

  if (params.reqId) {
    this.bitgo._reqId = params.reqId;
  }
  return this.bitgo.post(this.baseCoin.url('/key'))
  .send({
    pub: params.pub,
    encryptedPrv: params.encryptedPrv,
    type: params.type,
    source: params.source,
    provider: params.provider,
    originalPasscodeEncryptionCode: params.originalPasscodeEncryptionCode,
    enterprise: params.enterprise,
    derivedFromParentWithSeed: params.derivedFromParentWithSeed,
    disableKRSEmail: params.disableKRSEmail,
    krsSpecific: params.krsSpecific
  })
  .result()
  .nodeify(callback);
};
Beispiel #8
0
 public async setValue(opts: CommandOptions) {
   // get value so we have a type
   const splitted = opts.parameters.split(' ');
   const pointer = splitted.shift();
   let newValue = splitted.join(' ');
   if (!pointer) {
     return sendMessage(`$sender, settings does not exists`, opts.sender);
   }
   const currentValue = await get(global, pointer, undefined);
   if (typeof currentValue !== 'undefined') {
     if (isBoolean(currentValue)) {
       newValue = newValue.toLowerCase().trim();
       if (['true', 'false'].includes(newValue)) {
         set(global, pointer, newValue === 'true');
         sendMessage(`$sender, ${pointer} set to ${newValue}`, opts.sender);
       } else {
         sendMessage('$sender, !set error: bool is expected', opts.sender);
       }
     } else if (isNumber(currentValue)) {
       if (isFinite(Number(newValue))) {
         set(global, pointer, Number(newValue));
         sendMessage(`$sender, ${pointer} set to ${newValue}`, opts.sender);
       } else {
         sendMessage('$sender, !set error: number is expected', opts.sender);
       }
     } else if (isString(currentValue)) {
       set(global, pointer, newValue);
       sendMessage(`$sender, ${pointer} set to '${newValue}'`, opts.sender);
     } else {
       sendMessage(`$sender, ${pointer} is not supported settings to change`, opts.sender);
     }
   } else {
     sendMessage(`$sender, ${pointer} settings not exists`, opts.sender);
   }
 }
Beispiel #9
0
PendingApproval.prototype.constructApprovalTx = function(params, callback) {
  params = params || {};
  common.validateParams(params, [], ['walletPassphrase'], callback);

  if (this.type() === 'transactionRequest' && !(params.walletPassphrase || params.xprv)) {
    throw new Error('wallet passphrase or xprv required to approve a transactionRequest');
  }

  if (params.useOriginalFee) {
    if (!_.isBoolean(params.useOriginalFee)) {
      throw new Error('invalid type for useOriginalFeeRate');
    }
    if (params.fee || params.feeRate || params.feeTxConfirmTarget) {
      throw new Error('cannot specify a fee/feerate/feeTxConfirmTarget as well as useOriginalFee');
    }
  }

  const self = this;
  return Promise.try(function() {
    if (self.type() === 'transactionRequest') {
      const extendParams: any = { txHex: self.info().transactionRequest.transaction };
      if (params.useOriginalFee) {
        extendParams.fee = self.info().transactionRequest.fee;
      }
      return self.populateWallet()
      .then(function() {
        return self.recreateAndSignTransaction(_.extend(params, extendParams));
      });
    }
  });
};
Beispiel #10
0
Wallets.prototype.getWallet = function(params, callback) {
  params = params || {};
  common.validateParams(params, ['id'], [], callback);

  const self = this;

  const query: any = {};

  if (params.allTokens) {
    if (!_.isBoolean(params.allTokens)) {
      throw new Error('invalid allTokens argument, expecting boolean');
    }
    query.allTokens = params.allTokens;
  }

  this.bitgo._reqId = params.reqId || util.createRequestId();

  return this.bitgo.get(this.baseCoin.url('/wallet/' + params.id))
  .query(query)
  .result()
  .then(function(wallet) {
    return new self.coinWallet(self.bitgo, self.baseCoin, wallet);
  })
  .nodeify(callback);
};