code: function signRequest(method, URI, host, port, token, secret, hashMethod, timestamp, nonce, bodyHash) {
  
      // Parse request URI
  
      var uri = URL.parse(URI, true);
  
      if (uri.pathname == null) {
  
          // Error: Bad request URI
          return "";
      }
  
      // Construct normalized request string
  
      var normalized = token + '\n' +
                       timestamp + '\n' +
                       nonce + '\n' +
                       bodyHash + '\n' +
                       method.toUpperCase() + '\n' +
                       host.toLowerCase() + '\n' +
                       port + '\n' +
                       uri.pathname + '\n';
  
      // Normalize parameters
  
      var params = new Array;
  
      if (uri.query) {
  
          var count = 0;
          for (var p in uri.query) {
  
              if (typeof uri.query[p] == 'string') {
  
                  params[count++] = percentEscape(p) + "=" + percentEscape(uri.query[p]);
              }
              else {
  
                  for (var i in uri.query[p]) {
  
                      params[count++] = percentEscape(p) + "=" + percentEscape(uri.query[p][i]);
                  }
              }
          }
  
          params.sort();
  
          for (var i in params) {
  
              normalized += params[i] + '\n';
          }
      }
  
      // Sign normalized request string
  
      var hmac = Crypto.createHmac(hashMethod, secret).update(normalized);
      var digest = hmac.digest(encoding = "base64");
      return digest;
  }
docs: Calculate the request signature