Yikes...that's like saying 'I want to re-invent the wheel, how hard would that be?' :)
I've never done anything completely in JS, but I have built some simple user interfaces using C#/ASP.NET and the CRM SDK, which does all the heavy lifting for you, including authentication. I know you can add your own JS into those web sites for the
UI, but at least the authentication and queries could be done with the SDK.