Returns unique token for method and params
344006
public static function getCsrfToken(Session $session, string $controlClassName, string $method, array $params): string
	{
		$sessionSection = $session->getSection('Nextras.Application.UI.SecuredLinksPresenterTrait');
		if (!isset($sessionSection->token)) {
			$sessionSection->token = function_exists('random_bytes')
				? random_bytes(16)
				: Nette\Utils\Random::generate(16, "\x00-\xFF");
		}

		$params = Nette\Utils\Arrays::flatten($params);
		$params = implode('|', array_keys($params)) . '|' . implode('|', array_values($params));

		$data = $controlClassName . $method . $params . $session->getId();
		$hash = hash_hmac('sha1', $data, $sessionSection->token, TRUE);
		$token = strtr(substr(base64_encode($hash), 0, 8), '+/', '-_');

		return $token;
	}
1186906
def build_request(method, query_params={})
      query   = { token: token }.merge(query_params)
      request = { query: query, method: method, headers: {}, mock: @test_mode }

      if Diffbot.instrumentor
        request.update(
          instrumentor: Diffbot.instrumentor,
          instrumentor_name: "diffbot"
        )
      end

      request
    end
950213
function(authMethods){
      var _method = {};
      var _methodName;

      try{
        _.each(authMethods, function(method){
          _methodName = method.name;
          method = _.merge(require('../../'+_methodName), method);
          _method[method.authType] = method;
        });
      }catch(e){
        this._errorHandler(_methodName);
      }

      return _method;
    }
1083459
def push_token
      return params[:pushToken] if params.include?(:pushToken)
      if request && request.body
        request.body.rewind
        json_body = JSON.parse(request.body.read)
        if json_body['pushToken']
          json_body['pushToken']
        end
      end
    end
1230572
function includeCSRFToken ({ method, csrf=true, headers }) {
  if (!csrf || !CSRF_METHODS.includes(method)) return
  const token = getTokenFromDocument(csrf)
  if (!token) return
  return {
    headers: { ...headers, 'X-CSRF-Token': token }
  }
}
84249
function process_token(token, index, tokens) {
	var last = (index === (tokens.length - 1));
	if (token[0] === "+") return process_single(token, last);
	else if (token[0] === "#") return process_multi(token, last);
	else return process_raw(token, last);
}
11420
public function getCsrfToken(string $control, string $method, array $params): string
	{
		return Helpers::getCsrfToken($this->getSession(), $control, $method, $params);
	}
1083073
function getMethodUse(tokens, API) {
  var used = [];

  // Those variable names can't be jQuery things.
  var excludeListIdentifiers = ['behaviors', 'this', 'self', 'tab_focus'];

  var JQVars = ['jQuery', '$'];
  var JQMethods = _.pluck(_.where(API, {object: 'jQuery'}), 'method');
  var JQFNMethods = _.pluck(_.where(API, {object: 'jQuery.fn'}), 'method');
  var sizzleSelectors = _.pluck(_.where(API, {object: 'jQuery.expr.filters'}), 'method');

  var isJQ = false;
  var isVar = false;
  var isVarExcluded = false;
  var justAddedVar = false;

  tokens.forEach(function (token) {
    var isJQVar = JQVars.indexOf(token.value) !== -1;
    var isJQMethod = JQMethods.indexOf(token.value) !== -1;
    var isJQFNMethod = JQFNMethods.indexOf(token.value) !== -1;
    // Some things use jQuery method names while not being jQuery.
    var isExcluded = excludeListIdentifiers.indexOf(token.value) !== -1;

    var semicol = token.type === 'Punctuator' && token.value === ';';
    var closeCurly = token.type === 'Punctuator' && token.value === '}';
    var jsword = token.type === 'Keyword';
    var stop = semicol || closeCurly || jsword;

    // Make sure we're not mistaking jQuery stuff with other variable names.
    if (justAddedVar) {
      if (token.type === 'Punctuator' && token.value !== '(') {
        var poped = used.pop();
        debug(poped);
      }
      justAddedVar = false;
    }

    if (isExcluded && !isVarExcluded) {
      isVarExcluded = true;
    }

    if (!isVarExcluded) {
      // Catch $('.element').xxx()
      if (token.type === 'Identifier') {
        if (isJQFNMethod) {
          used.push({method: token.value, object: 'jQuery.fn'});
          justAddedVar = true;
        }
      }
      else if (token.type === 'Identifier' && !isJQVar) {
        isVar = true;
      }
      else if (stop) {
        isVar = false;
      }

      // Catch jQuery.xxx().
      if (token.type === 'Identifier' && isJQVar) {
        isJQ = true;
      }
      else if (isJQ && token.type === 'Identifier' && isJQMethod) {
        used.push({method: token.value, object: 'jQuery'});
      }
      else if (isJQ && stop) {
        isJQ = false;
      }
    }

    if (stop) {
      isVarExcluded = false;
    }

    // Catch sizzle selectors in strings.
    if (token.type === 'String' && token.value.indexOf(':') !== -1) {
      sizzleSelectors.forEach(function (selector) {
        if (token.value.indexOf(selector) !== -1) {
          used.push({method: selector, object: 'jQuery.expr.filters'});
        }
      });
    }

    // Ajax is special. We don't track transport types so it's best guess.
    if (token.type === 'String') {
      var ajaxDep = false;
      switch (token.value.replace(/'/g, '').replace(/"/g, '')) {
        case 'jsonp':
          ajaxDep = {method: 'jsonp', object: 'jQuery.ajax', module: 'ajax/jsonp'};
          break;

        case 'json':
          ajaxDep = {method: 'json', object: 'jQuery.ajax', module: 'ajax/parseJSON'};
          break;

        case 'xml':
          ajaxDep = {method: 'xml', object: 'jQuery.ajax', module: 'ajax/parseXML'};
          break;

        case 'script':
          ajaxDep = {method: 'script', object: 'jQuery.ajax', module: 'ajax/script'};
          break;
      }

      if (ajaxDep) {
        used.push(ajaxDep);
        used.push({method: 'xhr', object: 'jQuery.ajax', module: 'ajax/xhr'});
      }
    }
  });

  debug(used);

  return used;
}
763039
def method_missing(method, *args, &block)
      super
    rescue NoMethodError
      return regs(method) if self.has_reg?(method)
      return ports(method) if self.has_port?(method)
      if method.to_s =~ /=$/
        define_singleton_method(method) do |val|
          instance_variable_set("@#{method.to_s.sub('=', '')}", val)
        end
      else
        define_singleton_method(method) do
          instance_variable_get("@#{method}")
        end
      end
      send(method, *args, &block)
    end
468531
function(methodDef, callback, params, payload) {
        // check required params
        for (var index in methodDef.required_params) {
            var requiredParamName = methodDef.required_params[index];
            if (!params.hasOwnProperty(requiredParamName)) {
                callback(requiredParamName +' param is required');
                return false;
            }
        }
        // check unattended params
        if (methodDef.unattended_params === false) {
            for (var param in params) {
                if (methodDef.optional_params.indexOf(param) == -1
                    && methodDef.required_params.indexOf(param) == -1) {
                    callback('unattended param '+ param);
                    return false;
                }
            }
        }
        // TODO: optional_payload is also on spore specification
        if (!payload && methodDef.required_payload === true) {
            callback("payload is required");
            return false;
        }
        return true;
    }
1204254
def each
      return enum_for(__method__) unless block_given?

      each_event { |v, _, _, i|
        break if i > 0
        yield v
      }
    end
980002
private static String getSignature(MethodLiteral<?, ?> method, String[] paramNames,
      String overrideName, int overrideModifiers) throws NoSourceNameException {
    if (paramNames.length != method.getParameterTypes().size()) {
      throw new IllegalArgumentException(
          String.format("Wrong number of parameters provided for method signature, "
              + "expected %d but got %d.", method.getParameterTypes().size(), paramNames.length));
    }

    StringBuilder sb = new StringBuilder();

    if (overrideModifiers != 0) {
      sb.append(Modifier.toString(overrideModifiers)).append(" ");
    }

    if (method.getTypeParameters().length > 0) {
      List<String> typeParameters = new ArrayList<String>();
      for (TypeVariable<?> typeVariable : method.getTypeParameters()) {
        typeParameters.add(getTypeVariableDefinition(typeVariable));
      }
      sb.append("<").append(join(", ", typeParameters)).append("> ");
    }

    if (!method.isConstructor()) {
      sb.append(getSourceName(method.getReturnType())).append(" ");
      if (overrideName != null) {
        sb.append(overrideName);
      } else {
        sb.append(method.getName());
      }
    } else {
      sb.append(getSourceName(method.getRawDeclaringType()));
    }
    sb.append("(");

    // TODO(schmitt): We are not respecting varargs here.
    List<String> parameters = new ArrayList<String>();
    int i = 0;
    for (TypeLiteral<?> parameterType : method.getParameterTypes()) {
      parameters.add(
          String.format("%s %s", getSourceName(parameterType), paramNames[i]));
      i++;
    }
    sb.append(join(", ", parameters)).append(")");

    if (method.getExceptionTypes().size() > 0) {
      List<String> exceptions = new ArrayList<String>();
      for (TypeLiteral<?> exceptionType : method.getExceptionTypes()) {
        exceptions.add(getSourceName(exceptionType));
      }
      sb.append(" throws ").append(join(", ", exceptions));
    }

    return sb.toString();
  }
611667
function getCacheKey (args, methodMeta) {
    // get cache data from method meta data
    var cache = methodMeta.cache
    // if cache spec has a list of params specified then use these
    if (cache.keyParams) {
        args = _.pick(args, cache.keyParams)
    }
    // otherwise use everything except session
    else {
        // shallow clone args
        args = _.clone(args)
        // delete session from clone
        delete args.session
    }
    // generate hex id for arg data
    return stableId({
        args: args,
        method: methodMeta.signature,
    })
}
2830
def each
      return to_enum(__method__) { instance.size } unless block_given?
      instance.each_index { |i| yield(self[i]) }
      self
    end
1269569
def get_security_token!(parameters = {})
      username = parameters[:username] || @options.username
      password = parameters[:password] || @options.password
      appname = parameters[:appname] || @options.appname

      request_data = {
        'Username' => username,
        'Password' => password,
        'Appname' => appname
      }

      start_timer
      response = @connection.post(build_uri('GetToken'), MultiJson.dump(request_data.to_hash))
      end_timer

      log_get_security_token
      log_info("Response Status: #{response.status}")

      if response.status != 200
        raise make_get_security_token_error
      else
        raise_if_response_error(response)

        @security_token = response.body
      end
    end
279429
function getUniqueMethodName(methodName, module, parent) {
  if (methodName in module) {
    do {
      methodName += '!';
    } while (methodName in module);
  }
  return methodName;
}
774226
function getToken(params) {

      var api = params.api;
      var data = params.data;
      var operator = params.operator;
      var t = params.t;
      var token = params.token;

      if (!api || !data || !operator || !t || !token) {
          return;
      }

      var SPLIT_STR = "&";

      return md5([api, data, operator, t, token].join(SPLIT_STR));

    }