cordovax-edit-ats
Advanced tools
Comparing version 1.0.0 to 1.1.0
16
index.js
@@ -17,8 +17,14 @@ // npm install cordova-common 2.2.3 | ||
var ConfigFile = require(cordovaCommonPath).ConfigFile; | ||
var plistHelper = require(path.resolve(cordovaCommonPath, 'src', 'util', 'plist-helpers')); | ||
var configFile = new ConfigFile(iosPlatformPath, 'ios', '*-Info.plist'); | ||
if (command === 'create') { | ||
logger.log("creating NSAppTransportSecurity"); | ||
configFile.graft_child('NSAppTransportSecurity', | ||
{xml:'<dict><key>NSAllowsArbitraryLoads</key><true/></dict>'} | ||
); | ||
if (['create', 'create_true', 'create_false'].includes(command)) { | ||
var value = ['create', 'create_true'].includes(command) ? 'true' : 'false'; | ||
logger.log('creating NSAppTransportSecurity NSAllowsArbitraryLoads ' + value); | ||
if (configFile.data['NSAppTransportSecurity']) { // alread exists | ||
configFile.data['NSAppTransportSecurity']['NSAllowsArbitraryLoads'] = value == 'true'; | ||
} else { | ||
configFile.graft_child('NSAppTransportSecurity', | ||
{xml:'<dict><key>NSAllowsArbitraryLoads</key><'+value+'/></dict>'} | ||
); | ||
} | ||
} else { | ||
@@ -25,0 +31,0 @@ logger.log("removing NSAppTransportSecurity"); |
{ | ||
"name": "cordovax-edit-ats", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "repository" : { |
@@ -26,3 +26,22 @@ # Introduction | ||
the following ATS is created | ||
``` | ||
<key>NSAppTransportSecurity</key> | ||
<dict> | ||
<key>NSAllowsArbitraryLoads</key> | ||
<true/> | ||
</dict> | ||
``` | ||
Create ATS with NSAllowsArbitraryLoads true | ||
``` | ||
$ npx xordovax-edit-ats create true | ||
``` | ||
Create ATS with NSAllowsArbitraryLoads false | ||
``` | ||
$ npx xordovax-edit-ats create false | ||
``` | ||
# With Cordova hook. | ||
@@ -35,6 +54,6 @@ | ||
``` | ||
<hook src="scripts/removeATS.js" type="after_platform_add" /> | ||
<hook src="scripts/editPlist.js" type="after_platform_add" /> | ||
``` | ||
scripts/removeATS.js | ||
scripts/editPlist.js | ||
``` | ||
@@ -45,5 +64,5 @@ var editATS = require('cordovax-edit-ats'); | ||
if (context.opts.cordova.platforms.includes('ios')) { | ||
editATS('remove', context.opts.projectRoot); | ||
editATS('create_false', context.opts.projectRoot); | ||
} | ||
}; | ||
``` |
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
3613
36
66
3