Illustrator is a vector app (and file format), so it's pretty much impossible to convert a raster format image to the AI format. The other way around would be feasible, although I am unaware of a free library that can do this. The commercial
Aspose library claims to support that, though. I take it you have checked whether Adobe offers something?
You wouldn't need to do it in JavaScript as well (which is even less likely to exist anyway), since JavaScript could also access the service running on the backend.