This likely isn't the answer that you want, but, Asterisk is not a SIP proxy. It's technically a B2BUA (back-to-back user agent).
In short, that means Asterisk is always a kind-of end-point on the call.
You might try using Kamailio which can be used as a stateless relay to act as a SIP proxy, and it's rather good at it.
However, you may be able to B2BUA the call if you can both:
A: Create a trunk from Asterisk to "SIP Server A"
B: Create a client connection from SIP.js to Asterisk. Documentation available for SIP.js specifically for this.
In which case, once the call comes inbound to Asterisk from the SIP.js client, you can bridge calls using the Dial
application in Asterisk to make a call to "sip server a"
For example, sip.conf
:
[sipjs]
context=inbound_sipjs
; ...and the rest from sip.js documentation
[sipservera]
context=inbound_sipserver
; rest as required with your sip server
Then, in your extensions.conf
, assuming an inbound call from SIP.js client:
[inbound_sipjs]
exten => _X.,1,Noop(Call from SIP.js)
same => n,Dial(SIP/sipservera/${EXTEN})
same => n,Hangup()