Alfresco does have a little known feature to do just what you need! I believe it was implemented in Enterprise 4.0.3ish, ready for 4.1, and the main use of it so far is in Cloud Sync.
The webscript you're looking for is org.alfresco.repository.site.site-share-view-url.get
and it is exposed as /api/sites/shareUrl?nodeRef=nodeRef
. It returns a simple bit of JSON, such as:
{
"site": "alfresco-test",
"url": "https:\/\/my.alfresco.com\/share\/test.com\/page\/site\/alfresco-test\/document-details?nodeRef=workspace:\/\/SpacesStore\/aae3b33fd-23d4-4091-ae64-44a8e332091341"
}
(The above example is taken from the Alfresco cloud version, but it should be present in late 4.0 enterprise releases, enterprise 4.1, and community + enterprise 4.2 onwards)
If you want to see what kinds of content it supports, your best bet is to look at the java class which powers it, org.alfresco.repo.web.scripts.site.SiteShareViewUrlGet
However, one slight restriction is that it only supports nodes that are located within sites. If you have a non-site node, you'll have to calculate a repository browser URL for it yourself...