Good news for you then, there is actually a library doing exactly what you want. Only sad part is: The relevant API's are (as far as I know) not available on mobile devices. In other words, you would need to build an abstraction layer where on mobile devices you use the Cordova capture API and on desktop devices you will use either RecordRTC which is quite a broad library or more explictedly Recorder.js which takes a bit more work to implement. Lastly you can use this library also called Recorder.js which is older and less maintained, but should fall back to flash if WebRTC is not supported.
To give an example of how RecordRTC should work:
navigator.getUserMedia({audio: true, video:false}, function(mediaStream) {
window.recordRTC = RecordRTC(MediaStream);
recordRTC.startRecording();
});
btnStopRecording.onclick = function() {
recordRTC.stopRecording(function(audioURL) {
window.open(audioURL);
//or
recordRTC.save();
});
};
Still though, despite such an abstraction layer taking some work, it's far from reinventing the wheel.