[id: string]: any;
}
let workers: WorkerMap = {};
-let serviceType: string = wrt.getServiceModel();
let runner: any;
-function isGlobalService() {
- return serviceType === 'DAEMON';
-}
+global.serviceType = wrt.getServiceModel();
function isStandalone() {
- return serviceType === 'STANDALONE';
+ return global.serviceType === 'STANDALONE';
+}
+
+function isGlobalService() {
+ return global.serviceType === 'DAEMON';
}
function createWorker(id: string, startService: string, filename: string) {
import { isMainThread, parentPort, workerData } from 'worker_threads';
import { wrt } from '../browser/wrt';
-let serviceType: string = wrt.getServiceModel();
-
function isServiceApplication() {
- return serviceType !== 'UI';
+ return global.serviceType !== 'UI';
}
function isGlobalService() {
- return serviceType === 'DAEMON';
+ return global.serviceType === 'DAEMON';
}
function registerExtensionResolver(id: string) {
}
});
- console.log('serviceType : '+serviceType)
+ console.log(`serviceType : ${global.serviceType}`)
new DeviceAPIRouter(id, isGlobalService());
if (isServiceApplication()) {
this.createNamespace(global, ext.name);
var api = (ext.use_trampoline) ? api_ : global;
-
+ var extension_api = ext.jsapi;
+ if (global.serviceType === 'DAEMON' && ext.name === 'xwalk') {
+ console.log(`Delete freeze exports.utils for override method`);
+ extension_api = extension_api.replace('Object.freeze(exports.utils);', '');
+ extension_api = extension_api.replace('Object.freeze(Utils.prototype);', '');
+ }
const jscode =
'(function(extension) {' +
' extension.internal = {};' +
' extension.internal.sendSyncMessage = extension.sendSyncMessage;' +
' delete extension.sendSyncMessage;' +
' var exports = {}; ' +
- ' (function() {\'use strict\'; ' + ext.jsapi + '})();' +
+ ' (function() {\'use strict\'; ' + extension_api + '})();' +
' api.' + ext.name + ' = exports; ' +
'});';
serviceId: string;
packageId: string;
callerAppId: string;
+ permissions: string[];
constructor(id: string, isGlobal: boolean) {
this.id = id;
this.serviceId = ids[0];
this.callerAppId = ids[1] ?? '';
this.packageId = this.serviceId.split('.')[0];
+ this.permissions = wrt.getPrivileges(this.id);
this.initWebapis();
if (isGlobal) {
this.refinePackageApis();
this.refineFilesystemApis()
this.initAccessControlManager();
+ this.refineXwalkUtilApis();
}
}
}
initAccessControlManager() {
- const permissions = wrt.getPrivileges(this.id);
- console.log(`permissions : ${permissions}`);
+ console.log(`permissions : ${this.permissions}`);
const AccessControlManager = require('./access_control_manager');
- AccessControlManager.initialize(permissions);
+ AccessControlManager.initialize(this.permissions);
}
getServiceId() {
global.tizen.filesystem.isDirectory = this.injectVirtualRootResolver(global.tizen.filesystem.isDirectory);
global.tizen.filesystem.pathExists = this.injectVirtualRootResolver(global.tizen.filesystem.pathExists);
}
+
+ refineXwalkUtilApis() {
+ global.xwalk.utils.checkPrivilegeAccess = (privilege: string) => {
+ if (!this.permissions.includes(privilege)) {
+ throw 'Permission denied';
+ }
+ }
+ }
}