Permissions when creating a service

Hi,

I created a simple JS service that sends an HTTP GET request and looks like this:

var config = require('./config.json');
var Service = require('webos-service');
var service = new Service("com.ha.webhook.service");
const http = require('http');

const url = `http://${config.ha_url}/api/webhook/`;

service.register("webhook", function (message) {
    var id = message.payload.id;
    http.get(url + id);
    message.respond({
        returnValue: true,
        data: url + id,
    });
});


When I try to run this service using a helper WebApp, I get the following log entries:

[18:52:37.257][WARNING] ls-hubd LSHUB_NO_NAME_PERMS Can not find match for 'com.ha.webhook.service' in pattern queue '["com.webos.service.*", "com.webos.service.*", "com.webos.*", "com.palm.service.*", "com.palm.*", "com.palm.*", "com.lge.*", "com.lge.*", "airplay.service"]' {}
[18:52:37.257][ERR] ls-hubd LSHUB_NO_OUT_PERMS "com.webos.surfacemanager" does not have sufficient outbound permissions to communicate with "com.ha.webhook.service" (cmdline: /usr/bin/surface-manager -platform starfish) {"DEST_APP_ID":"com.ha.webhook.service","SRC_APP_ID":"com.webos.surfacemanager","EXE":"/usr/bin/surface-manager","PID":1853}
[18:52:37.257][WARNING] ls-hubd LSHUB_NO_SERVICE _LSHubSendQueryNameReplyMessage: Failed Connecting to Service err_code: -2, service_name: "com.ha.webhook.service", unique_name: "(null)", static, fd -1 {}
[18:52:37.260][INFO] VOICEFW VOICEUI_FOREGROUND foreground changed {"foreground":"com.webos.app.hdmi1"}
[18:52:37.262][WARNING] surface-manager LSM Hub error detected for token: 724 "webhook" "PermissionDenied" {}
[18:52:37.262][WARNING] surface-manager LSM Error response for token: 724 -1 "Not permitted to send to com.ha.webhook.service." {}


I tells me that my service name must match any of these patterns:

["com.webos.service.*", "com.webos.service.*", "com.webos.*", "com.palm.service.*", "com.palm.*", "com.palm.*", "com.lge.*", "com.lge.*", "airplay.service"]


So I tried to change my service name to com.webos.ha.service so that it fits the proposed patterns.

Unfortunately, this does not work and I get the following errors:

ares-install ERR! [com.webos.appInstallService failure]: luna-send command failed <Cannnot install privileged app on developer mode>
ares-install ERR! [Tips]: Please change the app id (app id should not start with 'com.lge', 'com.webos', 'com.palm')


So I experimented a bit and the only name that worked for me was com.webos.
And to be honest, I think this is a bug because based on the error message above, this name shouldn’t work either.

Therefore my question: Is there a way to take a freely chosen service name and fix the original permission problem?

The service name must begin with the app name. If your service name is com.ha.webhook.service, the app name must be com.ha.webhook. For more information, please refer to JS Service Usage and Hello World Service sample app. Thank you.

Yes, I know that and that’s what I did.
But then I still get the following error when calling the service:

[18:52:37.257][ERR] ls-hubd LSHUB_NO_OUT_PERMS "com.webos.surfacemanager" does not have sufficient outbound permissions to communicate with "com.ha.webhook.service" (cmdline: /usr/bin/surface-manager -platform starfish) {"DEST_APP_ID":"com.ha.webhook.service","SRC_APP_ID":"com.webos.surfacemanager","EXE":"/usr/bin/surface-manager","PID":1853}

com.ha.webhook.service cannot communicate with com.webos.surfacemanager. As we said, it should be com.ha.webhook. And we do not guarantee the compatibility of webOS TV apps with webOS OSE resources. For webOS TV apps, please use webOS TV resources in this website only. Thank you.

I have to add or correct something.
I have now adjusted the service name again to com.ha.webhook.service (and the app name accordingly to com.ha.webhook) and calling the service from the app and via ares-shell works perfectly.

I only get the above error message when I call the service from a notification, which I create via Home Assistant with the command system.notifications/createAlert.



When I click on the first button, I call up luna://com.ha.webhook.service/webhook.
Only then do I get the error:

ls-hubd LSHUB_NO_OUT_PERMS "com.webos.surfacemanager" does not have sufficient outbound permissions to communicate with "com.ha.webhook.service" (cmdline: /usr/bin/surface-manager -platform starfish) {"DEST_APP_ID":" com.ha.webhook.service","SRC_APP_ID":"com.webos.surfacemanager","EXE":"/usr/bin/surface-manager","PID":1853}

As we said above, we do not guarantee the compatibility of webOS TV apps with webOS OSE resources. Please do not use the webOS OSE API in your webOS TV app. Thank you.

I just don’t understand which part of my code is a webOS OSE resource.
It must then probably be the require('http') because the rest of the code is exactly the same as in the linked Hello World Service, which I used as a template.
If that is the case, how can I call an HTTP GET via webOS?

Or is it the use of the Luna Service API when I try to call the service?
But that’s also part of the webOS developer site: Luna Service API Introduction | webOS TV Developer and JS Service Usage | webOS TV Developer

Currently, we do not provide notification-related APIs. So if you only use the webOS TV API, you won’t get any notifications. We are not sure exactly what Home Assistant and system.notifications/createAlert are, but we are guessing they are using webOS OSE APIs like com.webos.notification somewhere. For further questions, please contact Home Assistant support. Thank you.