Choose ports dynamically

ran grunt test.
It seems like here if data.argsForCallback is defined you will be calling this.mapPromiseIdToFulfillAndReject_[promiseId].fulfill twice (once with args and a 2nd time without).  Also the same thing for the errorForCallback case

I think you can probably just call the fulfill and reject functions with argsForCallback/errorForCallback without checking if its defined, and in the undefined case (e.g. login) the caller will get a single undefined argument (basically the same as no arguments, unless the typescript compiler complains)