Young 4 år sedan
incheckning
a046b7354c
38 ändrade filer med 2282 tillägg och 0 borttagningar
  1. 3 0
      .gitignore
  2. 31 0
      README.md
  3. 27 0
      config.xml
  4. 23 0
      hooks/README.md
  5. 223 0
      package-lock.json
  6. 30 0
      package.json
  7. 19 0
      plugins/android.json
  8. 4 0
      plugins/cordova-plugin-semsx-launcher/.github/FUNDING.yml
  9. 141 0
      plugins/cordova-plugin-semsx-launcher/.github/ISSUE_TEMPLATE.md
  10. 37 0
      plugins/cordova-plugin-semsx-launcher/.github/PULL_REQUEST_TEMPLATE.md
  11. 2 0
      plugins/cordova-plugin-semsx-launcher/.gitignore
  12. 11 0
      plugins/cordova-plugin-semsx-launcher/README.md
  13. 53 0
      plugins/cordova-plugin-semsx-launcher/hooks/on-uninstall.js
  14. 60 0
      plugins/cordova-plugin-semsx-launcher/hooks/support-kotlin.js
  15. 29 0
      plugins/cordova-plugin-semsx-launcher/package.json
  16. 54 0
      plugins/cordova-plugin-semsx-launcher/plugin.xml
  17. 64 0
      plugins/cordova-plugin-semsx-launcher/src/android/CheckWindowStateService.kt
  18. 8 0
      plugins/cordova-plugin-semsx-launcher/src/android/check_window_state.xml
  19. 37 0
      plugins/cordova-plugin-whitelist/CONTRIBUTING.md
  20. 202 0
      plugins/cordova-plugin-whitelist/LICENSE
  21. 5 0
      plugins/cordova-plugin-whitelist/NOTICE
  22. 167 0
      plugins/cordova-plugin-whitelist/README.md
  23. 87 0
      plugins/cordova-plugin-whitelist/RELEASENOTES.md
  24. 67 0
      plugins/cordova-plugin-whitelist/package.json
  25. 44 0
      plugins/cordova-plugin-whitelist/plugin.xml
  26. 161 0
      plugins/cordova-plugin-whitelist/src/android/WhitelistPlugin.java
  27. 53 0
      plugins/cordova-plugin-whitelist/tests/README.md
  28. 15 0
      plugins/cordova-plugin-whitelist/tests/package.json
  29. 56 0
      plugins/cordova-plugin-whitelist/tests/plugin.xml
  30. 19 0
      plugins/cordova-plugin-whitelist/tests/scripts/remove-access.js
  31. 90 0
      plugins/cordova-plugin-whitelist/tests/src/android/WhitelistAPI.java
  32. 214 0
      plugins/cordova-plugin-whitelist/tests/tests.js
  33. 34 0
      plugins/cordova-plugin-whitelist/tests/www/whitelist.js
  34. 10 0
      plugins/fetch.json
  35. 107 0
      www/css/index.css
  36. BIN
      www/img/logo.png
  37. 49 0
      www/index.html
  38. 46 0
      www/js/index.js

+ 3 - 0
.gitignore

@@ -0,0 +1,3 @@
1
+node_modules
2
+
3
+platforms

+ 31 - 0
README.md

@@ -0,0 +1,31 @@
1
+# Script
2
+
3
+Copy plugins/cordova-plugin-semsx-launcher to root project ./plugins
4
+
5
+## Step
6
+
7
+```
8
+cordova platform remove android
9
+cordova platform add android
10
+replace AndroidManifest
11
+cordova run android
12
+```
13
+
14
+## Replace AndroidManifest
15
+
16
+```
17
+            <intent-filter android:label="@string/launcher_name">
18
+                <action android:name="android.intent.action.MAIN" />
19
+                <category android:name="android.intent.category.LAUNCHER" />
20
+            </intent-filter>
21
+```
22
+
23
+Chang to
24
+
25
+```
26
+            <intent-filter android:label="home">
27
+                <action android:name="android.intent.action.MAIN" />
28
+                <category android:name="android.intent.category.HOME" />
29
+                <category android:name="android.intent.category.DEFAULT" />
30
+            </intent-filter>
31
+```

+ 27 - 0
config.xml

@@ -0,0 +1,27 @@
1
+<?xml version='1.0' encoding='utf-8'?>
2
+<widget id="com.example.hello" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
3
+    <name>HelloWorld</name>
4
+    <description>
5
+        A sample Apache Cordova application that responds to the deviceready event.
6
+    </description>
7
+    <author email="dev@cordova.apache.org" href="http://cordova.io">
8
+        Apache Cordova Team
9
+    </author>
10
+    <content src="index.html" />
11
+    <access origin="*" />
12
+    <allow-intent href="http://*/*" />
13
+    <allow-intent href="https://*/*" />
14
+    <allow-intent href="tel:*" />
15
+    <allow-intent href="sms:*" />
16
+    <allow-intent href="mailto:*" />
17
+    <allow-intent href="geo:*" />
18
+    <platform name="android">
19
+        <allow-intent href="market:*" />
20
+    </platform>
21
+    <platform name="ios">
22
+        <allow-intent href="itms:*" />
23
+        <allow-intent href="itms-apps:*" />
24
+    </platform>
25
+    <plugin name="cordova-plugin-whitelist" spec="1" />
26
+    <engine name="android" spec="^7.1.4" />
27
+</widget>

+ 23 - 0
hooks/README.md

@@ -0,0 +1,23 @@
1
+<!--
2
+#
3
+# Licensed to the Apache Software Foundation (ASF) under one
4
+# or more contributor license agreements.  See the NOTICE file
5
+# distributed with this work for additional information
6
+# regarding copyright ownership.  The ASF licenses this file
7
+# to you under the Apache License, Version 2.0 (the
8
+# "License"); you may not use this file except in compliance
9
+# with the License.  You may obtain a copy of the License at
10
+#
11
+# http://www.apache.org/licenses/LICENSE-2.0
12
+#
13
+# Unless required by applicable law or agreed to in writing,
14
+# software distributed under the License is distributed on an
15
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+#  KIND, either express or implied.  See the License for the
17
+# specific language governing permissions and limitations
18
+# under the License.
19
+#
20
+-->
21
+# Cordova Hooks
22
+
23
+Cordova Hooks represent special scripts which could be added by application and plugin developers or even by your own build system  to customize cordova commands. See Hooks Guide for more details:  http://cordova.apache.org/docs/en/edge/guide_appdev_hooks_index.md.html#Hooks%20Guide.

+ 223 - 0
package-lock.json

@@ -0,0 +1,223 @@
1
+{
2
+    "name": "com.example.hello",
3
+    "version": "1.0.0",
4
+    "lockfileVersion": 1,
5
+    "requires": true,
6
+    "dependencies": {
7
+        "cordova-android": {
8
+            "version": "7.1.4",
9
+            "resolved": "https://registry.npmjs.org/cordova-android/-/cordova-android-7.1.4.tgz",
10
+            "integrity": "sha512-Rtvu002I83uzfVyCsE6p2krFKVHt9TSAqZUATes+zH+o9cdxYGrLHY+PKCQo4SLCdSMdrkIHCDnQPTYTp/d7+g==",
11
+            "requires": {
12
+                "abbrev": "1.1.1",
13
+                "android-versions": "1.4.0",
14
+                "ansi": "0.3.1",
15
+                "balanced-match": "1.0.0",
16
+                "base64-js": "1.2.0",
17
+                "big-integer": "1.6.32",
18
+                "bplist-parser": "0.1.1",
19
+                "brace-expansion": "1.1.11",
20
+                "concat-map": "0.0.1",
21
+                "cordova-common": "2.2.5",
22
+                "cordova-registry-mapper": "1.1.15",
23
+                "elementtree": "0.1.6",
24
+                "glob": "5.0.15",
25
+                "inflight": "1.0.6",
26
+                "inherits": "2.0.3",
27
+                "minimatch": "3.0.4",
28
+                "nopt": "3.0.1",
29
+                "once": "1.4.0",
30
+                "path-is-absolute": "1.0.1",
31
+                "plist": "2.1.0",
32
+                "properties-parser": "0.2.3",
33
+                "q": "1.4.1",
34
+                "sax": "0.3.5",
35
+                "semver": "5.5.0",
36
+                "shelljs": "0.5.3",
37
+                "underscore": "1.9.1",
38
+                "unorm": "1.4.1",
39
+                "wrappy": "1.0.2",
40
+                "xmlbuilder": "8.2.2",
41
+                "xmldom": "0.1.27"
42
+            },
43
+            "dependencies": {
44
+                "abbrev": {
45
+                    "version": "1.1.1",
46
+                    "bundled": true
47
+                },
48
+                "android-versions": {
49
+                    "version": "1.4.0",
50
+                    "bundled": true,
51
+                    "requires": {
52
+                        "semver": "5.5.0"
53
+                    }
54
+                },
55
+                "ansi": {
56
+                    "version": "0.3.1",
57
+                    "bundled": true
58
+                },
59
+                "balanced-match": {
60
+                    "version": "1.0.0",
61
+                    "bundled": true
62
+                },
63
+                "base64-js": {
64
+                    "version": "1.2.0",
65
+                    "bundled": true
66
+                },
67
+                "big-integer": {
68
+                    "version": "1.6.32",
69
+                    "bundled": true
70
+                },
71
+                "bplist-parser": {
72
+                    "version": "0.1.1",
73
+                    "bundled": true,
74
+                    "requires": {
75
+                        "big-integer": "1.6.32"
76
+                    }
77
+                },
78
+                "brace-expansion": {
79
+                    "version": "1.1.11",
80
+                    "bundled": true,
81
+                    "requires": {
82
+                        "balanced-match": "1.0.0",
83
+                        "concat-map": "0.0.1"
84
+                    }
85
+                },
86
+                "concat-map": {
87
+                    "version": "0.0.1",
88
+                    "bundled": true
89
+                },
90
+                "cordova-common": {
91
+                    "version": "2.2.5",
92
+                    "bundled": true,
93
+                    "requires": {
94
+                        "ansi": "0.3.1",
95
+                        "bplist-parser": "0.1.1",
96
+                        "cordova-registry-mapper": "1.1.15",
97
+                        "elementtree": "0.1.6",
98
+                        "glob": "5.0.15",
99
+                        "minimatch": "3.0.4",
100
+                        "plist": "2.1.0",
101
+                        "q": "1.4.1",
102
+                        "shelljs": "0.5.3",
103
+                        "underscore": "1.9.1",
104
+                        "unorm": "1.4.1"
105
+                    }
106
+                },
107
+                "cordova-registry-mapper": {
108
+                    "version": "1.1.15",
109
+                    "bundled": true
110
+                },
111
+                "elementtree": {
112
+                    "version": "0.1.6",
113
+                    "bundled": true,
114
+                    "requires": {
115
+                        "sax": "0.3.5"
116
+                    }
117
+                },
118
+                "glob": {
119
+                    "version": "5.0.15",
120
+                    "bundled": true,
121
+                    "requires": {
122
+                        "inflight": "1.0.6",
123
+                        "inherits": "2.0.3",
124
+                        "minimatch": "3.0.4",
125
+                        "once": "1.4.0",
126
+                        "path-is-absolute": "1.0.1"
127
+                    }
128
+                },
129
+                "inflight": {
130
+                    "version": "1.0.6",
131
+                    "bundled": true,
132
+                    "requires": {
133
+                        "once": "1.4.0",
134
+                        "wrappy": "1.0.2"
135
+                    }
136
+                },
137
+                "inherits": {
138
+                    "version": "2.0.3",
139
+                    "bundled": true
140
+                },
141
+                "minimatch": {
142
+                    "version": "3.0.4",
143
+                    "bundled": true,
144
+                    "requires": {
145
+                        "brace-expansion": "1.1.11"
146
+                    }
147
+                },
148
+                "nopt": {
149
+                    "version": "3.0.1",
150
+                    "bundled": true,
151
+                    "requires": {
152
+                        "abbrev": "1.1.1"
153
+                    }
154
+                },
155
+                "once": {
156
+                    "version": "1.4.0",
157
+                    "bundled": true,
158
+                    "requires": {
159
+                        "wrappy": "1.0.2"
160
+                    }
161
+                },
162
+                "path-is-absolute": {
163
+                    "version": "1.0.1",
164
+                    "bundled": true
165
+                },
166
+                "plist": {
167
+                    "version": "2.1.0",
168
+                    "bundled": true,
169
+                    "requires": {
170
+                        "base64-js": "1.2.0",
171
+                        "xmlbuilder": "8.2.2",
172
+                        "xmldom": "0.1.27"
173
+                    }
174
+                },
175
+                "properties-parser": {
176
+                    "version": "0.2.3",
177
+                    "bundled": true
178
+                },
179
+                "q": {
180
+                    "version": "1.4.1",
181
+                    "bundled": true
182
+                },
183
+                "sax": {
184
+                    "version": "0.3.5",
185
+                    "bundled": true
186
+                },
187
+                "semver": {
188
+                    "version": "5.5.0",
189
+                    "bundled": true
190
+                },
191
+                "shelljs": {
192
+                    "version": "0.5.3",
193
+                    "bundled": true
194
+                },
195
+                "underscore": {
196
+                    "version": "1.9.1",
197
+                    "bundled": true
198
+                },
199
+                "unorm": {
200
+                    "version": "1.4.1",
201
+                    "bundled": true
202
+                },
203
+                "wrappy": {
204
+                    "version": "1.0.2",
205
+                    "bundled": true
206
+                },
207
+                "xmlbuilder": {
208
+                    "version": "8.2.2",
209
+                    "bundled": true
210
+                },
211
+                "xmldom": {
212
+                    "version": "0.1.27",
213
+                    "bundled": true
214
+                }
215
+            }
216
+        },
217
+        "cordova-plugin-whitelist": {
218
+            "version": "1.3.4",
219
+            "resolved": "https://registry.npmjs.org/cordova-plugin-whitelist/-/cordova-plugin-whitelist-1.3.4.tgz",
220
+            "integrity": "sha512-EYC5eQFVkoYXq39l7tYKE6lEjHJ04mvTmKXxGL7quHLdFPfJMNzru/UYpn92AOfpl3PQaZmou78C7EgmFOwFQQ=="
221
+        }
222
+    }
223
+}

+ 30 - 0
package.json

@@ -0,0 +1,30 @@
1
+{
2
+  "name": "com.example.hello",
3
+  "displayName": "HelloWorld",
4
+  "version": "1.0.0",
5
+  "description": "A sample Apache Cordova application that responds to the deviceready event.",
6
+  "main": "index.js",
7
+  "scripts": {
8
+    "test": "echo \"Error: no test specified\" && exit 1"
9
+  },
10
+  "keywords": [
11
+    "ecosystem:cordova"
12
+  ],
13
+  "author": "Apache Cordova Team",
14
+  "license": "Apache-2.0",
15
+  "dependencies": {
16
+    "cordova-android": "^7.1.4",
17
+    "cordova-plugin-whitelist": "1"
18
+  },
19
+  "devDependencies": {
20
+    "cordova-plugin-whitelist": "^1.3.4"
21
+  },
22
+  "cordova": {
23
+    "plugins": {
24
+      "cordova-plugin-whitelist": {}
25
+    },
26
+    "platforms": [
27
+      "android"
28
+    ]
29
+  }
30
+}

+ 19 - 0
plugins/android.json

@@ -0,0 +1,19 @@
1
+{
2
+  "prepare_queue": {
3
+    "installed": [],
4
+    "uninstalled": []
5
+  },
6
+  "config_munge": {
7
+    "files": {}
8
+  },
9
+  "installed_plugins": {
10
+    "cordova-plugin-whitelist": {
11
+      "PACKAGE_NAME": "com.example.hello"
12
+    }
13
+  },
14
+  "dependent_plugins": {
15
+    "cordova-plugin-semsx-launcher": {
16
+      "PACKAGE_NAME": "com.example.hello"
17
+    }
18
+  }
19
+}

+ 4 - 0
plugins/cordova-plugin-semsx-launcher/.github/FUNDING.yml

@@ -0,0 +1,4 @@
1
+# These are supported funding model platforms
2
+
3
+github: [ dpa99c ]
4
+custom: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZRD3W47HQ3EMJ&source=url

+ 141 - 0
plugins/cordova-plugin-semsx-launcher/.github/ISSUE_TEMPLATE.md

@@ -0,0 +1,141 @@
1
+<!--
2
+WARNING: Failure to follow the issue template guidelines below will result in the issue being immediately closed.
3
+
4
+Only bug reports/feature request/documentation issues should be opened here.
5
+
6
+Before opening an issue, please check a similar issue is not already open (or closed). Duplicates or near-duplicates will be closed immediately.
7
+-->
8
+
9
+**I'm submitting a ...**  (check one with "x"):
10
+- [ ] bug report
11
+- [ ] feature request
12
+- [ ] documentation issue
13
+
14
+
15
+<!-- Fill out the relevant sections below and delete irrelevant sections. -->
16
+
17
+# Bug report
18
+
19
+**Current behavior:**
20
+
21
+<!-- Describe how the bug manifests. -->
22
+
23
+<!-- Explain how you're sure there is an issue with this plugin rather than your own code:
24
+ - If this plugin has an example project, have you been able to reproduce the issue within it?
25
+ - Have you created a clean test Cordova project containing only this plugin to eliminate the potential for interference with other plugins/code?
26
+ -->
27
+
28
+**Expected behavior:**
29
+
30
+<!-- Describe what the behavior should be without the bug. -->
31
+
32
+**Steps to reproduce:**
33
+
34
+<!-- If you are able to illustrate the bug with an example, please provide steps to reproduce. -->
35
+
36
+**Environment information**
37
+
38
+<!-- Please supply full details of your development environment including: -->
39
+- Cordova CLI version 
40
+	- `cordova -v`
41
+- Cordova platform version
42
+	- `cordova platform ls`
43
+- Plugins & versions installed in project (including this plugin)
44
+    - `cordova plugin ls`
45
+- Dev machine OS and version, e.g.
46
+    - OSX
47
+        - `sw_vers`
48
+    - Windows 10
49
+        - `winver`
50
+        
51
+_Runtime issue_
52
+- Device details
53
+    - _e.g. iPhone 7, Samsung Galaxy S8, iPhone X Simulator, Pixel XL Emulator_
54
+- OS details
55
+    - _e.g. iOS 11.2, Android 8.1_	
56
+	
57
+_Android build issue:_	
58
+- Node JS version
59
+    - `node -v`
60
+- Gradle version
61
+	- `ls platforms/android/.gradle`
62
+- Target Android SDK version
63
+	- `android:targetSdkVersion` in `AndroidManifest.xml`
64
+- Android SDK details
65
+	- `sdkmanager --list | sed -e '/Available Packages/q'`
66
+	
67
+_iOS build issue:_
68
+- Node JS version
69
+    - `node -v`
70
+- XCode version
71
+
72
+_If using an [Ionic Native Typescript wrapper]() for this plugin:_
73
+- Ionic environment info
74
+    - `ionic info`
75
+- Installed Ionic Native modules and versions
76
+    - `npm list | grep "@ionic-native"`
77
+
78
+<!--
79
+NOTE: Ionic Native Typescript wrappers are maintained by the Ionic Team:
80
+- Any issue which is suspected of being caused by the Ionic Native wrapper should be reported against Ionic Native (https://github.com/ionic-team/ionic-native/issues)
81
+- To verify an if an issue is caused by this plugin or its Typescript wrapper, please re-test using the vanilla Javascript plugin interface (without the Ionic Native wrapper).
82
+- Any issue opened here which is obviously an Ionic Typescript wrapper issue will be closed immediately.
83
+-->
84
+
85
+**Related code:**
86
+
87
+```
88
+insert any relevant code here such as plugin API calls / input parameters
89
+```
90
+
91
+**Console output**
92
+
93
+<details>
94
+<summary>console output</summary>
95
+
96
+```
97
+
98
+// Paste any relevant JS/native console output here
99
+
100
+```
101
+
102
+</details><br/><br/>
103
+
104
+**Other information:**
105
+
106
+<!-- List any other information that is relevant to your issue. Stack traces, related issues, suggestions on how to fix, Stack Overflow links, forum links, etc. -->
107
+
108
+# Feature request
109
+<!--
110
+Feature requests should include as much detail as possible:
111
+
112
+- A descriptive title 
113
+- A description of the problem you're trying to solve, including why you think this is a problem
114
+- An overview of the suggested solution
115
+- Use case: why should this be implemented?
116
+- If the feature changes current behavior, reasons why your solution is better
117
+- Relevant links, e.g.
118
+    - Stack Overflow post illustrating a solution
119
+    - Code within a Github repo that illustrates a solution
120
+    - Native API documentation for proposed feature
121
+-->
122
+
123
+# Documentation issue
124
+<!-- 
125
+Describe the issue with the documentation or the request for documentation changes.
126
+- Please give reasons why the change is necessary.
127
+- If the change is trivial or you are able to make it, please consider making a Pull Request containing the necessary changes.
128
+-->
129
+
130
+
131
+
132
+
133
+<!--
134
+A POLITE REMINDER
135
+
136
+- This is free, open-source software. 
137
+- Although the author makes every effort to maintain it, no guarantees are made as to the quality or reliability, and reported issues will be addressed if and when the author has time. 
138
+- Help/support will not be given by the author, so forums (e.g. Ionic) or Stack Overflow should be used. Any issues requesting help/support will be closed immediately.
139
+- If you have urgent need of a bug fix/feature, the author can be engaged for PAID contract work to do so: please contact dave@workingedge.co.uk
140
+- Rude or abusive comments/issues will not be tolerated, nor will opening multiple issues if those previously closed are deemed unsuitable. Any of the above will result in you being BANNED from ALL of my Github repositories.
141
+-->

+ 37 - 0
plugins/cordova-plugin-semsx-launcher/.github/PULL_REQUEST_TEMPLATE.md

@@ -0,0 +1,37 @@
1
+## PR Type
2
+What kind of change does this PR introduce?
3
+
4
+<!-- Please check the one that applies to this PR using "x". -->
5
+- [ ] Bugfix
6
+- [ ] Feature
7
+- [ ] Code style update (formatting, local variables)
8
+- [ ] Refactoring (no functional changes, no api changes)
9
+- [ ] Documentation  changes
10
+- [ ] Other... Please describe:
11
+
12
+<!-- Fill out the relevant sections below and delete irrelevant sections. -->
13
+
14
+## PR Checklist
15
+For bug fixes / features, please check if your PR fulfills the following requirements:
16
+
17
+- [ ] Testing has been carried out for the changes have been added
18
+- [ ] Regression testing has been carried out for existing functionality
19
+- [ ] Docs have been added / updated
20
+
21
+## What is the purpose of this PR?
22
+<!-- Describe any current behavior that you are modifying, or link to a relevant issue. -->
23
+<!-- Describe the new behaviour added/modified and its purpose. -->
24
+
25
+## Does this PR introduce a breaking change?
26
+- [ ] Yes
27
+- [ ] No
28
+
29
+<!-- If this PR contains a breaking change, please describe the impact and migration path for existing plugin versions. -->
30
+
31
+## What testing has been done on the changes in the PR?
32
+<!-- e.g. if an example project exists for this plugin, has it been updated to test the new functionality? -->
33
+
34
+## What testing has been done on existing functionality?
35
+<!-- e.g. if an example project exists for this plugin, has been it been tested to ensure no regression bugs have been introduced? -->
36
+
37
+## Other information

+ 2 - 0
plugins/cordova-plugin-semsx-launcher/.gitignore

@@ -0,0 +1,2 @@
1
+.idea
2
+/src/android/obj

+ 11 - 0
plugins/cordova-plugin-semsx-launcher/README.md

@@ -0,0 +1,11 @@
1
+cordova-plugin-hello-kotlin
2
+===========================
3
+
4
+A simple example of a Cordova plugin that uses Kotlin (instead of Java) to implement the native Cordova plugin interface on Android.
5
+
6
+Since `cordova-android@7` currently doesn't implicitly support Kotlin, this plugin uses hook scripts to add the necessary native config to make the Kotlin work in the generated Android project and to remove the Kotlin source files from the native Android project on uninstalling the plugin.
7
+
8
+
9
+- Clone the [test project](https://github.com/dpa99c/cordova-plugin-hello-kotlin-test): `git clone https://github.com/dpa99c/cordova-plugin-hello-kotlin-test`
10
+- Add the Android platform: `cordova platform add android`
11
+- Run the test app: `cordova run android`

+ 53 - 0
plugins/cordova-plugin-semsx-launcher/hooks/on-uninstall.js

@@ -0,0 +1,53 @@
1
+const fs = require('fs');
2
+const path = require('path');
3
+const xml2js = require('xml2js');
4
+
5
+const PLUGIN_ID = "cordova-plugin-semsx-launcher";
6
+const androidPlatformRoot = "./platforms/android/";
7
+
8
+let  deferral;
9
+
10
+function removeKotlinSourceFiles(){
11
+
12
+    const pluginXML = fs.readFileSync('./plugins/'+PLUGIN_ID+'/plugin.xml').toString();
13
+    const parser = new xml2js.Parser();
14
+    parser.parseString(pluginXML, (error, config) => {
15
+        if (error) return;
16
+        if (!config.plugin.hasOwnProperty('platform')) return;
17
+        for (let platform of config.plugin.platform)
18
+            if (platform['$'].name === 'android') {
19
+                if (platform.hasOwnProperty('source-file')){
20
+                    let sourceFiles = platform['source-file'];
21
+                    for(let sourceFile of sourceFiles){
22
+                        if (sourceFile['$'].hasOwnProperty('src')){
23
+                            let src = sourceFile['$']['src'];
24
+                            if(src.match(/\.kt/)){
25
+                                let srcParts = src.split('/');
26
+                                let filename = srcParts[srcParts.length - 1];
27
+                                let filepath = sourceFile['$']['target-dir'];
28
+                                filepath = androidPlatformRoot+filepath+'/'+filename;
29
+                                if(fs.existsSync(path.resolve(filepath))){
30
+                                    fs.unlinkSync(filepath);
31
+                                    console.log("Removed Kotlin source file: "+filepath);
32
+                                }
33
+                            }
34
+                        }
35
+                    }
36
+                }
37
+                break;
38
+            }
39
+    });
40
+    
41
+}
42
+module.exports = function(ctx) {
43
+    try{
44
+        deferral = ctx.requireCordovaModule('q').defer();
45
+        removeKotlinSourceFiles();
46
+        deferral.resolve();
47
+    }catch(e){
48
+        let msg = e.toString();
49
+        console.dir(e);
50
+        deferral.reject(msg);
51
+        return deferral.promise;
52
+    }
53
+};

+ 60 - 0
plugins/cordova-plugin-semsx-launcher/hooks/support-kotlin.js

@@ -0,0 +1,60 @@
1
+const fs = require('fs');
2
+const xml2js = require('xml2js');
3
+
4
+const PLUGIN_ID = "cordova-plugin-semsx-launcher";
5
+const gradlePath = './platforms/android/app/build.gradle'; // cordova-android@7+ path
6
+
7
+let deferral;
8
+
9
+function addSupport() {
10
+    let defaultArgs = {
11
+        kotlin_version: '\text.kotlin_version = "latest.integration"\n\t',
12
+        kotlin_android: 'apply plugin: "kotlin-android"',
13
+        classpath: ' \t\tclasspath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"'
14
+    };
15
+    const pluginXML = fs.readFileSync('./plugins/' + PLUGIN_ID + '/plugin.xml').toString();
16
+    const gradle = fs.readFileSync(gradlePath).toString();
17
+    let text = gradle;
18
+    const parser = new xml2js.Parser();
19
+    parser.parseString(pluginXML, (error, config) => {
20
+        if (error) return;
21
+        if (!config.plugin.hasOwnProperty('platform')) return;
22
+        for (let x of config.plugin.platform)
23
+            if (x['$'].name === 'android') {
24
+                if (x['$'].hasOwnProperty('kotlin')) defaultArgs.kotlin_version = `\text.kotlin_version = "${x['$'].kotlin}"\n\t`;
25
+                if (x.hasOwnProperty('apply-plugin')) defaultArgs.apply_plugin = x['apply-plugin'];
26
+                break;
27
+            }
28
+        if (!gradle.match(/ext.kotlin_version/g)) append(defaultArgs.kotlin_version, /buildscript(\s*)\{\s*/g);
29
+        if (!gradle.match(/kotlin-gradle-plugin/g)) append(defaultArgs.classpath, /classpath\s+(['"])[\w.:]+(['"])/g);
30
+        if (!gradle.match(/apply\s+plugin(\s*:\s*)(['"])kotlin-android(['"])/g)) append(defaultArgs.kotlin_android);
31
+        if (defaultArgs.apply_plugin)
32
+            for (let x of defaultArgs.apply_plugin) {
33
+                const reg = new RegExp(`apply\\s+plugin(\\s*:\\s*)(['"])${x}(['"])`, 'g');
34
+                if (!gradle.match(reg)) append(`apply plugin: "${x}"`);
35
+            }
36
+    });
37
+
38
+    function append(edit, reg) {
39
+        if (reg === undefined) reg = /com.android.application['"]/g;
40
+        const pos = text.search(reg);
41
+        const len = text.match(reg)[0].length;
42
+        const header = text.substring(0, pos + len);
43
+        const footer = text.substring(pos + len);
44
+        text = header + '\n' + edit + footer;
45
+    }
46
+
47
+    fs.writeFileSync(gradlePath, text);
48
+}
49
+module.exports = function (ctx) {
50
+    try {
51
+        deferral = ctx.requireCordovaModule('q').defer();
52
+        addSupport();
53
+        deferral.resolve();
54
+    } catch (e) {
55
+        let msg = e.toString();
56
+        console.dir(e);
57
+        deferral.reject(msg);
58
+        return deferral.promise;
59
+    }
60
+};

+ 29 - 0
plugins/cordova-plugin-semsx-launcher/package.json

@@ -0,0 +1,29 @@
1
+{
2
+    "version": "1.0.0",
3
+    "name": "cordova-plugin-semsx-launcher",
4
+    "cordova_name": "Hello Kotlin",
5
+    "description": "",
6
+    "cordova": {
7
+        "id": "cordova-plugin-semsx-launcher",
8
+        "platforms": [
9
+            "android"
10
+        ]
11
+    },
12
+    "keywords": [
13
+        "ecosystem:cordova",
14
+        "cordova",
15
+        "android",
16
+        "kotlin"
17
+    ],
18
+    "dependencies": {
19
+        "xml2js": "^0.4.19"
20
+    },
21
+    "engines": {
22
+        "cordovaDependencies": {
23
+            "1.0.0": {
24
+                "cordova-android": ">=7.0.0",
25
+                "cordova": ">=7.1.0"
26
+            }
27
+        }
28
+    }
29
+}

+ 54 - 0
plugins/cordova-plugin-semsx-launcher/plugin.xml

@@ -0,0 +1,54 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
3
+        id="cordova-plugin-semsx-launcher"
4
+        version="1.0.0">
5
+
6
+  <name>Hello Kotlin</name>
7
+
8
+  <engines>
9
+    <engine name="cordova" version=">=7.1.0"/>
10
+    <engine name="cordova-android" version=">=7.0.0"/>
11
+  </engines>
12
+
13
+  <author email="young91@vip.qq.com">Young</author>
14
+
15
+  <platform name="android"
16
+            kotlin="1.2.30">
17
+    <!-- Add Kotlin support -->
18
+    <hook type="after_plugin_add" src="hooks/support-kotlin.js" />
19
+    <hook type="after_platform_add" src="hooks/support-kotlin.js" />
20
+    <framework src="org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.31" />
21
+    <apply-plugin>kotlin-android-extensions</apply-plugin>
22
+    <apply-plugin>kotlin-kapt</apply-plugin>
23
+
24
+    <!-- Cleanup Kotlin source on uninstall -->
25
+    <hook type="before_plugin_rm" src="hooks/on-uninstall.js" />
26
+    <hook type="before_plugin_uninstall" src="hooks/on-uninstall.js" />
27
+    
28
+    <config-file target="config.xml" parent="/*">    
29
+      <custom-preference delete="true" name="android-manifest/application/activity[@android:name='MainActivity']" />
30
+    </config-file>
31
+
32
+    <config-file target="res/values/strings.xml" parent="/*">
33
+        <string name="check_window">Lock Window</string>
34
+    </config-file> 
35
+
36
+    <config-file parent="/manifest/application" target="AndroidManifest.xml">      
37
+        <service
38
+            android:name="com.semsx.android.home.locker.CheckWindowStateService"
39
+            android:enabled="true"
40
+            android:exported="true"
41
+            android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE" >
42
+            <intent-filter>
43
+                <action android:name="android.accessibilityservice.AccessibilityService" />
44
+            </intent-filter>
45
+
46
+            <meta-data
47
+                android:name="android.accessibilityservice"
48
+                android:resource="@xml/check_window_state"/>
49
+        </service>
50
+    </config-file>
51
+    <source-file src="src/android/CheckWindowStateService.kt" target-dir="app/src/main/java/com/semsx/android/home/locker"/>
52
+    <source-file src="src/android/check_window_state.xml" target-dir="app/src/main/res/xml"/>
53
+  </platform>
54
+</plugin>

+ 64 - 0
plugins/cordova-plugin-semsx-launcher/src/android/CheckWindowStateService.kt

@@ -0,0 +1,64 @@
1
+package com.semsx.android.home.locker
2
+
3
+import android.accessibilityservice.AccessibilityService
4
+import android.accessibilityservice.AccessibilityServiceInfo
5
+import android.app.KeyguardManager
6
+import android.content.Context
7
+import android.view.accessibility.AccessibilityEvent
8
+
9
+
10
+class CheckWindowStateService : AccessibilityService() {
11
+    
12
+    companion object {
13
+        const val LOCK_PACKAGE_NAME = "com.semsx.shoose.system.mobile"
14
+    }
15
+
16
+    private var disableTemp: Boolean = false
17
+
18
+    override fun onInterrupt() {
19
+    }
20
+
21
+    override fun onServiceConnected() {
22
+        super.onServiceConnected()
23
+    }
24
+
25
+    override fun onAccessibilityEvent(event: AccessibilityEvent?) {
26
+        if (event?.packageName == "com.android.settings") {
27
+            if (event.source == null) {
28
+                return
29
+            }
30
+            // WLAN            
31
+            if (event.source?.findAccessibilityNodeInfosByText("WLAN")?.isEmpty() == false
32
+                || event.source?.findAccessibilityNodeInfosByText("Wifi")?.isEmpty() == false
33
+                || event.source?.findAccessibilityNodeInfosByText("Wi-Fi")?.isEmpty() == false
34
+            ) {
35
+                disableTemp = true
36
+                return
37
+            }
38
+        }
39
+        if (disableTemp) {
40
+            // 回到主题界面,恢复检测
41
+            if (event?.packageName == LOCK_PACKAGE_NAME) {
42
+                disableTemp = false
43
+                return
44
+            }
45
+            // 禁用通知栏
46
+            if (event?.packageName == "com.android.systemui") {
47
+                performGlobalAction(GLOBAL_ACTION_HOME)
48
+            }
49
+            return
50
+        }
51
+        if ((getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager).isKeyguardLocked) {
52
+            return
53
+        }
54
+        if (event?.packageName != LOCK_PACKAGE_NAME
55
+            && event?.packageName != packageName
56
+            && event?.packageName != "com.android.systemui"
57
+            && event?.packageName != "android"
58
+        ) {
59
+            disableTemp = false
60
+            performGlobalAction(GLOBAL_ACTION_HOME)
61
+        }
62
+    }
63
+
64
+}

+ 8 - 0
plugins/cordova-plugin-semsx-launcher/src/android/check_window_state.xml

@@ -0,0 +1,8 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
3
+    android:accessibilityEventTypes="typeWindowStateChanged"
4
+    android:accessibilityFeedbackType="feedbackGeneric"
5
+    android:accessibilityFlags="flagDefault"
6
+    android:canRetrieveWindowContent="true"
7
+    android:notificationTimeout="100"
8
+    android:description="@string/check_window" />

+ 37 - 0
plugins/cordova-plugin-whitelist/CONTRIBUTING.md

@@ -0,0 +1,37 @@
1
+<!--
2
+#
3
+# Licensed to the Apache Software Foundation (ASF) under one
4
+# or more contributor license agreements.  See the NOTICE file
5
+# distributed with this work for additional information
6
+# regarding copyright ownership.  The ASF licenses this file
7
+# to you under the Apache License, Version 2.0 (the
8
+# "License"); you may not use this file except in compliance
9
+# with the License.  You may obtain a copy of the License at
10
+#
11
+# http://www.apache.org/licenses/LICENSE-2.0
12
+#
13
+# Unless required by applicable law or agreed to in writing,
14
+# software distributed under the License is distributed on an
15
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+#  KIND, either express or implied.  See the License for the
17
+# specific language governing permissions and limitations
18
+# under the License.
19
+#
20
+-->
21
+
22
+# Contributing to Apache Cordova
23
+
24
+Anyone can contribute to Cordova. And we need your contributions.
25
+
26
+There are multiple ways to contribute: report bugs, improve the docs, and
27
+contribute code.
28
+
29
+For instructions on this, start with the
30
+[contribution overview](http://cordova.apache.org/contribute/).
31
+
32
+The details are explained there, but the important items are:
33
+ - Sign and submit an Apache ICLA (Contributor License Agreement).
34
+ - Have a Jira issue open that corresponds to your contribution.
35
+ - Run the tests so your patch doesn't break existing functionality.
36
+
37
+We look forward to your contributions!

+ 202 - 0
plugins/cordova-plugin-whitelist/LICENSE

@@ -0,0 +1,202 @@
1
+
2
+                                 Apache License
3
+                           Version 2.0, January 2004
4
+                        http://www.apache.org/licenses/
5
+
6
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+   1. Definitions.
9
+
10
+      "License" shall mean the terms and conditions for use, reproduction,
11
+      and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+      "Licensor" shall mean the copyright owner or entity authorized by
14
+      the copyright owner that is granting the License.
15
+
16
+      "Legal Entity" shall mean the union of the acting entity and all
17
+      other entities that control, are controlled by, or are under common
18
+      control with that entity. For the purposes of this definition,
19
+      "control" means (i) the power, direct or indirect, to cause the
20
+      direction or management of such entity, whether by contract or
21
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+      outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+      "You" (or "Your") shall mean an individual or Legal Entity
25
+      exercising permissions granted by this License.
26
+
27
+      "Source" form shall mean the preferred form for making modifications,
28
+      including but not limited to software source code, documentation
29
+      source, and configuration files.
30
+
31
+      "Object" form shall mean any form resulting from mechanical
32
+      transformation or translation of a Source form, including but
33
+      not limited to compiled object code, generated documentation,
34
+      and conversions to other media types.
35
+
36
+      "Work" shall mean the work of authorship, whether in Source or
37
+      Object form, made available under the License, as indicated by a
38
+      copyright notice that is included in or attached to the work
39
+      (an example is provided in the Appendix below).
40
+
41
+      "Derivative Works" shall mean any work, whether in Source or Object
42
+      form, that is based on (or derived from) the Work and for which the
43
+      editorial revisions, annotations, elaborations, or other modifications
44
+      represent, as a whole, an original work of authorship. For the purposes
45
+      of this License, Derivative Works shall not include works that remain
46
+      separable from, or merely link (or bind by name) to the interfaces of,
47
+      the Work and Derivative Works thereof.
48
+
49
+      "Contribution" shall mean any work of authorship, including
50
+      the original version of the Work and any modifications or additions
51
+      to that Work or Derivative Works thereof, that is intentionally
52
+      submitted to Licensor for inclusion in the Work by the copyright owner
53
+      or by an individual or Legal Entity authorized to submit on behalf of
54
+      the copyright owner. For the purposes of this definition, "submitted"
55
+      means any form of electronic, verbal, or written communication sent
56
+      to the Licensor or its representatives, including but not limited to
57
+      communication on electronic mailing lists, source code control systems,
58
+      and issue tracking systems that are managed by, or on behalf of, the
59
+      Licensor for the purpose of discussing and improving the Work, but
60
+      excluding communication that is conspicuously marked or otherwise
61
+      designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+      "Contributor" shall mean Licensor and any individual or Legal Entity
64
+      on behalf of whom a Contribution has been received by Licensor and
65
+      subsequently incorporated within the Work.
66
+
67
+   2. Grant of Copyright License. Subject to the terms and conditions of
68
+      this License, each Contributor hereby grants to You a perpetual,
69
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+      copyright license to reproduce, prepare Derivative Works of,
71
+      publicly display, publicly perform, sublicense, and distribute the
72
+      Work and such Derivative Works in Source or Object form.
73
+
74
+   3. Grant of Patent License. Subject to the terms and conditions of
75
+      this License, each Contributor hereby grants to You a perpetual,
76
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+      (except as stated in this section) patent license to make, have made,
78
+      use, offer to sell, sell, import, and otherwise transfer the Work,
79
+      where such license applies only to those patent claims licensable
80
+      by such Contributor that are necessarily infringed by their
81
+      Contribution(s) alone or by combination of their Contribution(s)
82
+      with the Work to which such Contribution(s) was submitted. If You
83
+      institute patent litigation against any entity (including a
84
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+      or a Contribution incorporated within the Work constitutes direct
86
+      or contributory patent infringement, then any patent licenses
87
+      granted to You under this License for that Work shall terminate
88
+      as of the date such litigation is filed.
89
+
90
+   4. Redistribution. You may reproduce and distribute copies of the
91
+      Work or Derivative Works thereof in any medium, with or without
92
+      modifications, and in Source or Object form, provided that You
93
+      meet the following conditions:
94
+
95
+      (a) You must give any other recipients of the Work or
96
+          Derivative Works a copy of this License; and
97
+
98
+      (b) You must cause any modified files to carry prominent notices
99
+          stating that You changed the files; and
100
+
101
+      (c) You must retain, in the Source form of any Derivative Works
102
+          that You distribute, all copyright, patent, trademark, and
103
+          attribution notices from the Source form of the Work,
104
+          excluding those notices that do not pertain to any part of
105
+          the Derivative Works; and
106
+
107
+      (d) If the Work includes a "NOTICE" text file as part of its
108
+          distribution, then any Derivative Works that You distribute must
109
+          include a readable copy of the attribution notices contained
110
+          within such NOTICE file, excluding those notices that do not
111
+          pertain to any part of the Derivative Works, in at least one
112
+          of the following places: within a NOTICE text file distributed
113
+          as part of the Derivative Works; within the Source form or
114
+          documentation, if provided along with the Derivative Works; or,
115
+          within a display generated by the Derivative Works, if and
116
+          wherever such third-party notices normally appear. The contents
117
+          of the NOTICE file are for informational purposes only and
118
+          do not modify the License. You may add Your own attribution
119
+          notices within Derivative Works that You distribute, alongside
120
+          or as an addendum to the NOTICE text from the Work, provided
121
+          that such additional attribution notices cannot be construed
122
+          as modifying the License.
123
+
124
+      You may add Your own copyright statement to Your modifications and
125
+      may provide additional or different license terms and conditions
126
+      for use, reproduction, or distribution of Your modifications, or
127
+      for any such Derivative Works as a whole, provided Your use,
128
+      reproduction, and distribution of the Work otherwise complies with
129
+      the conditions stated in this License.
130
+
131
+   5. Submission of Contributions. Unless You explicitly state otherwise,
132
+      any Contribution intentionally submitted for inclusion in the Work
133
+      by You to the Licensor shall be under the terms and conditions of
134
+      this License, without any additional terms or conditions.
135
+      Notwithstanding the above, nothing herein shall supersede or modify
136
+      the terms of any separate license agreement you may have executed
137
+      with Licensor regarding such Contributions.
138
+
139
+   6. Trademarks. This License does not grant permission to use the trade
140
+      names, trademarks, service marks, or product names of the Licensor,
141
+      except as required for reasonable and customary use in describing the
142
+      origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+   7. Disclaimer of Warranty. Unless required by applicable law or
145
+      agreed to in writing, Licensor provides the Work (and each
146
+      Contributor provides its Contributions) on an "AS IS" BASIS,
147
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+      implied, including, without limitation, any warranties or conditions
149
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+      PARTICULAR PURPOSE. You are solely responsible for determining the
151
+      appropriateness of using or redistributing the Work and assume any
152
+      risks associated with Your exercise of permissions under this License.
153
+
154
+   8. Limitation of Liability. In no event and under no legal theory,
155
+      whether in tort (including negligence), contract, or otherwise,
156
+      unless required by applicable law (such as deliberate and grossly
157
+      negligent acts) or agreed to in writing, shall any Contributor be
158
+      liable to You for damages, including any direct, indirect, special,
159
+      incidental, or consequential damages of any character arising as a
160
+      result of this License or out of the use or inability to use the
161
+      Work (including but not limited to damages for loss of goodwill,
162
+      work stoppage, computer failure or malfunction, or any and all
163
+      other commercial damages or losses), even if such Contributor
164
+      has been advised of the possibility of such damages.
165
+
166
+   9. Accepting Warranty or Additional Liability. While redistributing
167
+      the Work or Derivative Works thereof, You may choose to offer,
168
+      and charge a fee for, acceptance of support, warranty, indemnity,
169
+      or other liability obligations and/or rights consistent with this
170
+      License. However, in accepting such obligations, You may act only
171
+      on Your own behalf and on Your sole responsibility, not on behalf
172
+      of any other Contributor, and only if You agree to indemnify,
173
+      defend, and hold each Contributor harmless for any liability
174
+      incurred by, or claims asserted against, such Contributor by reason
175
+      of your accepting any such warranty or additional liability.
176
+
177
+   END OF TERMS AND CONDITIONS
178
+
179
+   APPENDIX: How to apply the Apache License to your work.
180
+
181
+      To apply the Apache License to your work, attach the following
182
+      boilerplate notice, with the fields enclosed by brackets "[]"
183
+      replaced with your own identifying information. (Don't include
184
+      the brackets!)  The text should be enclosed in the appropriate
185
+      comment syntax for the file format. We also recommend that a
186
+      file or class name and description of purpose be included on the
187
+      same "printed page" as the copyright notice for easier
188
+      identification within third-party archives.
189
+
190
+   Copyright [yyyy] [name of copyright owner]
191
+
192
+   Licensed under the Apache License, Version 2.0 (the "License");
193
+   you may not use this file except in compliance with the License.
194
+   You may obtain a copy of the License at
195
+
196
+       http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+   Unless required by applicable law or agreed to in writing, software
199
+   distributed under the License is distributed on an "AS IS" BASIS,
200
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+   See the License for the specific language governing permissions and
202
+   limitations under the License.

+ 5 - 0
plugins/cordova-plugin-whitelist/NOTICE

@@ -0,0 +1,5 @@
1
+Apache Cordova
2
+Copyright 2012 The Apache Software Foundation
3
+
4
+This product includes software developed at
5
+The Apache Software Foundation (http://www.apache.org/).

+ 167 - 0
plugins/cordova-plugin-whitelist/README.md

@@ -0,0 +1,167 @@
1
+---
2
+title: Whitelist
3
+description: Whitelist external content accessible by your app.
4
+---
5
+<!--
6
+# license: Licensed to the Apache Software Foundation (ASF) under one
7
+#         or more contributor license agreements.  See the NOTICE file
8
+#         distributed with this work for additional information
9
+#         regarding copyright ownership.  The ASF licenses this file
10
+#         to you under the Apache License, Version 2.0 (the
11
+#         "License"); you may not use this file except in compliance
12
+#         with the License.  You may obtain a copy of the License at
13
+#
14
+#           http://www.apache.org/licenses/LICENSE-2.0
15
+#
16
+#         Unless required by applicable law or agreed to in writing,
17
+#         software distributed under the License is distributed on an
18
+#         "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19
+#         KIND, either express or implied.  See the License for the
20
+#         specific language governing permissions and limitations
21
+#         under the License.
22
+-->
23
+
24
+# cordova-plugin-whitelist
25
+
26
+This plugin implements a whitelist policy for navigating the application webview on Cordova 4.0
27
+
28
+## Installation
29
+
30
+You can install whitelist plugin with Cordova CLI, from npm:
31
+
32
+```
33
+$ cordova plugin add cordova-plugin-whitelist
34
+$ cordova prepare
35
+```
36
+
37
+## Supported Cordova Platforms
38
+
39
+* Android 4.0.0 or above
40
+
41
+## Navigation Whitelist
42
+
43
+Controls which URLs the WebView itself can be navigated to. Applies to
44
+top-level navigations only.
45
+
46
+By default navigations are only allowed to `file://` URLs. To allow others URLs, you must add `<allow-navigation>` tags to your `config.xml`:
47
+
48
+    <!-- Allow links to example.com -->
49
+    <allow-navigation href="http://example.com/*" />
50
+
51
+    <!-- Wildcards are allowed for the protocol, as a prefix
52
+         to the host, or as a suffix to the path -->
53
+    <allow-navigation href="*://*.example.com/*" />
54
+
55
+    <!-- A wildcard can be used to whitelist the entire network,
56
+         over HTTP and HTTPS.
57
+         *NOT RECOMMENDED* -->
58
+    <allow-navigation href="*" />
59
+
60
+    <!-- The above is equivalent to these three declarations -->
61
+    <allow-navigation href="http://*/*" />
62
+    <allow-navigation href="https://*/*" />
63
+    <allow-navigation href="data:*" />
64
+
65
+Quirks: on Android it also applies to iframes for non-http(s) schemes.
66
+
67
+## Intent Whitelist
68
+
69
+Controls which URLs the app is allowed to ask the system to open.
70
+
71
+In `config.xml`, add `<allow-intent>` tags, like this:
72
+
73
+    <!-- Allow links to web pages to open in a browser -->
74
+    <allow-intent href="http://*/*" />
75
+    <allow-intent href="https://*/*" />
76
+
77
+    <!-- Allow links to example.com to open in a browser -->
78
+    <allow-intent href="http://example.com/*" />
79
+
80
+    <!-- Wildcards are allowed for the protocol, as a prefix
81
+         to the host, or as a suffix to the path -->
82
+    <allow-intent href="*://*.example.com/*" />
83
+
84
+    <!-- Allow SMS links to open messaging app -->
85
+    <allow-intent href="sms:*" />
86
+
87
+    <!-- Allow tel: links to open the dialer -->
88
+    <allow-intent href="tel:*" />
89
+
90
+    <!-- Allow geo: links to open maps -->
91
+    <allow-intent href="geo:*" />
92
+
93
+    <!-- Allow all unrecognized URLs to open installed apps
94
+         *NOT RECOMMENDED* -->
95
+    <allow-intent href="*" />
96
+
97
+Without any `<allow-intent>` tags, no requests to external URLs are allowed. However, the default Cordova application includes a quite liberal set of `allow-intent` entries by default. It is advised to narrow this down based on each app's needs.
98
+
99
+On Android, this equates to sending an intent of type BROWSEABLE.
100
+
101
+This whitelist does not apply to plugins, only hyperlinks and calls to `window.open()`.
102
+
103
+Note: `allow-navigation` takes precedence over `allow-intent`. Allowing navigation to all URLs with `<allow-navigation href="*" />` for example has the side effect of "capturing" all intents, so the webview navigates to them instead of triggering e.g. external apps.
104
+
105
+## Network Request Whitelist
106
+
107
+Controls which network requests (images, XHRs, etc) are allowed to be made (via cordova native hooks).
108
+
109
+Note: We suggest you use a Content Security Policy (see below), which is more secure.  This whitelist is mostly historical for webviews which do not support CSP.
110
+
111
+In `config.xml`, add `<access>` tags, like this:
112
+
113
+    <!-- Allow images, xhrs, etc. to google.com -->
114
+    <access origin="http://google.com" />
115
+    <access origin="https://google.com" />
116
+
117
+    <!-- Access to the subdomain maps.google.com -->
118
+    <access origin="http://maps.google.com" />
119
+
120
+    <!-- Access to all the subdomains on google.com -->
121
+    <access origin="http://*.google.com" />
122
+
123
+    <!-- Enable requests to content: URLs -->
124
+    <access origin="content:///*" />
125
+
126
+    <!-- Don't block any requests -->
127
+    <access origin="*" />
128
+
129
+Without any `<access>` tags, only requests to `file://` URLs are allowed. However, the default Cordova application includes `<access origin="*">` by default.
130
+
131
+Note: Whitelist cannot block network redirects from a whitelisted remote website (i.e. http or https) to a non-whitelisted website. Use CSP rules to mitigate redirects to non-whitelisted websites for webviews that support CSP.
132
+
133
+Quirk: Android also allows requests to https://ssl.gstatic.com/accessibility/javascript/android/ by default, since this is required for TalkBack to function properly.
134
+
135
+### Content Security Policy
136
+
137
+Controls which network requests (images, XHRs, etc) are allowed to be made (via webview directly).
138
+
139
+On Android and iOS, the network request whitelist (see above) is not able to filter all types of requests (e.g. `<video>` & WebSockets are not blocked). So, in addition to the whitelist, you should use a [Content Security Policy](http://content-security-policy.com/) `<meta>` tag on all of your pages.
140
+
141
+On Android, support for CSP within the system webview starts with KitKat (but is available on all versions using Crosswalk WebView).
142
+
143
+Here are some example CSP declarations for your `.html` pages:
144
+
145
+    <!-- Good default declaration:
146
+        * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
147
+        * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
148
+        * Disables use of eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
149
+            * Enable inline JS: add 'unsafe-inline' to default-src
150
+            * Enable eval(): add 'unsafe-eval' to default-src
151
+    -->
152
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">
153
+
154
+    <!-- Allow everything but only from the same origin and foo.com -->
155
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' foo.com">
156
+
157
+    <!-- This policy allows everything (eg CSS, AJAX, object, frame, media, etc) except that 
158
+        * CSS only from the same origin and inline styles,
159
+        * scripts only from the same origin and inline styles, and eval()
160
+    -->
161
+    <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
162
+
163
+    <!-- Allows XHRs only over HTTPS on the same domain. -->
164
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' https:">
165
+
166
+    <!-- Allow iframe to https://cordova.apache.org/ -->
167
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self' https://cordova.apache.org">

+ 87 - 0
plugins/cordova-plugin-whitelist/RELEASENOTES.md

@@ -0,0 +1,87 @@
1
+<!--
2
+#
3
+# Licensed to the Apache Software Foundation (ASF) under one
4
+# or more contributor license agreements.  See the NOTICE file
5
+# distributed with this work for additional information
6
+# regarding copyright ownership.  The ASF licenses this file
7
+# to you under the Apache License, Version 2.0 (the
8
+# "License"); you may not use this file except in compliance
9
+# with the License.  You may obtain a copy of the License at
10
+#
11
+# http://www.apache.org/licenses/LICENSE-2.0
12
+#
13
+# Unless required by applicable law or agreed to in writing,
14
+# software distributed under the License is distributed on an
15
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+#  KIND, either express or implied.  See the License for the
17
+# specific language governing permissions and limitations
18
+# under the License.
19
+#
20
+-->
21
+# Release Notes
22
+
23
+### 1.3.4 (Jun 19, 2019)
24
+
25
+-   chore: manually fix lines breaks to LF ([`d804ef2`](https://github.com/apache/cordova-plugin-whitelist/commit/d804ef2))
26
+-   build: add `.gitattributes` to force LF (instead of possible CRLF on Windows) ([`ed0206b`](https://github.com/apache/cordova-plugin-whitelist/commit/ed0206b))
27
+-   build: add `.npmignore` to remove unneeded files from npm package ([`bf8fea5`](https://github.com/apache/cordova-plugin-whitelist/commit/bf8fea5))
28
+-   test,ci(travis): Tests (extracted from cordova-mobile-spec) ([#38](https://github.com/apache/cordova-plugin-whitelist/issues/38)) ([`e4f17b0`](https://github.com/apache/cordova-plugin-whitelist/commit/e4f17b0))
29
+-   docs: Added information on allow-navigation preceding allow-intent ([#41](https://github.com/apache/cordova-plugin-whitelist/issues/41)) ([`7725fed`](https://github.com/apache/cordova-plugin-whitelist/commit/7725fed))
30
+-   chore(github): Add or update GitHub pull request and issue template ([`86b3ee1`](https://github.com/apache/cordova-plugin-whitelist/commit/86b3ee1))
31
+-   fix: Remove information about cordova-android ([#27](https://github.com/apache/cordova-plugin-whitelist/issues/27)) ([`34ed9d0`](https://github.com/apache/cordova-plugin-whitelist/commit/34ed9d0))
32
+-   docs: remove JIRA link ([`fa78675`](https://github.com/apache/cordova-plugin-whitelist/commit/fa78675))
33
+-   docs: Clarify unconfigured Intent Whitelist behaviour ([#26](https://github.com/apache/cordova-plugin-whitelist/issues/26)) ([`8d3f86b`](https://github.com/apache/cordova-plugin-whitelist/commit/8d3f86b))
34
+
35
+### 1.3.3 (Nov 06, 2017)
36
+* [CB-12847](https://issues.apache.org/jira/browse/CB-12847) added `bugs` entry to `package.json`.
37
+
38
+### 1.3.2 (Feb 28, 2017)
39
+* [CB-12236](https://issues.apache.org/jira/browse/CB-12236) Fixed `RELEASENOTES` for `cordova-plugin-whitelist`
40
+
41
+### 1.3.1 (Dec 07, 2016)
42
+* [CB-12224](https://issues.apache.org/jira/browse/CB-12224) Updated version and RELEASENOTES.md for release 1.3.1
43
+* [CB-11917](https://issues.apache.org/jira/browse/CB-11917) - Remove pull request template checklist item: "iCLA has been submitted…"
44
+* Edit package.json license to match SPDX id
45
+* [CB-11832](https://issues.apache.org/jira/browse/CB-11832) Incremented plugin version.
46
+
47
+### 1.3.0 (Sep 08, 2016)
48
+* [CB-11795](https://issues.apache.org/jira/browse/CB-11795) Add 'protective' entry to cordovaDependencies
49
+* Updated installation section
50
+* Plugin uses `Android Log class` and not `Cordova LOG class`
51
+* Add pull request template.
52
+* [CB-10866](https://issues.apache.org/jira/browse/CB-10866) Adding engine info to `package.json`
53
+* [CB-10996](https://issues.apache.org/jira/browse/CB-10996) Adding front matter to README.md
54
+
55
+### 1.2.2 (Apr 15, 2016)
56
+* add note about redirects
57
+* [CB-10624](https://issues.apache.org/jira/browse/CB-10624) remove error message from `whitelist.js`, which leaves it empty
58
+
59
+### 1.2.1 (Jan 15, 2016)
60
+* [CB-10194](https://issues.apache.org/jira/browse/CB-10194) info tag prints for ios when not applicable
61
+
62
+### 1.2.0 (Nov 18, 2015)
63
+* removed **iOS** engine check from `plugin.xml`
64
+* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest
65
+* [CB-9972](https://issues.apache.org/jira/browse/CB-9972) - Remove **iOS** whitelist
66
+* Updated the text, it should read 4.0.x and greater, since this plugin will be required for `cordova-android 5.0`
67
+* Fixing contribute link.
68
+* Updated `plugin.xml <info>` tag to remove warning about not needing this plugin if you are using the **iOS 9 SDK**
69
+* [CB-9738](https://issues.apache.org/jira/browse/CB-9738) - Disable whitelist use when runtime environment is **iOS 9**
70
+* [CB-9740](https://issues.apache.org/jira/browse/CB-9740) - Add `<info>` tag describing whitelist plugin not needed on `cordova-ios` and cordova-android 3.x`
71
+* [CB-9568](https://issues.apache.org/jira/browse/CB-9568) - Update whitelist plugin to allow all network access by default
72
+* [CB-9337](https://issues.apache.org/jira/browse/CB-9337) - enable use of `<access>` tags for native code network requests
73
+
74
+### 1.1.0 (Jun 17, 2015)
75
+* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-whitelist documentation translation: cordova-plugin-whitelist
76
+* fix npm md issue
77
+* Usage of CDVURLRequestFilter protocol.
78
+* [CB-9089](https://issues.apache.org/jira/browse/CB-9089) - iOS whitelist plugin does not compile
79
+* [CB-9090](https://issues.apache.org/jira/browse/CB-9090) - Enable whitelist plugin for cordova-ios 4.0.0
80
+* Fixed error in Content-Security-Policy example
81
+
82
+### 1.0.0 (Mar 25, 2015)
83
+* [CB-8739](https://issues.apache.org/jira/browse/CB-8739) added missing license headers
84
+* Add @Override to CustomConfigXmlParser methods
85
+* Change ID to cordova-plugin-whitelist rather than reverse-DNS-style
86
+* Tweak CSP examples in README
87
+* [CB-8660](https://issues.apache.org/jira/browse/CB-8660) remove extra commas from package.json

+ 67 - 0
plugins/cordova-plugin-whitelist/package.json

@@ -0,0 +1,67 @@
1
+{
2
+  "_from": "cordova-plugin-whitelist@1",
3
+  "_id": "cordova-plugin-whitelist@1.3.4",
4
+  "_inBundle": false,
5
+  "_integrity": "sha512-EYC5eQFVkoYXq39l7tYKE6lEjHJ04mvTmKXxGL7quHLdFPfJMNzru/UYpn92AOfpl3PQaZmou78C7EgmFOwFQQ==",
6
+  "_location": "/cordova-plugin-whitelist",
7
+  "_phantomChildren": {},
8
+  "_requested": {
9
+    "type": "range",
10
+    "registry": true,
11
+    "raw": "cordova-plugin-whitelist@1",
12
+    "name": "cordova-plugin-whitelist",
13
+    "escapedName": "cordova-plugin-whitelist",
14
+    "rawSpec": "1",
15
+    "saveSpec": null,
16
+    "fetchSpec": "1"
17
+  },
18
+  "_requiredBy": [
19
+    "#DEV:/",
20
+    "#USER"
21
+  ],
22
+  "_resolved": "https://registry.npmjs.org/cordova-plugin-whitelist/-/cordova-plugin-whitelist-1.3.4.tgz",
23
+  "_shasum": "31938545c7c3e7de35c20ab08c2c3afa06e8a3f9",
24
+  "_spec": "cordova-plugin-whitelist@1",
25
+  "_where": "F:\\Workspace\\hello2",
26
+  "author": {
27
+    "name": "Apache Software Foundation"
28
+  },
29
+  "bugs": {
30
+    "url": "https://github.com/apache/cordova-plugin-whitelist/issues"
31
+  },
32
+  "bundleDependencies": false,
33
+  "cordova": {
34
+    "platforms": [
35
+      "android"
36
+    ]
37
+  },
38
+  "deprecated": false,
39
+  "description": "Cordova Whitelist Plugin",
40
+  "engines": {
41
+    "cordovaDependencies": {
42
+      "0.0.0": {
43
+        "cordova-android": ">=4.0.0"
44
+      },
45
+      "2.0.0": {
46
+        "cordova": ">100"
47
+      }
48
+    }
49
+  },
50
+  "homepage": "https://github.com/apache/cordova-plugin-whitelist#readme",
51
+  "keywords": [
52
+    "cordova",
53
+    "whitelist",
54
+    "ecosystem:cordova",
55
+    "cordova-android"
56
+  ],
57
+  "license": "Apache-2.0",
58
+  "name": "cordova-plugin-whitelist",
59
+  "repository": {
60
+    "type": "git",
61
+    "url": "git+https://github.com/apache/cordova-plugin-whitelist.git"
62
+  },
63
+  "scripts": {
64
+    "test": "echo \"no tests implemented for this plugin\""
65
+  },
66
+  "version": "1.3.4"
67
+}

+ 44 - 0
plugins/cordova-plugin-whitelist/plugin.xml

@@ -0,0 +1,44 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!--
3
+  Licensed to the Apache Software Foundation (ASF) under one
4
+  or more contributor license agreements.  See the NOTICE file
5
+  distributed with this work for additional information
6
+  regarding copyright ownership.  The ASF licenses this file
7
+  to you under the Apache License, Version 2.0 (the
8
+  "License"); you may not use this file except in compliance
9
+  with the License.  You may obtain a copy of the License at
10
+
11
+    http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+  Unless required by applicable law or agreed to in writing,
14
+  software distributed under the License is distributed on an
15
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+  KIND, either express or implied.  See the License for the
17
+  specific language governing permissions and limitations
18
+  under the License.
19
+-->
20
+
21
+<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
22
+           id="cordova-plugin-whitelist"
23
+      version="1.3.4">
24
+    <name>Whitelist</name>
25
+    <description>Cordova Network Whitelist Plugin</description>
26
+    <license>Apache 2.0</license>
27
+    <keywords>cordova,whitelist,policy</keywords>
28
+
29
+    <engines>
30
+      <engine name="cordova-android" version=">=4.0.0" />
31
+    </engines>
32
+
33
+    <platform name="android">
34
+        <config-file target="res/xml/config.xml" parent="/*">
35
+            <feature name="Whitelist" >
36
+                <param name="android-package" value="org.apache.cordova.whitelist.WhitelistPlugin"/>
37
+                <param name="onload" value="true" />
38
+            </feature>
39
+        </config-file>
40
+
41
+        <source-file src="src/android/WhitelistPlugin.java" target-dir="src/org/apache/cordova/whitelist" />
42
+    </platform>
43
+
44
+</plugin>

+ 161 - 0
plugins/cordova-plugin-whitelist/src/android/WhitelistPlugin.java

@@ -0,0 +1,161 @@
1
+/*
2
+       Licensed to the Apache Software Foundation (ASF) under one
3
+       or more contributor license agreements.  See the NOTICE file
4
+       distributed with this work for additional information
5
+       regarding copyright ownership.  The ASF licenses this file
6
+       to you under the Apache License, Version 2.0 (the
7
+       "License"); you may not use this file except in compliance
8
+       with the License.  You may obtain a copy of the License at
9
+
10
+         http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+       Unless required by applicable law or agreed to in writing,
13
+       software distributed under the License is distributed on an
14
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+       KIND, either express or implied.  See the License for the
16
+       specific language governing permissions and limitations
17
+       under the License.
18
+*/
19
+
20
+package org.apache.cordova.whitelist;
21
+
22
+import org.apache.cordova.CordovaPlugin;
23
+import org.apache.cordova.ConfigXmlParser;
24
+import org.apache.cordova.LOG;
25
+import org.apache.cordova.Whitelist;
26
+import org.xmlpull.v1.XmlPullParser;
27
+
28
+import android.content.Context;
29
+
30
+public class WhitelistPlugin extends CordovaPlugin {
31
+    private static final String LOG_TAG = "WhitelistPlugin";
32
+    private Whitelist allowedNavigations;
33
+    private Whitelist allowedIntents;
34
+    private Whitelist allowedRequests;
35
+
36
+    // Used when instantiated via reflection by PluginManager
37
+    public WhitelistPlugin() {
38
+    }
39
+    // These can be used by embedders to allow Java-configuration of whitelists.
40
+    public WhitelistPlugin(Context context) {
41
+        this(new Whitelist(), new Whitelist(), null);
42
+        new CustomConfigXmlParser().parse(context);
43
+    }
44
+    public WhitelistPlugin(XmlPullParser xmlParser) {
45
+        this(new Whitelist(), new Whitelist(), null);
46
+        new CustomConfigXmlParser().parse(xmlParser);
47
+    }
48
+    public WhitelistPlugin(Whitelist allowedNavigations, Whitelist allowedIntents, Whitelist allowedRequests) {
49
+        if (allowedRequests == null) {
50
+            allowedRequests = new Whitelist();
51
+            allowedRequests.addWhiteListEntry("file:///*", false);
52
+            allowedRequests.addWhiteListEntry("data:*", false);
53
+        }
54
+        this.allowedNavigations = allowedNavigations;
55
+        this.allowedIntents = allowedIntents;
56
+        this.allowedRequests = allowedRequests;
57
+    }
58
+    @Override
59
+    public void pluginInitialize() {
60
+        if (allowedNavigations == null) {
61
+            allowedNavigations = new Whitelist();
62
+            allowedIntents = new Whitelist();
63
+            allowedRequests = new Whitelist();
64
+            new CustomConfigXmlParser().parse(webView.getContext());
65
+        }
66
+    }
67
+
68
+    private class CustomConfigXmlParser extends ConfigXmlParser {
69
+        @Override
70
+        public void handleStartTag(XmlPullParser xml) {
71
+            String strNode = xml.getName();
72
+            if (strNode.equals("content")) {
73
+                String startPage = xml.getAttributeValue(null, "src");
74
+                allowedNavigations.addWhiteListEntry(startPage, false);
75
+            } else if (strNode.equals("allow-navigation")) {
76
+                String origin = xml.getAttributeValue(null, "href");
77
+                if ("*".equals(origin)) {
78
+                    allowedNavigations.addWhiteListEntry("http://*/*", false);
79
+                    allowedNavigations.addWhiteListEntry("https://*/*", false);
80
+                    allowedNavigations.addWhiteListEntry("data:*", false);
81
+                } else {
82
+                    allowedNavigations.addWhiteListEntry(origin, false);
83
+                }
84
+            } else if (strNode.equals("allow-intent")) {
85
+                String origin = xml.getAttributeValue(null, "href");
86
+                allowedIntents.addWhiteListEntry(origin, false);
87
+            } else if (strNode.equals("access")) {
88
+                String origin = xml.getAttributeValue(null, "origin");
89
+                String subdomains = xml.getAttributeValue(null, "subdomains");
90
+                boolean external = (xml.getAttributeValue(null, "launch-external") != null);
91
+                if (origin != null) {
92
+                    if (external) {
93
+                        LOG.w(LOG_TAG, "Found <access launch-external> within config.xml. Please use <allow-intent> instead.");
94
+                        allowedIntents.addWhiteListEntry(origin, (subdomains != null) && (subdomains.compareToIgnoreCase("true") == 0));
95
+                    } else {
96
+                        if ("*".equals(origin)) {
97
+                            allowedRequests.addWhiteListEntry("http://*/*", false);
98
+                            allowedRequests.addWhiteListEntry("https://*/*", false);
99
+                        } else {
100
+                            allowedRequests.addWhiteListEntry(origin, (subdomains != null) && (subdomains.compareToIgnoreCase("true") == 0));
101
+                        }
102
+                    }
103
+                }
104
+            }
105
+        }
106
+        @Override
107
+        public void handleEndTag(XmlPullParser xml) {
108
+        }
109
+    }
110
+
111
+    @Override
112
+    public Boolean shouldAllowNavigation(String url) {
113
+        if (allowedNavigations.isUrlWhiteListed(url)) {
114
+            return true;
115
+        }
116
+        return null; // Default policy
117
+    }
118
+
119
+    @Override
120
+    public Boolean shouldAllowRequest(String url) {
121
+        if (Boolean.TRUE == shouldAllowNavigation(url)) {
122
+            return true;
123
+        }
124
+        if (allowedRequests.isUrlWhiteListed(url)) {
125
+            return true;
126
+        }
127
+        return null; // Default policy
128
+    }
129
+
130
+    @Override
131
+    public Boolean shouldOpenExternalUrl(String url) {
132
+        if (allowedIntents.isUrlWhiteListed(url)) {
133
+            return true;
134
+        }
135
+        return null; // Default policy
136
+    }
137
+
138
+    public Whitelist getAllowedNavigations() {
139
+        return allowedNavigations;
140
+    }
141
+
142
+    public void setAllowedNavigations(Whitelist allowedNavigations) {
143
+        this.allowedNavigations = allowedNavigations;
144
+    }
145
+
146
+    public Whitelist getAllowedIntents() {
147
+        return allowedIntents;
148
+    }
149
+
150
+    public void setAllowedIntents(Whitelist allowedIntents) {
151
+        this.allowedIntents = allowedIntents;
152
+    }
153
+
154
+    public Whitelist getAllowedRequests() {
155
+        return allowedRequests;
156
+    }
157
+
158
+    public void setAllowedRequests(Whitelist allowedRequests) {
159
+        this.allowedRequests = allowedRequests;
160
+    }
161
+}

+ 53 - 0
plugins/cordova-plugin-whitelist/tests/README.md

@@ -0,0 +1,53 @@
1
+---
2
+ license: Licensed to the Apache Software Foundation (ASF) under one
3
+         or more contributor license agreements.  See the NOTICE file
4
+         distributed with this work for additional information
5
+         regarding copyright ownership.  The ASF licenses this file
6
+         to you under the Apache License, Version 2.0 (the
7
+         "License"); you may not use this file except in compliance
8
+         with the License.  You may obtain a copy of the License at
9
+
10
+           http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+         Unless required by applicable law or agreed to in writing,
13
+         software distributed under the License is distributed on an
14
+         "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+         KIND, either express or implied.  See the License for the
16
+         specific language governing permissions and limitations
17
+         under the License.
18
+---
19
+
20
+# cordova-plugin-whitelist-tests
21
+
22
+This are an [optional JavaScript interface](#whitelist) to the core Cordova Whitelist functionality and the test plugin that uses it to test cordova-plugin-whitelist.
23
+
24
+## Whitelist
25
+
26
+> The `whitelist` object provides an interface for testing whether arbitrary
27
+> URLs are allowed by the currently active configuration, or would be allowed
28
+> by a given set of whitelist patterns.
29
+
30
+### Methods
31
+
32
+- cordova.whitelist.match
33
+- cordova.whitelist.test
34
+
35
+#### cordova.whitelist.match
36
+
37
+Indicates whether a given URL would be allowed by a set of Whitelist URL
38
+patterns.
39
+
40
+    cordova.whitelist.match(url, patterns, callback);
41
+
42
+`callback` will be invoked with a boolean argument indicating whether the
43
+url matches the set of patterns.
44
+
45
+#### cordova.whitelist.test
46
+
47
+Indicates whether a given URL would be allowed by the current application
48
+configuration.
49
+
50
+    cordova.whitelist.test(url, callback);
51
+
52
+`callback` will be invoked with a boolean argument indicating whether the
53
+url is currently whitelisted.

+ 15 - 0
plugins/cordova-plugin-whitelist/tests/package.json

@@ -0,0 +1,15 @@
1
+{
2
+  "name": "cordova-plugin-whitelist-tests",
3
+  "version": "1.3.4",
4
+  "description": "",
5
+  "cordova": {
6
+    "id": "cordova-plugin-whitelist-tests",
7
+    "platforms": []
8
+  },
9
+  "keywords": [
10
+    "ecosystem:cordova"
11
+  ],
12
+  "author": "",
13
+  "license": "Apache 2.0"
14
+}
15
+

+ 56 - 0
plugins/cordova-plugin-whitelist/tests/plugin.xml

@@ -0,0 +1,56 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+
3
+<!--
4
+  Licensed to the Apache Software Foundation (ASF) under one
5
+  or more contributor license agreements.  See the NOTICE file
6
+  distributed with this work for additional information
7
+  regarding copyright ownership.  The ASF licenses this file
8
+  to you under the Apache License, Version 2.0 (the
9
+  "License"); you may not use this file except in compliance
10
+  with the License.  You may obtain a copy of the License at
11
+
12
+    http://www.apache.org/licenses/LICENSE-2.0
13
+
14
+  Unless required by applicable law or agreed to in writing,
15
+  software distributed under the License is distributed on an
16
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17
+  KIND, either express or implied.  See the License for the
18
+  specific language governing permissions and limitations
19
+  under the License.
20
+-->
21
+
22
+<plugin xmlns="http://cordova.apache.org/ns/plugins/1.0"
23
+           id="cordova-plugin-whitelist-tests"
24
+      version="1.3.4">
25
+    <name>Cordova Plugin Whitelist Tests</name>
26
+    <license>Apache 2.0</license>
27
+
28
+    <js-module src="tests.js" name="tests">
29
+    </js-module>
30
+    
31
+    <js-module src="www/whitelist.js" name="whitelist">
32
+        <clobbers target="cordova.whitelist" />
33
+    </js-module>
34
+
35
+    <!-- android -->
36
+    <platform name="android">
37
+        <config-file target="res/xml/config.xml" parent="/*">
38
+            <feature name="WhitelistAPI" >
39
+                <param name="android-package" value="org.apache.cordova.test.WhitelistAPI"/>
40
+            </feature>
41
+        </config-file>
42
+
43
+        <source-file src="src/android/WhitelistAPI.java" target-dir="src/org/apache/cordova/test" />
44
+
45
+        <!-- remove <access origin="*" /> -->
46
+        <hook type="after_prepare" src="scripts/remove-access.js"/>
47
+
48
+        <!-- add whitelist configuration the tests test for -->
49
+        <config-file target="config.xml" parent="/*">
50
+            <allow-navigation href="http://*.apache.org" />
51
+            <allow-navigation href="https://*.apache.org" />
52
+        </config-file>
53
+
54
+    </platform>
55
+
56
+</plugin>

+ 19 - 0
plugins/cordova-plugin-whitelist/tests/scripts/remove-access.js

@@ -0,0 +1,19 @@
1
+var fs = require('fs');
2
+var path = require('path');
3
+var rootdir = "";
4
+var file = path.join(rootdir, "platforms/android/app/src/main/res/xml/config.xml");
5
+
6
+fs.readFile( file, "utf8", function( err, data )
7
+{
8
+    if (err)
9
+        return console.log( err );
10
+
11
+    var result = data;
12
+    result = result.replace( "<access origin=\"*\" />", "" );
13
+
14
+    fs.writeFile( file, result, "utf8", function( err )
15
+    {
16
+        if (err)
17
+            return console.log( err );
18
+    } );
19
+} );

+ 90 - 0
plugins/cordova-plugin-whitelist/tests/src/android/WhitelistAPI.java

@@ -0,0 +1,90 @@
1
+/*
2
+       Licensed to the Apache Software Foundation (ASF) under one
3
+       or more contributor license agreements.  See the NOTICE file
4
+       distributed with this work for additional information
5
+       regarding copyright ownership.  The ASF licenses this file
6
+       to you under the Apache License, Version 2.0 (the
7
+       "License"); you may not use this file except in compliance
8
+       with the License.  You may obtain a copy of the License at
9
+
10
+         http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+       Unless required by applicable law or agreed to in writing,
13
+       software distributed under the License is distributed on an
14
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+       KIND, either express or implied.  See the License for the
16
+       specific language governing permissions and limitations
17
+       under the License.
18
+*/
19
+package org.apache.cordova.test;
20
+
21
+import org.apache.cordova.Whitelist;
22
+import org.apache.cordova.Config;
23
+
24
+import org.apache.cordova.CallbackContext;
25
+import org.apache.cordova.CordovaPlugin;
26
+import org.apache.cordova.PluginResult;
27
+import org.json.JSONArray;
28
+import org.json.JSONException;
29
+
30
+import org.apache.cordova.PluginManager;
31
+import java.lang.reflect.InvocationTargetException;
32
+import java.lang.reflect.Method;
33
+
34
+public class WhitelistAPI extends CordovaPlugin {
35
+    /**
36
+     * Executes the request and returns PluginResult.
37
+     *
38
+     * @param action            The action to execute.
39
+     * @param args              JSONArry of arguments for the plugin.
40
+     * @param callbackContext   The callback id used when calling back into JavaScript.
41
+     * @return                  True if the action was valid, false if not.
42
+     */
43
+    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
44
+        if (action.equals("URLMatchesPatterns")) {
45
+            String url = args.getString(0);
46
+            JSONArray patterns = args.getJSONArray(1);
47
+            Whitelist whitelist = new Whitelist();
48
+            for (int i=0; i < patterns.length(); i++) {
49
+                String pattern = patterns.getString(i);
50
+                whitelist.addWhiteListEntry(pattern, false);
51
+            }
52
+            boolean isAllowed = whitelist.isUrlWhiteListed(url);
53
+            callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, isAllowed));
54
+            return true;
55
+        } else if (action.equals("URLIsAllowed")) {
56
+            String url = args.getString(0);
57
+            /* This code exists for compatibility between 3.x and 4.x versions of Cordova.
58
+             * Previously the CordovaWebView class had a method, getWhitelist, which would
59
+             * return a Whitelist object. Since the fixed whitelist is removed in Cordova 4.x,
60
+             * the correct call now is to shouldAllowRequest from the plugin manager.
61
+             */
62
+            Boolean isAllowed = null;
63
+            try {
64
+                Method isUrlWhiteListed = Config.class.getDeclaredMethod("isUrlWhitelisted", String.class);
65
+                isAllowed = (Boolean)isUrlWhiteListed.invoke(url);
66
+            } catch (NoSuchMethodException e) {
67
+            } catch (IllegalAccessException e) {
68
+            } catch (InvocationTargetException e) {
69
+            }
70
+            if (isAllowed == null) {
71
+                try {
72
+                    Method gpm = webView.getClass().getMethod("getPluginManager");
73
+                    PluginManager pm = (PluginManager)gpm.invoke(webView);
74
+                    Method isAllowedMethod = pm.getClass().getMethod("shouldAllowRequest", String.class);
75
+                    isAllowed = (Boolean)isAllowedMethod.invoke(pm, url);
76
+                    if (isAllowed == null) {
77
+                        isAllowed = false;
78
+                    }
79
+                } catch (NoSuchMethodException e) {
80
+                } catch (IllegalAccessException e) {
81
+                } catch (InvocationTargetException e) {
82
+                }
83
+            }
84
+
85
+            callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, isAllowed));
86
+            return true;
87
+        }
88
+        return false;
89
+    }
90
+}

+ 214 - 0
plugins/cordova-plugin-whitelist/tests/tests.js

@@ -0,0 +1,214 @@
1
+/*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements.  See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership.  The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License.  You may obtain a copy of the License at
9
+ *
10
+ *   http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied.  See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ *
19
+ */
20
+
21
+exports.defineAutoTests = function () {
22
+
23
+    var isAndroid = (cordova.platformId === "android");
24
+
25
+    describe('Whitelist API (cordova.whitelist)', function () {
26
+
27
+        it("should exist", function () {
28
+            expect(cordova.whitelist).toBeDefined();
29
+        });
30
+
31
+        describe("Match function (cordova.whitelist.match) that checks URLs against patterns", function () {
32
+            function expectMatchWithResult(result) {
33
+                return (function (url, patterns, description) {
34
+                    description = description || ((result ? "should accept " : "should reject ") + url + " for " + JSON.stringify(patterns));
35
+                    this.result = result;
36
+
37
+                    describe("Match function", function () {
38
+                        if (!isAndroid) {
39
+                            pending("Whitelist Plugin only exists for Android");
40
+                        }
41
+
42
+                        // Timeout is 7.5 seconds to allow physical devices enough
43
+                        // time to query the response. This is important for some
44
+                        // Android devices.
45
+                        var originalTimeout,
46
+                            cb;
47
+
48
+                        beforeEach(function (done) {
49
+                            originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
50
+                            jasmine.DEFAULT_TIMEOUT_INTERVAL = 7500;
51
+                            
52
+                            cb = jasmine.createSpy('spy').and.callFake(function () {
53
+                                done();
54
+                            });
55
+                            cordova.whitelist.match(url, patterns, cb);
56
+                        });
57
+
58
+                        afterEach(function () {
59
+                            jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
60
+                        });
61
+
62
+                        it(description, function () {
63
+                            expect(cb).toHaveBeenCalledWith(result);
64
+                        });
65
+                    });
66
+                });
67
+            }
68
+
69
+            var itShouldMatch = expectMatchWithResult(true);
70
+            var itShouldNotMatch = expectMatchWithResult(false);
71
+
72
+            it("should exist", function () {
73
+                expect(cordova.whitelist.match).toBeDefined();
74
+                expect(typeof cordova.whitelist.match).toBe("function");
75
+            });
76
+
77
+            itShouldMatch('http://www.apache.org/',     ['*'],  "should accept any domain for *");
78
+            itShouldNotMatch('http://www.apache.org/',  [],     "should not accept any domain for []");
79
+
80
+            itShouldMatch('http://apache.org/',                                             ['http://*.apache.org']);
81
+            itShouldMatch('http://www.apache.org/',                                         ['http://*.apache.org']);
82
+            itShouldMatch('http://www.apache.org/some/path',                                ['http://*.apache.org']);
83
+            itShouldMatch('http://some.domain.under.apache.org/',                           ['http://*.apache.org']);
84
+            itShouldMatch('http://user:pass@apache.org/',                                   ['http://*.apache.org']);
85
+            itShouldMatch('http://user:pass@www.apache.org/',                               ['http://*.apache.org']);
86
+            itShouldMatch('http://www.apache.org/?some=params',                             ['http://*.apache.org']);
87
+            itShouldNotMatch('http://apache.com/',                                          ['http://*.apache.org']);
88
+            itShouldNotMatch('http://www.evil.com/?url=www.apache.org',                     ['http://*.apache.org']);
89
+            itShouldNotMatch('http://www.evil.com/?url=http://www.apache.org',              ['http://*.apache.org']);
90
+            itShouldNotMatch('http://www.evil.com/?url=http%3A%2F%2Fwww%2Eapache%2Eorg',    ['http://*.apache.org']);
91
+            itShouldNotMatch('https://apache.org/',                                         ['http://*.apache.org']);
92
+            itShouldNotMatch('http://www.apache.org:pass@evil.com/',                        ['http://*.apache.org']);
93
+            itShouldNotMatch('http://www.apache.org.evil.com/',                             ['http://*.apache.org']);
94
+
95
+            itShouldMatch('http://www.apache.org/',     ['http://*.apache.org', 'https://*.apache.org']);
96
+            itShouldMatch('https://www.apache.org/',    ['http://*.apache.org', 'https://*.apache.org']);
97
+            itShouldNotMatch('ftp://www.apache.org/',   ['http://*.apache.org', 'https://*.apache.org']);
98
+            itShouldNotMatch('http://www.apache.com/',  ['http://*.apache.org', 'https://*.apache.org']);
99
+
100
+            itShouldMatch('http://www.apache.org/',         ['http://www.apache.org']);
101
+            itShouldNotMatch('http://build.apache.org/',    ['http://www.apache.org']);
102
+            itShouldNotMatch('http://apache.org/',          ['http://www.apache.org']);
103
+
104
+            itShouldMatch('http://www.apache.org/',             ['http://*/*']);
105
+            itShouldMatch('http://www.apache.org/foo/bar.html', ['http://*/*']);
106
+
107
+            itShouldMatch('http://www.apache.org/foo',          ['http://*/foo*']);
108
+            itShouldMatch('http://www.apache.org/foo/bar.html', ['http://*/foo*']);
109
+            itShouldNotMatch('http://www.apache.org/',          ['http://*/foo*']);
110
+
111
+            itShouldMatch('file:///foo', ['file:///*']);
112
+
113
+            itShouldMatch('file:///foo',                ['file:///foo*']);
114
+            itShouldMatch('file:///foo/bar.html',       ['file:///foo*']);
115
+            itShouldNotMatch('file:///foo.html',        []);
116
+            itShouldNotMatch('http://www.apache.org/etc/foo',   ['http://www.apache.org/foo*']);
117
+            itShouldNotMatch('http://www.apache.org/foo',       ['file:///foo*']);
118
+
119
+            itShouldMatch('http://www.apache.org/',     ['*://www.apache.org/*']);
120
+            itShouldMatch('https://www.apache.org/',    ['*://www.apache.org/*']);
121
+            itShouldMatch('ftp://www.apache.org/',      ['*://www.apache.org/*']);
122
+            itShouldMatch('file://www.apache.org/',     ['*://www.apache.org/*']);
123
+            if (cordova.platformId == 'android')
124
+                itShouldMatch('content://www.apache.org/', ['*://www.apache.org/*']);
125
+            itShouldMatch('foo://www.apache.org/',      ['*://www.apache.org/*']);
126
+            itShouldNotMatch('http://www.apache.com/',  ['*://www.apache.org/*']);
127
+
128
+            itShouldMatch('http://www.apache.org/',     ['*.apache.org']);
129
+            itShouldMatch('https://www.apache.org/',    ['*.apache.org']);
130
+            itShouldNotMatch('ftp://www.apache.org/',   ['*.apache.org']);
131
+
132
+            itShouldMatch('http://www.apache.org:81/',                          ['http://www.apache.org:81/*']);
133
+            itShouldMatch('http://user:pass@www.apache.org:81/foo/bar.html',    ['http://www.apache.org:81/*']);
134
+            itShouldNotMatch('http://www.apache.org:80/',                       ['http://www.apache.org:81/*']);
135
+            itShouldNotMatch('http://www.apache.org/',                          ['http://www.apache.org:81/*']);
136
+            itShouldNotMatch('http://www.apache.org:foo/',                      ['http://www.apache.org:81/*']);
137
+            itShouldNotMatch('http://www.apache.org:81@www.apache.org/',        ['http://www.apache.org:81/*']);
138
+            itShouldNotMatch('http://www.apache.org:81@www.evil.com/',          ['http://www.apache.org:81/*']);
139
+
140
+            itShouldMatch('http://www.APAche.org/', ['*.apache.org']);
141
+            itShouldMatch('http://WWw.apache.org/', ['*.apache.org']);
142
+            itShouldMatch('http://www.apache.org/', ['*.APACHE.ORG']);
143
+            itShouldMatch('HTTP://www.apache.org/', ['*.apache.org']);
144
+            itShouldMatch('HTTP://www.apache.org/', ['http://*.apache.org']);
145
+            itShouldMatch('http://www.apache.org/', ['HTTP://*.apache.org']);
146
+
147
+            itShouldMatch('http://www.apache.org/foo/',         ['*://*.apache.org/foo/*']);
148
+            itShouldMatch('http://www.apache.org/foo/bar',      ['*://*.apache.org/foo/*']);
149
+            itShouldNotMatch('http://www.apache.org/bar/foo/',  ['*://*.apache.org/foo/*']);
150
+            itShouldNotMatch('http://www.apache.org/Foo/',      ['*://*.apache.org/foo/*']);
151
+            itShouldNotMatch('http://www.apache.org/Foo/bar',   ['*://*.apache.org/foo/*']);
152
+        });
153
+
154
+        describe("Test function (cordova.whitelist.test) that checks against config.xml", function () {
155
+            function expectTestWithResult(result) {
156
+                return (function (url, description) {
157
+                    description = description || ((result ? "should accept " : "should reject ") + url);
158
+
159
+                    describe("Test function", function () {
160
+                        if (!isAndroid) {
161
+                            pending("Whitelist Plugin only exists for Android");
162
+                        }
163
+
164
+                        var cb,
165
+                            originalTimeout;
166
+
167
+                        beforeEach(function (done) {
168
+                            originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
169
+                            jasmine.DEFAULT_TIMEOUT_INTERVAL = 7500;
170
+                            cb = jasmine.createSpy('spy').and.callFake(function (){
171
+                                done();
172
+                            });
173
+                            cordova.whitelist.test(url, cb);
174
+                        });
175
+
176
+                        afterEach(function () {
177
+                            jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
178
+                        });
179
+
180
+                        it(description, function () {
181
+                            expect(cb).toHaveBeenCalledWith(result);
182
+                        });
183
+                    });
184
+                });
185
+            }
186
+
187
+            var itShouldAccept = expectTestWithResult(true);
188
+            var itShouldReject = expectTestWithResult(false);
189
+
190
+            it("should exist", function () {
191
+                expect(cordova.whitelist.test).toBeDefined();
192
+                expect(typeof cordova.whitelist.test).toBe("function");
193
+            });
194
+
195
+            itShouldAccept('http://apache.org');
196
+            itShouldAccept('http://apache.org/');
197
+            itShouldAccept('http://www.apache.org/');
198
+            itShouldAccept('http://www.apache.org/some/path');
199
+            itShouldAccept('http://some.domain.under.apache.org/');
200
+            itShouldAccept('http://user:pass@apache.org/');
201
+            itShouldAccept('http://user:pass@www.apache.org/');
202
+            itShouldAccept('https://www.apache.org/');
203
+
204
+            itShouldReject('ftp://www.apache.org/');
205
+            itShouldReject('http://www.apache.com/');
206
+            itShouldReject('http://www.apache.org:pass@evil.com/');
207
+            itShouldReject('http://www.apache.org.evil.com/');
208
+
209
+            itShouldAccept('file:///foo');
210
+            if (cordova.platformId == 'android')
211
+                itShouldReject('content:///foo');
212
+        });
213
+    });
214
+}

+ 34 - 0
plugins/cordova-plugin-whitelist/tests/www/whitelist.js

@@ -0,0 +1,34 @@
1
+/*
2
+ *
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements.  See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership.  The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License.  You may obtain a copy of the License at
10
+ *
11
+ *   http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied.  See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+*/
21
+
22
+var argscheck = require('cordova/argscheck'),
23
+    exec = require('cordova/exec');
24
+
25
+module.exports = {
26
+    match: function(url, patterns, callback) {
27
+        //argscheck.checkArgs('fF', 'Whitelist.match', arguments);
28
+        exec(callback, callback, "WhitelistAPI", "URLMatchesPatterns", [url, patterns]);
29
+    },
30
+    test: function(url, callback) {
31
+        //argscheck.checkArgs('fF', 'Whitelist.test', arguments);
32
+        exec(callback, callback, "WhitelistAPI", "URLIsAllowed", [url]);
33
+    }
34
+}

+ 10 - 0
plugins/fetch.json

@@ -0,0 +1,10 @@
1
+{
2
+  "cordova-plugin-whitelist": {
3
+    "source": {
4
+      "type": "registry",
5
+      "id": "cordova-plugin-whitelist@1"
6
+    },
7
+    "is_top_level": true,
8
+    "variables": {}
9
+  }
10
+}

+ 107 - 0
www/css/index.css

@@ -0,0 +1,107 @@
1
+/*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements.  See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership.  The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License.  You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied.  See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+* {
20
+    -webkit-tap-highlight-color: rgba(0,0,0,0); /* make transparent link selection, adjust last value opacity 0 to 1.0 */
21
+}
22
+
23
+body {
24
+    -webkit-touch-callout: none;                /* prevent callout to copy image, etc when tap to hold */
25
+    -webkit-text-size-adjust: none;             /* prevent webkit from resizing text to fit */
26
+    -webkit-user-select: none;                  /* prevent copy paste, to allow, change 'none' to 'text' */
27
+    background-color:#E4E4E4;
28
+    background-image:linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
29
+    font-family: system-ui, -apple-system, -apple-system-font, 'Segoe UI', 'Roboto', sans-serif;
30
+    font-size:12px;
31
+    height:100vh;
32
+    margin:0px;
33
+    padding:0px;
34
+    /* Padding to avoid the "unsafe" areas behind notches in the screen */
35
+    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-right, 0px);
36
+    text-transform:uppercase;
37
+    width:100%;
38
+}
39
+
40
+/* Portrait layout (default) */
41
+.app {
42
+    background:url(../img/logo.png) no-repeat center top; /* 170px x 200px */
43
+    position:absolute;             /* position in the center of the screen */
44
+    left:50%;
45
+    top:50%;
46
+    height:50px;                   /* text area height */
47
+    width:225px;                   /* text area width */
48
+    text-align:center;
49
+    padding:180px 0px 0px 0px;     /* image height is 200px (bottom 20px are overlapped with text) */
50
+    margin:-115px 0px 0px -112px;  /* offset vertical: half of image height and text area height */
51
+                                   /* offset horizontal: half of text area width */
52
+}
53
+
54
+/* Landscape layout (with min-width) */
55
+@media screen and (min-aspect-ratio: 1/1) and (min-width:400px) {
56
+    .app {
57
+        background-position:left center;
58
+        padding:75px 0px 75px 170px;  /* padding-top + padding-bottom + text area = image height */
59
+        margin:-90px 0px 0px -198px;  /* offset vertical: half of image height */
60
+                                      /* offset horizontal: half of image width and text area width */
61
+    }
62
+}
63
+
64
+h1 {
65
+    font-size:24px;
66
+    font-weight:normal;
67
+    margin:0px;
68
+    overflow:visible;
69
+    padding:0px;
70
+    text-align:center;
71
+}
72
+
73
+.event {
74
+    border-radius:4px;
75
+    -webkit-border-radius:4px;
76
+    color:#FFFFFF;
77
+    font-size:12px;
78
+    margin:0px 30px;
79
+    padding:2px 0px;
80
+}
81
+
82
+.event.listening {
83
+    background-color:#333333;
84
+    display:block;
85
+}
86
+
87
+.event.received {
88
+    background-color:#4B946A;
89
+    display:none;
90
+}
91
+
92
+@keyframes fade {
93
+    from { opacity: 1.0; }
94
+    50% { opacity: 0.4; }
95
+    to { opacity: 1.0; }
96
+}
97
+ 
98
+@-webkit-keyframes fade {
99
+    from { opacity: 1.0; }
100
+    50% { opacity: 0.4; }
101
+    to { opacity: 1.0; }
102
+}
103
+ 
104
+.blink {
105
+    animation:fade 3000ms infinite;
106
+    -webkit-animation:fade 3000ms infinite;
107
+}

BIN
www/img/logo.png


+ 49 - 0
www/index.html

@@ -0,0 +1,49 @@
1
+<!DOCTYPE html>
2
+<!--
3
+    Licensed to the Apache Software Foundation (ASF) under one
4
+    or more contributor license agreements.  See the NOTICE file
5
+    distributed with this work for additional information
6
+    regarding copyright ownership.  The ASF licenses this file
7
+    to you under the Apache License, Version 2.0 (the
8
+    "License"); you may not use this file except in compliance
9
+    with the License.  You may obtain a copy of the License at
10
+
11
+    http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+    Unless required by applicable law or agreed to in writing,
14
+    software distributed under the License is distributed on an
15
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+     KIND, either express or implied.  See the License for the
17
+    specific language governing permissions and limitations
18
+    under the License.
19
+-->
20
+<html>
21
+    <head>
22
+        <!--
23
+        Customize this policy to fit your own app's needs. For more guidance, see:
24
+            https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#content-security-policy
25
+        Some notes:
26
+            * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
27
+            * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
28
+            * Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
29
+                * Enable inline JS: add 'unsafe-inline' to default-src
30
+        -->
31
+        <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">
32
+        <meta name="format-detection" content="telephone=no">
33
+        <meta name="msapplication-tap-highlight" content="no">
34
+        <meta name="viewport" content="initial-scale=1, width=device-width, viewport-fit=cover">
35
+        <link rel="stylesheet" type="text/css" href="css/index.css">
36
+        <title>Hello World</title>
37
+    </head>
38
+    <body>
39
+        <div class="app">
40
+            <h1>Apache Cordova</h1>
41
+            <div id="deviceready" class="blink">
42
+                <p class="event listening">Connecting to Device</p>
43
+                <p class="event received">Device is Ready</p>
44
+            </div>
45
+        </div>
46
+        <script type="text/javascript" src="cordova.js"></script>
47
+        <script type="text/javascript" src="js/index.js"></script>
48
+    </body>
49
+</html>

+ 46 - 0
www/js/index.js

@@ -0,0 +1,46 @@
1
+/*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements.  See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership.  The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License.  You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied.  See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+var app = {
20
+    // Application Constructor
21
+    initialize: function() {
22
+        document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
23
+    },
24
+
25
+    // deviceready Event Handler
26
+    //
27
+    // Bind any cordova events here. Common events are:
28
+    // 'pause', 'resume', etc.
29
+    onDeviceReady: function() {
30
+        this.receivedEvent('deviceready');
31
+    },
32
+
33
+    // Update DOM on a Received Event
34
+    receivedEvent: function(id) {
35
+        var parentElement = document.getElementById(id);
36
+        var listeningElement = parentElement.querySelector('.listening');
37
+        var receivedElement = parentElement.querySelector('.received');
38
+
39
+        listeningElement.setAttribute('style', 'display:none;');
40
+        receivedElement.setAttribute('style', 'display:block;');
41
+
42
+        console.log('Received Event: ' + id);
43
+    }
44
+};
45
+
46
+app.initialize();