I've created some functions that is really about sharing objects with external users via the JSOM api in SharePoint.
var result = SP.Web.shareObject(ctx, urlToDocument,
peoplePickerInput, roleValue, groupId, propageAcl,
sendEmail, includedAnonymousLinkInEmail, emailSubject,
The code is working fine while in a scripteditor on a page in the same site as the library I'm sharing objects from. Then I get statuscode 0 and the user gets an email invitation.
But when I try the same code from a page in another site or even a SharePoint Hosted App i get: statuscode -3 and errormessage:
"MountPoint security error: NoScript isn't enabled on the host site