import { createHash } from 'crypto' ; export interface RequestParams { [ x ] : string ; } export interface RequestOptions { url : string ; method : string ; friendlyName : string ; params : RequestParams ; } /**
 * COntains all data used by custom facebook http logic.
 */ export default class HttpApiRequest { url : string ; method : string ; friendlyName : string ; params : RequestParams ; constructor ( options ) { this . url = options . url ; this . method = options . method ; this . friendlyName = options . friendlyName ; this . params = options . params ; } get sortedKeys ( ) { const keys = Object . keys ( this . params ) ; keys . sort ( ) ; return keys ; } serializeParams ( ) { return this . sortedKeys . map ( k => encodeURIComponent ( k ) + '=' + encodeURIComponent ( this . params [ k ] ) ) . join ( '&' ) ; } sign ( ) { let data = this . sortedKeys . map ( k => k + '=' + this . params [ k ] ) . join ( '' ) ; data += '374e60f8b9bb6b8cbb30f78030438895' ; this . params . sig = createHash ( 'md5' ) . update ( data ) . digest ( 'hex' ) ; } }