checkSystemInfoApiPrivilege(tizen.systeminfo.addPropertyValueArrayChangeListener, permissions);
}
-
-export function refineResolveFilename(packageId: string, permissions: string[]) {
- const originalResolveFilename = Module._resolveFilename;
- Module._resolveFilename = function(...args: any[]) {
- let path = '';
- if (args[0] === 'fs') {
- path = originalResolveFilename('fs_tizen', args[1], args[2]);
- } else if (isNetworkModule(args[0]) &&
- !permissions.includes("http://tizen.org/privilege/internet")) {
- throw new Error('The internet permission is missing.');
- } else {
- path = originalResolveFilename(...args);
- }
- if (path.startsWith('/') && !wrt.security?.checkSmack(packageId, path, 'r'))
- throw new Error(`Invalid access to ${path}`);
- return path;
- }
- Object.defineProperty(Module, '_resolveFilename', { writable: false });
-}
this.refineFilesystemApis()
this.initAccessControlManager();
this.refineXwalkUtilApis();
- this.refineResolveFilename();
}
}
this.initEdgeWebapis();
this.initMDEWebapis();
this.initProductWebapis();
- this.initSecurityWebapis();
}
initEdgeWebapis() {
}
}
- initSecurityWebapis() {
- if (wrt['security'] && !global.webapis.security) {
- let security = wrt.security as NativeWRTjs.SecurityExtension;
- global.webapis.security = {
- checkSmack: (packageId: string, path: string, type: string) => {
- let smackMap = this.smackMap;
- if (smackMap[path] !== undefined && smackMap[path][type] !== undefined)
- return smackMap[path][type];
- if (smackMap[path] === undefined)
- smackMap[path] = {};
- return smackMap[path][type] = security.checkSmack(packageId, path, type);
- }
- }
- Object.defineProperty(global.webapis, 'security', { writable: false, enumerable: true });
- }
- }
-
initAccessControlManager() {
console.log(`permissions : ${this.permissions}`);
const AccessControlManager = require('./access_control_manager');