In theory, you can deploy a SIP server using an open source softswitch (FreeSWITCH, Asterisk) project and purchase "SIP trunking" service to obtain phone numbers and route calls to/from the PSTN. Then, you can configure a WebRTC SIP client to use your server. There are open source JavaScript libraries (SIP.js, JsSIP, sipML5).
That may be your best choice if you are working in small scale and quite used to running telecom infrastructure & purchasing trunking. In practice, running PSTN to WebRTC calls can be tough— lots of quality concerns. I also don't know at what scale you are looking to build your app, but over 100 simultaneous connections to your SIP server, and you'll need to deal with scaling. If you want a hosted solution to cut out the telecom hassle, you can use SIP.js and sign up for OnSIP (company supporting SIP.js), which is a pay-as-you-go service that will allow you to purchase phone numbers and just get coding your client. SIP.js user agent construction looks like this:
var userAgent = new SIP.UA({
uri: '[email protected]',
wsServers: ['wss://sip-ws.example.com'],
authorizationUser: sipUsername,
password: sipPassword
});
If you chose OnSIP (hosted), those credentials are provided by the service and register with OnSIP. If you choose to deploy your own SIP servers, you would change out accordingly.