I tried quite a bit too (see this post) but did not manage to make it neither.
At the end of the day, if your goal is to reproduce itentities from dfx in agent-js, it might just unfortunately not be possible at the moment
Using @dfinity/agent in node.js - #39 by kpeacock