lib/poloniex.js
function Poloniex(key, secret) {
    if (key && secret) {
      authenticated = true;
    }

    // Generate headers signed by this user's key and secret.
    // The secret is encapsulated and never exposed
    this._getPrivateHeaders = function (parameters) {
      if (!authenticated) {
        throw 'Poloniex: Error. API key and secret required';
      }

      // Convert to `arg1=foo&arg2=bar`
      const paramString = Object.keys(parameters).map(function (param) {
        return encodeURIComponent(param) + '=' + encodeURIComponent(parameters[param]);
      }).join('&');

      const signature = crypto.createHmac('sha512', secret).update(paramString).digest('hex');

      return {
        Key: key,
        Sign: signature
      };
    };
  }
function Poloniex(key, secret) {
    if (key && secret) {
      authenticated = true;
    }

    // Generate headers signed by this user's key and secret.
    // The secret is encapsulated and never exposed
    this._getPrivateHeaders = function (parameters) {
      if (!authenticated) {
        throw 'Poloniex: Error. API key and secret required';
      }

      // Convert to `arg1=foo&arg2=bar`
      const paramString = Object.keys(parameters).map(function (param) {
        return encodeURIComponent(param) + '=' + encodeURIComponent(parameters[param]);
      }).join('&');

      const signature = crypto.createHmac('sha512', secret).update(paramString).digest('hex');

      return {
        Key: key,
        Sign: signature
      };
    };
  }
function Poloniex ( key , secret ) { if ( key && secret ) { authenticated = true ; } // Generate headers signed by this user's key and secret. // The secret is encapsulated and never exposed this . _getPrivateHeaders = function ( parameters ) { if ( ! authenticated ) { throw 'Poloniex: Error. API key and secret required' ; } // Convert to `arg1=foo&arg2=bar` const paramString = Object . keys ( parameters ) . map ( function ( param ) { return encodeURIComponent ( param ) + '=' + encodeURIComponent ( parameters [ param ] ) ; } ) . join ( '&' ) ; const signature = crypto . createHmac ( 'sha512' , secret ) . update ( paramString ) . digest ( 'hex' ) ; return { Key : key , Sign : signature } ; } ; }
Constructor
Constructor