Young 6 年之前
當前提交
5360a5be41
共有 90 個文件被更改,包括 3413 次插入0 次删除
  1. 4 0
      .gitignore
  2. 2 0
      .npmignore
  3. 28 0
      config.xml
  4. 23 0
      hooks/README.md
  5. 27 0
      package.json
  6. 22 0
      plugins/android.json
  7. 15 0
      plugins/cordova-plugin-chrome-apps-system-network/CONTRIBUTING.md
  8. 28 0
      plugins/cordova-plugin-chrome-apps-system-network/LICENSE
  9. 25 0
      plugins/cordova-plugin-chrome-apps-system-network/README.md
  10. 59 0
      plugins/cordova-plugin-chrome-apps-system-network/package.json
  11. 42 0
      plugins/cordova-plugin-chrome-apps-system-network/plugin.xml
  12. 69 0
      plugins/cordova-plugin-chrome-apps-system-network/src/android/ChromeSystemNetwork.java
  13. 190 0
      plugins/cordova-plugin-chrome-apps-system-network/src/ios/ChromeSystemNetwork.m
  14. 9 0
      plugins/cordova-plugin-chrome-apps-system-network/system.network.js
  15. 15 0
      plugins/cordova-plugin-chrome-apps-system-network/tests/plugin.xml
  16. 83 0
      plugins/cordova-plugin-chrome-apps-system-network/tests/tests.js
  17. 81 0
      plugins/cordova-plugin-diont/README.md
  18. 60 0
      plugins/cordova-plugin-diont/package.json
  19. 35 0
      plugins/cordova-plugin-diont/plugin.xml
  20. 127 0
      plugins/cordova-plugin-diont/src/android/Diont.java
  21. 221 0
      plugins/cordova-plugin-diont/www/diont.js
  22. 37 0
      plugins/cordova-plugin-whitelist/CONTRIBUTING.md
  23. 202 0
      plugins/cordova-plugin-whitelist/LICENSE
  24. 5 0
      plugins/cordova-plugin-whitelist/NOTICE
  25. 163 0
      plugins/cordova-plugin-whitelist/README.md
  26. 75 0
      plugins/cordova-plugin-whitelist/RELEASENOTES.md
  27. 148 0
      plugins/cordova-plugin-whitelist/doc/de/README.md
  28. 148 0
      plugins/cordova-plugin-whitelist/doc/es/README.md
  29. 148 0
      plugins/cordova-plugin-whitelist/doc/fr/README.md
  30. 148 0
      plugins/cordova-plugin-whitelist/doc/it/README.md
  31. 148 0
      plugins/cordova-plugin-whitelist/doc/ja/README.md
  32. 148 0
      plugins/cordova-plugin-whitelist/doc/ko/README.md
  33. 148 0
      plugins/cordova-plugin-whitelist/doc/pl/README.md
  34. 148 0
      plugins/cordova-plugin-whitelist/doc/zh/README.md
  35. 64 0
      plugins/cordova-plugin-whitelist/package.json
  36. 48 0
      plugins/cordova-plugin-whitelist/plugin.xml
  37. 161 0
      plugins/cordova-plugin-whitelist/src/android/WhitelistPlugin.java
  38. 26 0
      plugins/fetch.json
  39. 29 0
      res/README.md
  40. 二進制
      res/icon/android/icon-36-ldpi.png
  41. 二進制
      res/icon/android/icon-48-mdpi.png
  42. 二進制
      res/icon/android/icon-72-hdpi.png
  43. 二進制
      res/icon/android/icon-96-xhdpi.png
  44. 二進制
      res/icon/bada-wac/icon-48-type5.png
  45. 二進制
      res/icon/bada-wac/icon-50-type3.png
  46. 二進制
      res/icon/bada-wac/icon-80-type4.png
  47. 二進制
      res/icon/bada/icon-128.png
  48. 二進制
      res/icon/blackberry/icon-80.png
  49. 二進制
      res/icon/blackberry10/icon-80.png
  50. 二進制
      res/icon/ios/icon-57-2x.png
  51. 二進制
      res/icon/ios/icon-57.png
  52. 二進制
      res/icon/ios/icon-72-2x.png
  53. 二進制
      res/icon/ios/icon-72.png
  54. 二進制
      res/icon/tizen/icon-128.png
  55. 二進制
      res/icon/webos/icon-64.png
  56. 二進制
      res/icon/windows-phone/icon-173-tile.png
  57. 二進制
      res/icon/windows-phone/icon-48.png
  58. 二進制
      res/icon/windows-phone/icon-62-tile.png
  59. 二進制
      res/screen/android/screen-hdpi-landscape.png
  60. 二進制
      res/screen/android/screen-hdpi-portrait.png
  61. 二進制
      res/screen/android/screen-ldpi-landscape.png
  62. 二進制
      res/screen/android/screen-ldpi-portrait.png
  63. 二進制
      res/screen/android/screen-mdpi-landscape.png
  64. 二進制
      res/screen/android/screen-mdpi-portrait.png
  65. 二進制
      res/screen/android/screen-xhdpi-landscape.png
  66. 二進制
      res/screen/android/screen-xhdpi-portrait.png
  67. 二進制
      res/screen/bada-wac/screen-type3.png
  68. 二進制
      res/screen/bada-wac/screen-type4.png
  69. 二進制
      res/screen/bada-wac/screen-type5.png
  70. 二進制
      res/screen/bada/screen-portrait.png
  71. 二進制
      res/screen/blackberry/screen-225.png
  72. 二進制
      res/screen/blackberry10/splash-1280x768.png
  73. 二進制
      res/screen/blackberry10/splash-720x720.png
  74. 二進制
      res/screen/blackberry10/splash-768x1280.png
  75. 二進制
      res/screen/ios/screen-ipad-landscape-2x.png
  76. 二進制
      res/screen/ios/screen-ipad-landscape.png
  77. 二進制
      res/screen/ios/screen-ipad-portrait-2x.png
  78. 二進制
      res/screen/ios/screen-ipad-portrait.png
  79. 二進制
      res/screen/ios/screen-iphone-landscape-2x.png
  80. 二進制
      res/screen/ios/screen-iphone-landscape.png
  81. 二進制
      res/screen/ios/screen-iphone-portrait-2x.png
  82. 二進制
      res/screen/ios/screen-iphone-portrait-568h-2x.png
  83. 二進制
      res/screen/ios/screen-iphone-portrait.png
  84. 24 0
      res/screen/tizen/README.md
  85. 二進制
      res/screen/webos/screen-64.png
  86. 二進制
      res/screen/windows-phone/screen-portrait.jpg
  87. 115 0
      www/css/index.css
  88. 二進制
      www/img/logo.png
  89. 49 0
      www/index.html
  90. 66 0
      www/js/index.js

+ 4 - 0
.gitignore

@@ -0,0 +1,4 @@
1
+node_modules
2
+package-lock.json
3
+build
4
+platforms/android

+ 2 - 0
.npmignore

@@ -0,0 +1,2 @@
1
+# OS X
2
+.DS_Store

+ 28 - 0
config.xml

@@ -0,0 +1,28 @@
1
+<?xml version='1.0' encoding='utf-8'?>
2
+<widget id="io.cordova.hellocordova" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
3
+    <name>HelloCordova</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
+    <plugin name="cordova-plugin-whitelist" spec="1" />
12
+    <access origin="*" />
13
+    <allow-intent href="http://*/*" />
14
+    <allow-intent href="https://*/*" />
15
+    <allow-intent href="tel:*" />
16
+    <allow-intent href="sms:*" />
17
+    <allow-intent href="mailto:*" />
18
+    <allow-intent href="geo:*" />
19
+    <platform name="android">
20
+        <allow-intent href="market:*" />
21
+    </platform>
22
+    <platform name="ios">
23
+        <allow-intent href="itms:*" />
24
+        <allow-intent href="itms-apps:*" />
25
+    </platform>
26
+    <plugin name="cordova-plugin-diont" spec="https://github.com/willemmulder/Diont-for-Cordova.git" />
27
+    <engine name="android" spec="^7.1.4" />
28
+</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.

+ 27 - 0
package.json

@@ -0,0 +1,27 @@
1
+{
2
+    "name": "helloworld",
3
+    "displayName": "HelloCordova",
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
+    "author": "Apache Cordova Team",
11
+    "license": "Apache-2.0",
12
+    "dependencies": {
13
+        "cordova-android": "^7.1.4",
14
+        "cordova-plugin-chrome-apps-system-network": "git+https://github.com/MobileChromeApps/cordova-plugin-chrome-apps-system-network.git",
15
+        "cordova-plugin-diont": "git+https://github.com/willemmulder/Diont-for-Cordova.git",
16
+        "cordova-plugin-whitelist": "^1.3.3"
17
+    },
18
+    "cordova": {
19
+        "plugins": {
20
+            "cordova-plugin-diont": {},
21
+            "cordova-plugin-whitelist": {}
22
+        },
23
+        "platforms": [
24
+            "android"
25
+        ]
26
+    }
27
+}

+ 22 - 0
plugins/android.json

@@ -0,0 +1,22 @@
1
+{
2
+  "prepare_queue": {
3
+    "installed": [],
4
+    "uninstalled": []
5
+  },
6
+  "config_munge": {
7
+    "files": {}
8
+  },
9
+  "installed_plugins": {
10
+    "cordova-plugin-diont": {
11
+      "PACKAGE_NAME": "io.cordova.hellocordova"
12
+    },
13
+    "cordova-plugin-whitelist": {
14
+      "PACKAGE_NAME": "io.cordova.hellocordova"
15
+    }
16
+  },
17
+  "dependent_plugins": {
18
+    "cordova-plugin-chrome-apps-system-network": {
19
+      "PACKAGE_NAME": "io.cordova.hellocordova"
20
+    }
21
+  }
22
+}

+ 15 - 0
plugins/cordova-plugin-chrome-apps-system-network/CONTRIBUTING.md

@@ -0,0 +1,15 @@
1
+# Contributing to this Repository
2
+
3
+Thank you for your interest in contributing!
4
+
5
+Send us your patches early and often and in whatever shape or form (even before you cover these next points).
6
+
7
+## Legal
8
+
9
+This repository is a Google open source project, and so we require contributors to sign Google's open source Contributor License Agreement.
10
+It's easy to do, just click here to sign as an [individual](https://developers.google.com/open-source/cla/individual) or [corporation](https://developers.google.com/open-source/cla/corporate).
11
+Individuals can sign electronically in seconds (see the bottom of the page); corporations will need to email a PDF, or mail.
12
+
13
+We cannot accept PRs or patches larger than fixing typos and the like without a signed CLA.
14
+
15
+If your Github account doesn't show the name you used to sign, please mention your name in your PR.

+ 28 - 0
plugins/cordova-plugin-chrome-apps-system-network/LICENSE

@@ -0,0 +1,28 @@
1
+Copyright (c) 2014 The Chromium Authors. All rights reserved.
2
+
3
+Redistribution and use in source and binary forms, with or without
4
+modification, are permitted provided that the following conditions are
5
+met:
6
+
7
+   * Redistributions of source code must retain the above copyright
8
+notice, this list of conditions and the following disclaimer.
9
+   * Redistributions in binary form must reproduce the above
10
+copyright notice, this list of conditions and the following disclaimer
11
+in the documentation and/or other materials provided with the
12
+distribution.
13
+   * Neither the name of Google Inc. nor the names of its
14
+contributors may be used to endorse or promote products derived from
15
+this software without specific prior written permission.
16
+
17
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20
+A PARTICULAR PURPOSE ARE DBSDLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+

+ 25 - 0
plugins/cordova-plugin-chrome-apps-system-network/README.md

@@ -0,0 +1,25 @@
1
+# chrome.system.network Plugin
2
+
3
+This plugin provides the ability to retrieve information about local network adapters.
4
+
5
+## Status
6
+
7
+Stable on Android and iOS.
8
+
9
+## Reference
10
+
11
+The API reference is [here](https://developer.chrome.com/apps/system_network).
12
+
13
+# Release Notes
14
+
15
+## 1.1.2 (April 30, 2015)
16
+- Renamed plugin to pubilsh to NPM
17
+
18
+## 1.1.1 (October 24, 2014)
19
+* Fixed Xcode build error
20
+
21
+## 1.1.0 (October 21, 2014)
22
+* Added support for iOS
23
+
24
+## 1.0.0
25
+* Initial release

+ 59 - 0
plugins/cordova-plugin-chrome-apps-system-network/package.json

@@ -0,0 +1,59 @@
1
+{
2
+  "_from": "git+https://github.com/MobileChromeApps/cordova-plugin-chrome-apps-system-network.git",
3
+  "_id": "cordova-plugin-chrome-apps-system-network@1.1.3-dev",
4
+  "_inBundle": false,
5
+  "_integrity": "",
6
+  "_location": "/cordova-plugin-chrome-apps-system-network",
7
+  "_phantomChildren": {},
8
+  "_requested": {
9
+    "type": "git",
10
+    "raw": "https://github.com/MobileChromeApps/cordova-plugin-chrome-apps-system-network",
11
+    "rawSpec": "https://github.com/MobileChromeApps/cordova-plugin-chrome-apps-system-network",
12
+    "saveSpec": "git+https://github.com/MobileChromeApps/cordova-plugin-chrome-apps-system-network.git",
13
+    "fetchSpec": "https://github.com/MobileChromeApps/cordova-plugin-chrome-apps-system-network.git",
14
+    "gitCommittish": null
15
+  },
16
+  "_requiredBy": [
17
+    "#USER",
18
+    "/"
19
+  ],
20
+  "_resolved": "git+https://github.com/MobileChromeApps/cordova-plugin-chrome-apps-system-network.git#d60889149dff21c9d479a61d5b94a3ae7991607f",
21
+  "_spec": "https://github.com/MobileChromeApps/cordova-plugin-chrome-apps-system-network",
22
+  "_where": "/Users/young/开发/udp-discover-client",
23
+  "author": "",
24
+  "bugs": {
25
+    "url": "https://github.com/MobileChromeApps/cordova-plugin-chrome-apps-system-network/issues"
26
+  },
27
+  "bundleDependencies": false,
28
+  "cordova": {
29
+    "id": "cordova-plugin-chrome-apps-system-network",
30
+    "platforms": [
31
+      "android",
32
+      "ios"
33
+    ]
34
+  },
35
+  "deprecated": false,
36
+  "description": "This plugin provides the ability to retrieve information about local network adapters.",
37
+  "engines": [
38
+    {
39
+      "name": "cordova",
40
+      "version": ">=3.0.0"
41
+    }
42
+  ],
43
+  "homepage": "https://github.com/MobileChromeApps/cordova-plugin-chrome-apps-system-network",
44
+  "keywords": [
45
+    "chrome",
46
+    "system",
47
+    "network",
48
+    "ecosystem:cordova",
49
+    "cordova-android",
50
+    "cordova-ios"
51
+  ],
52
+  "license": "BSD",
53
+  "name": "cordova-plugin-chrome-apps-system-network",
54
+  "repository": {
55
+    "type": "git",
56
+    "url": "git+https://github.com/MobileChromeApps/cordova-plugin-chrome-apps-system-network.git"
57
+  },
58
+  "version": "1.1.3-dev"
59
+}

+ 42 - 0
plugins/cordova-plugin-chrome-apps-system-network/plugin.xml

@@ -0,0 +1,42 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!--
3
+  Copyright (c) 2014 The Chromium Authors. All rights reserved.
4
+  Use of this source code is governed by a BSD-style license that can be
5
+  found in the LICENSE file.
6
+-->
7
+<plugin xmlns="http://cordova.apache.org/ns/plugins/1.0"
8
+    id="cordova-plugin-chrome-apps-system-network"
9
+    version="1.1.3-dev">
10
+  <engines>
11
+    <engine name="cordova" version=">=3.0.0" />
12
+  </engines>
13
+
14
+  <name>Chrome System Network API</name>
15
+  <keywords>chrome,system,network</keywords>
16
+  <repo>https://github.com/MobileChromeApps/cordova-plugin-chrome-apps-system-network.git</repo>
17
+  <issue>https://github.com/MobileChromeApps/cordova-plugin-chrome-apps-system-network/issues</issue>
18
+
19
+  <js-module src="system.network.js" name="system.network">
20
+    <clobbers target="chrome.system.network" />
21
+  </js-module>
22
+
23
+  <platform name="android">
24
+    <source-file src="src/android/ChromeSystemNetwork.java" target-dir="src/org/chromium" />
25
+
26
+    <config-file target="res/xml/config.xml" parent="/widget">
27
+      <feature name="ChromeSystemNetwork">
28
+        <param name="android-package" value="org.chromium.ChromeSystemNetwork"/>
29
+      </feature>
30
+    </config-file>
31
+  </platform>
32
+
33
+  <platform name="ios">
34
+    <source-file src="src/ios/ChromeSystemNetwork.m" />
35
+
36
+    <config-file target="config.xml" parent="/widget">
37
+      <feature name="ChromeSystemNetwork">
38
+        <param name="ios-package" value="ChromeSystemNetwork"/>
39
+      </feature>
40
+    </config-file>
41
+  </platform>
42
+</plugin>

+ 69 - 0
plugins/cordova-plugin-chrome-apps-system-network/src/android/ChromeSystemNetwork.java

@@ -0,0 +1,69 @@
1
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style license that can be
3
+// found in the LICENSE file.
4
+
5
+package org.chromium;
6
+
7
+import java.net.InetAddress;
8
+import java.net.InterfaceAddress;
9
+import java.net.NetworkInterface;
10
+import java.net.SocketException;
11
+import java.util.ArrayList;
12
+import java.util.Collections;
13
+
14
+import org.apache.cordova.CallbackContext;
15
+import org.apache.cordova.CordovaArgs;
16
+import org.apache.cordova.CordovaPlugin;
17
+import org.json.JSONArray;
18
+import org.json.JSONException;
19
+import org.json.JSONObject;
20
+
21
+import android.util.Log;
22
+
23
+public class ChromeSystemNetwork extends CordovaPlugin {
24
+    private static final String LOG_TAG = "ChromeSystemNetwork";
25
+
26
+    @Override
27
+    public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) throws JSONException {
28
+        if ("getNetworkInterfaces".equals(action)) {
29
+            getNetworkInterfaces(args, callbackContext);
30
+            return true;
31
+        }
32
+        return false;
33
+    }
34
+
35
+    private void getNetworkInterfaces(final CordovaArgs args, final CallbackContext callbackContext) {
36
+        cordova.getThreadPool().execute(new Runnable() {
37
+            @Override
38
+            public void run() {
39
+                try {
40
+                    JSONArray ret = new JSONArray();
41
+                    ArrayList<NetworkInterface> interfaces =  Collections.list(NetworkInterface.getNetworkInterfaces());
42
+                    for (NetworkInterface iface : interfaces) {
43
+                        if (iface.isLoopback()) {
44
+                            continue;
45
+                        }
46
+                        for (InterfaceAddress interfaceAddress : iface.getInterfaceAddresses()) {
47
+                            InetAddress address = interfaceAddress.getAddress();
48
+                            if (address == null) {
49
+                                continue;
50
+                            }
51
+                            JSONObject data = new JSONObject();
52
+                            data.put("name", iface.getDisplayName());
53
+                            // Strip address scope zones for IPv6 address.
54
+                            data.put("address", address.getHostAddress().replaceAll("%.*", ""));
55
+                            data.put("prefixLength", interfaceAddress.getNetworkPrefixLength());
56
+
57
+                            ret.put(data);
58
+                        }
59
+                    }
60
+
61
+                    callbackContext.success(ret);
62
+                } catch (Exception e) {
63
+                    Log.e(LOG_TAG, "Error occured while getting network interfaces", e);
64
+                    callbackContext.error("Could not get network interfaces");
65
+                }
66
+            }
67
+        });
68
+    }
69
+}

+ 190 - 0
plugins/cordova-plugin-chrome-apps-system-network/src/ios/ChromeSystemNetwork.m

@@ -0,0 +1,190 @@
1
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style license that can be
3
+// found in the LICENSE file.
4
+
5
+#import <Cordova/CDVPlugin.h>
6
+#import <Foundation/Foundation.h>
7
+#import <sys/types.h>
8
+#import <ifaddrs.h> // For getifaddrs()
9
+#import <net/if.h> // For IFF_LOOPBACK
10
+#import <netinet/in.h> // For sockaddr_in
11
+#import <arpa/inet.h> // For inet_ntop
12
+
13
+#if CHROME_SYSTEM_NETWORK_VERBOSE_LOGGING
14
+#define VERBOSE_LOG NSLog
15
+#else
16
+#define VERBOSE_LOG(args...) do {} while (false)
17
+#endif
18
+
19
+@interface ChromeSystemNetwork : CDVPlugin
20
+
21
+- (void)getNetworkInterfaces:(CDVInvokedUrlCommand*)command;
22
+
23
+@end
24
+
25
+@implementation ChromeSystemNetwork
26
+
27
+- (NSError *)kernelCallError:(NSString *)errMsg
28
+{
29
+    int code = errno;
30
+	NSString *codeDescription = [NSString stringWithUTF8String:strerror(code)];
31
+
32
+	NSDictionary* userInfo = @{
33
+                              NSLocalizedDescriptionKey: [NSString stringWithFormat:@"%@: %d - %@", errMsg, code, codeDescription]
34
+                              };
35
+
36
+	return [NSError errorWithDomain:NSPOSIXErrorDomain code:code userInfo:userInfo];
37
+}
38
+
39
+- (NSString*)getIPAddress:(struct sockaddr *)ifa_addr family:(sa_family_t)family
40
+{
41
+    // IP address has different data structure, for IPv4 vs IPv6
42
+    void* addressPointer = NULL;
43
+    char addressBuffer[100];
44
+
45
+    if (family == AF_INET6)
46
+    {
47
+        addressPointer = &((struct sockaddr_in6 *)ifa_addr)->sin6_addr;
48
+    }
49
+    else
50
+    {
51
+        addressPointer = &((struct sockaddr_in *)ifa_addr)->sin_addr;
52
+    }
53
+    inet_ntop(family, addressPointer, (char*)&addressBuffer, sizeof(addressBuffer));
54
+
55
+    NSString* address = [NSString stringWithUTF8String:addressBuffer];
56
+
57
+    // Strip address scope zones for IPv6 address.
58
+    if (family == AF_INET6)
59
+    {
60
+        NSRange range = [address rangeOfString:@"%"];
61
+        if (range.location != NSNotFound)
62
+        {
63
+            address = [address substringToIndex:range.location];
64
+        }
65
+    }
66
+
67
+    return address;
68
+}
69
+
70
+-(unsigned int)getPrefixLength:(struct sockaddr *)ifa_netmask family:(sa_family_t)family
71
+{
72
+    if (ifa_netmask == NULL)
73
+    {
74
+        return 0;
75
+    }
76
+
77
+    unsigned int prefixLength = 0;
78
+
79
+    // Compute the network prefix length by using the "address" of the net mask
80
+    //  - Count all the most significant bits that are set in the address
81
+    //  - The count stops as soon as a zero bit is found
82
+    //  - Approach is same for IPv4 vs IPv6, differs in implementation due to
83
+    //    different data structures for larger IPv6 addresses (32 vs 128 bit)
84
+    if (family == AF_INET6)
85
+    {
86
+        struct in6_addr address = ((struct sockaddr_in6 *)ifa_netmask)->sin6_addr;
87
+
88
+        // Count all the set bits in the 16 bytes of the IPv6 address
89
+        for (int i = 0; i < 16; i++) {
90
+            u_int8_t mask_part = address.s6_addr[i];
91
+
92
+            while ( mask_part & 0x80 ) {
93
+                prefixLength++;
94
+                mask_part <<= 1;
95
+            }
96
+        }
97
+    }
98
+    else
99
+    {
100
+        struct in_addr address = ((struct sockaddr_in *)ifa_netmask)->sin_addr;
101
+        uint32_t subnet_mask = ntohl( address.s_addr );
102
+
103
+        // Count all the set bits in the 32 bit IPv4 address
104
+        while ( subnet_mask & 0x80000000 ) {
105
+          prefixLength++;
106
+          subnet_mask <<= 1;
107
+        }
108
+    }
109
+
110
+    return prefixLength;
111
+}
112
+
113
+- (NSArray*)_getNetworkInterfaces:(NSError **)error
114
+{
115
+    struct ifaddrs* interfaces = NULL;
116
+
117
+    // retrieve the current interfaces - returns 0 on success
118
+    if (getifaddrs(&interfaces) != 0)
119
+    {
120
+		if (error)
121
+		{
122
+			*error = [self kernelCallError:@"Failed to getifaddrs"];
123
+		}
124
+        return nil;
125
+    }
126
+
127
+    NSMutableArray* ret = [NSMutableArray array];
128
+    struct ifaddrs* temp_addr = NULL;
129
+
130
+    // Loop through linked list of interfaces
131
+    for (temp_addr = interfaces; temp_addr != NULL; temp_addr = temp_addr->ifa_next)
132
+    {
133
+        if (temp_addr->ifa_flags & IFF_LOOPBACK)
134
+        {
135
+            // Ignore the loopback address
136
+            continue;
137
+        }
138
+
139
+        sa_family_t family = (temp_addr->ifa_addr ? temp_addr->ifa_addr->sa_family : 0);
140
+        if (family != AF_INET &&
141
+            family != AF_INET6)
142
+        {
143
+            // Ignore non-Internet interfaces
144
+            continue;
145
+        }
146
+
147
+        NSString* name = [NSString stringWithUTF8String:temp_addr->ifa_name];
148
+
149
+        NSString* address = [self getIPAddress:temp_addr->ifa_addr family:family];
150
+
151
+        unsigned int prefixLength = [self getPrefixLength:temp_addr->ifa_netmask family:family];
152
+
153
+        VERBOSE_LOG(@"interface name: %@; address: %@; prefixLength: %d", name, address, prefixLength);
154
+
155
+        [ret addObject:@{
156
+                         @"name": name,
157
+                         @"address": address,
158
+                         @"prefixLength": @(prefixLength)
159
+                         }];
160
+    }
161
+
162
+    // Free memory
163
+    freeifaddrs(interfaces);
164
+
165
+    return ret;
166
+}
167
+
168
+- (void)getNetworkInterfaces:(CDVInvokedUrlCommand*)command
169
+{
170
+    [self.commandDelegate runInBackground:^{
171
+        CDVPluginResult* pluginResult = nil;
172
+
173
+        NSError* error = nil;
174
+        NSArray* interfaces = [self _getNetworkInterfaces:&error];
175
+
176
+        if (interfaces)
177
+        {
178
+            pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:interfaces];
179
+        }
180
+        else
181
+        {
182
+            NSLog(@"Error occured while getting network interfaces - %@", [error localizedDescription]);
183
+            pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Could not get network interfaces"];
184
+        }
185
+
186
+        [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
187
+    }];
188
+}
189
+
190
+@end

+ 9 - 0
plugins/cordova-plugin-chrome-apps-system-network/system.network.js

@@ -0,0 +1,9 @@
1
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style license that can be
3
+// found in the LICENSE file.
4
+
5
+var exec = require('cordova/exec');
6
+
7
+exports.getNetworkInterfaces = function(callback) {
8
+  exec(callback, callback, 'ChromeSystemNetwork', 'getNetworkInterfaces', []);
9
+};

+ 15 - 0
plugins/cordova-plugin-chrome-apps-system-network/tests/plugin.xml

@@ -0,0 +1,15 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!--
3
+  Copyright (c) 2015 The Chromium Authors. All rights reserved.
4
+  Use of this source code is governed by a BSD-style license that can be
5
+  found in the LICENSE file.
6
+-->
7
+<plugin xmlns="http://cordova.apache.org/ns/plugins/1.0"
8
+    id="cordova-plugin-chrome-apps-system-network-tests"
9
+    version="1.1.2-dev">
10
+
11
+  <name>Chrome System Network Tests</name>
12
+  <js-module src="tests.js" name="tests">
13
+    <runs/>
14
+  </js-module>
15
+</plugin>

+ 83 - 0
plugins/cordova-plugin-chrome-apps-system-network/tests/tests.js

@@ -0,0 +1,83 @@
1
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style license that can be
3
+// found in the LICENSE file.
4
+
5
+exports.defineManualTests = function(rootEl, addButton) {
6
+  addButton('Get Network Interfaces', function() {
7
+    chrome.system.network.getNetworkInterfaces(function(networkInterfaces) {
8
+      console.log(JSON.stringify(networkInterfaces, null, 4));
9
+    });
10
+  });
11
+};
12
+
13
+exports.defineAutoTests = function() {
14
+  'use strict';
15
+
16
+  require('cordova-plugin-chrome-apps-test-framework.jasmine_helpers').addJasmineHelpers();
17
+
18
+  var customMatchers = {
19
+
20
+    toHaveProperty : function(util, customEqualityTesters) {
21
+      return {
22
+        compare : function(actual, propName, propType){
23
+          var result = {};
24
+          result.pass = ((void 0 !== actual[propName]) && (propType ? (typeof actual[propName] === propType) : true));
25
+          result.message = 'Expected ' + actual + ' to have property ' + propName + (propType ? ' of type ' + propType : '');
26
+          return result;
27
+        }
28
+      };
29
+    },
30
+
31
+    toBeArray : function(util, customEqualityTesters) {
32
+      return {
33
+        compare : function(actual, expected){
34
+          var result = {};
35
+          result.pass = (actual instanceof Array);
36
+          result.message = 'Expected ' + actual + ' to be an array.';
37
+          return result;
38
+        }
39
+      };
40
+    }
41
+  };
42
+
43
+  beforeEach(function(done) {
44
+    jasmine.addMatchers(customMatchers);
45
+    done();
46
+  });
47
+
48
+  describe('getNetworkInterfaces', function() {
49
+    it('should exist', function() {
50
+      expect(chrome.system.network.getNetworkInterfaces).toBeDefined();
51
+    });
52
+
53
+    it('should return an array of networkInterfaces', function(done) {
54
+      chrome.system.network.getNetworkInterfaces(function(networkInterfaces) {
55
+        expect(networkInterfaces).toBeDefined();
56
+        expect(networkInterfaces).not.toBe(null);
57
+        expect(networkInterfaces).toBeArray();
58
+        // NOTE: If wifi is disabled, the array of interfaces will be empty,
59
+        //       even if the device has wifi capability
60
+
61
+        done();
62
+      });
63
+    });
64
+
65
+    it('should report details', function(done) {
66
+      chrome.system.network.getNetworkInterfaces(function(networkInterfaces) {
67
+
68
+        networkInterfaces.forEach(function(netInterface) {
69
+          expect(netInterface).toHaveProperty('name', 'string');
70
+          expect(netInterface.name.length).toBeGreaterThan(0);
71
+
72
+          expect(netInterface).toHaveProperty('address', 'string');
73
+          expect(netInterface.address.length).toBeGreaterThan(0);
74
+
75
+          expect(netInterface).toHaveProperty('prefixLength', 'number');
76
+          expect(netInterface.prefixLength).toBeGreaterThan(0);
77
+        });
78
+        done();
79
+      });
80
+    });
81
+
82
+  });
83
+};

+ 81 - 0
plugins/cordova-plugin-diont/README.md

@@ -0,0 +1,81 @@
1
+# Diont for Cordova
2
+
3
+Easy Service Discovery on Local Networks. This Cordova plugin discovers services that are announced by Diont servers on the local network (wifi), either by other mobile devices that use this Diont plugin, or by a [Nodejs Diont](https://github.com/willemmulder/Diont) server.
4
+
5
+
6
+## Features
7
+* 100% complete: no extra dependencies
8
+* allows for transmitting extra, arbitrary service information
9
+* operates smoothly with [Diont for Nodejs](https://github.com/willemmulder/Diont)
10
+
11
+## Installation
12
+Install the plugin with cordova using this command
13
+
14
+```shell
15
+cordova plugin add "https://github.com/willemmulder/Diont-for-Cordova.git"
16
+```
17
+or install via [Plugman](https://github.com/apache/cordova-plugman/) and search for Diont.
18
+
19
+The Diont plugin will be available as the `Diont` global variable in your Javascript code. See 'Get started' for an example.
20
+
21
+## Get started
22
+```javascript
23
+// Cordova standard - run once Cordova and the device is ready
24
+document.addEventListener("deviceready", onDeviceReady, false);
25
+
26
+function onDeviceReady() {
27
+
28
+	var diont = Diont();
29
+	
30
+	// ======
31
+	// Listen for announcements and renouncements in services
32
+	// ======
33
+	diont.on("serviceAnnounced", function(serviceInfo) {
34
+		// A service was announced
35
+		// This function triggers for services not yet available in diont.getServiceInfos()
36
+		// serviceInfo is an Object { isOurService : Boolean, service: Object }
37
+		// service.name, service.host and service.port are always filled
38
+		console.log("A new service was announced", serviceInfo.service);
39
+		// List currently known services
40
+		console.log("All known services", diont.getServiceInfos());
41
+	});
42
+	
43
+	diont.on("serviceRenounced", function(serviceInfo) {
44
+		console.log("A service was renounced", serviceInfo.service);
45
+		console.log("All known services", diont.getServiceInfos());
46
+	});
47
+	
48
+	// ======
49
+	// Announce our own service
50
+	// ======
51
+	var service = {
52
+		name: "TestServer 1",
53
+		host: "127.0.0.1", // when omitted, defaults to the local IP
54
+		port: "1231"
55
+		// any additional information is allowed and will be propagated
56
+	};
57
+	diont.announceService(service);
58
+	
59
+	// Renounce after 5 seconds
60
+	setTimeout(function() {
61
+		diont.renounceService(service);
62
+	}, 5000);
63
+
64
+}
65
+
66
+```
67
+
68
+## Thanks
69
+Thanks to Gramakri for his [Cordova Datagram plugin](https://github.com/gramakri/cordova-plugin-datagram) that served as the inspiration for the UDP parts of this plugin.
70
+
71
+## License
72
+
73
+**This software is licensed under "MIT"**
74
+
75
+> Copyright (c) 2015 Willem Mulder
76
+>
77
+> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
78
+>
79
+> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
80
+>
81
+> THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+ 60 - 0
plugins/cordova-plugin-diont/package.json

@@ -0,0 +1,60 @@
1
+{
2
+  "_from": "git+https://github.com/willemmulder/Diont-for-Cordova.git",
3
+  "_id": "cordova-plugin-diont@0.9.11",
4
+  "_inBundle": false,
5
+  "_integrity": "",
6
+  "_location": "/cordova-plugin-diont",
7
+  "_phantomChildren": {},
8
+  "_requested": {
9
+    "type": "git",
10
+    "raw": "https://github.com/willemmulder/Diont-for-Cordova.git",
11
+    "rawSpec": "https://github.com/willemmulder/Diont-for-Cordova.git",
12
+    "saveSpec": "git+https://github.com/willemmulder/Diont-for-Cordova.git",
13
+    "fetchSpec": "https://github.com/willemmulder/Diont-for-Cordova.git",
14
+    "gitCommittish": null
15
+  },
16
+  "_requiredBy": [
17
+    "#USER",
18
+    "/"
19
+  ],
20
+  "_resolved": "git+https://github.com/willemmulder/Diont-for-Cordova.git#390ae63b1a952c4531ba66d584b79a62ccb6d669",
21
+  "_spec": "https://github.com/willemmulder/Diont-for-Cordova.git",
22
+  "_where": "/Users/young/开发/udp-discover-client",
23
+  "author": {
24
+    "name": "Willem Mulder"
25
+  },
26
+  "bugs": {
27
+    "url": "https://github.com/willemmulder/Diont-for-Cordova/issues"
28
+  },
29
+  "bundleDependencies": false,
30
+  "cordova": {
31
+    "id": "cordova-plugin-diont",
32
+    "platforms": [
33
+      "android"
34
+    ]
35
+  },
36
+  "deprecated": false,
37
+  "description": "Easy Service Discovery on Local Networks",
38
+  "homepage": "https://github.com/willemmulder/Diont-for-Cordova#readme",
39
+  "keywords": [
40
+    "udp",
41
+    "multicast",
42
+    "service",
43
+    "discovery",
44
+    "mdns",
45
+    "bonjour",
46
+    "diont",
47
+    "local",
48
+    "network",
49
+    "wifi",
50
+    "ecosystem:cordova",
51
+    "cordova-android"
52
+  ],
53
+  "license": "MIT",
54
+  "name": "cordova-plugin-diont",
55
+  "repository": {
56
+    "type": "git",
57
+    "url": "git+https://github.com/willemmulder/Diont-for-Cordova.git"
58
+  },
59
+  "version": "0.9.11"
60
+}

+ 35 - 0
plugins/cordova-plugin-diont/plugin.xml

@@ -0,0 +1,35 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
3
+	xmlns:android="http://schemas.android.com/apk/res/android"
4
+	id="cordova-plugin-diont"
5
+	version="0.9.11">
6
+
7
+	<name>Diont for Cordova</name>
8
+	<description>Easy Service Discovery on Local Networks</description>
9
+	<author>Willem Mulder</author>
10
+	<repo>https://github.com/willemmulder/Diont-for-Cordova</repo>
11
+	<license>ISC</license>
12
+	<keywords>udp, multicast, service, discovery, mdns, bonjour, diont, local, network, wifi</keywords>
13
+
14
+	<js-module src="www/diont.js" name="diont">
15
+		<clobbers target="Diont"/>
16
+	</js-module>
17
+
18
+	<dependency id="cordova-plugin-chrome-apps-system-network" url="https://github.com/MobileChromeApps/cordova-plugin-chrome-apps-system-network" commit="master" />
19
+	
20
+	<platform name="android">
21
+		<!-- inject <feature> tag into config.xml to register the plugin -->
22
+		<config-file target="res/xml/config.xml" parent="/*">
23
+			<feature name="Diont">
24
+				<param name="android-package" value="net.willemmulder.diont.cordova.Diont"/>
25
+			</feature>
26
+		</config-file>
27
+		<config-file target="AndroidManifest.xml" parent="/*">
28
+			<uses-permission android:name="android.permission.INTERNET"/>
29
+			<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
30
+		</config-file>
31
+		<source-file src="src/android/Diont.java" target-dir="src/net/willemmulder/diont/cordova/" />
32
+	</platform>
33
+
34
+</plugin>
35
+

+ 127 - 0
plugins/cordova-plugin-diont/src/android/Diont.java

@@ -0,0 +1,127 @@
1
+package net.willemmulder.diont.cordova;
2
+
3
+import java.io.IOException;
4
+import java.net.DatagramPacket;
5
+import java.net.InetAddress;
6
+import java.net.MulticastSocket;
7
+
8
+import org.apache.cordova.CallbackContext;
9
+import org.apache.cordova.CordovaPlugin;
10
+import org.apache.cordova.PluginResult;
11
+
12
+import org.json.JSONArray;
13
+import org.json.JSONException;
14
+
15
+import java.util.HashMap;
16
+
17
+public class Diont extends CordovaPlugin {
18
+
19
+    HashMap<String, MulticastSocket> sockets;
20
+    HashMap<String, SocketListener> listeners;
21
+
22
+    public Diont() {
23
+        sockets = new HashMap<String, MulticastSocket>();
24
+        listeners = new HashMap<String, SocketListener>();
25
+    }
26
+
27
+    @Override
28
+    public boolean execute(String action, JSONArray data, CallbackContext callbackContext) throws JSONException {
29
+        
30
+        final String instanceId = data.getString(0);
31
+        MulticastSocket socket = sockets.get(instanceId);
32
+
33
+        if (action.equals("init")) {
34
+            if (socket == null) {
35
+                try {
36
+                    String host = data.getString(1);
37
+                    int port = data.getInt(2);
38
+
39
+                    socket = new MulticastSocket(port);
40
+                    socket.setTimeToLive(10); // Local network
41
+                    socket.joinGroup(InetAddress.getByName(host)); // Tell the OS to listen for messages on the specified host and treat them as if they were meant for this host
42
+                    Boolean disableLoopback = false;
43
+                    socket.setLoopbackMode(disableLoopback);
44
+                    
45
+                    sockets.put(instanceId, socket);
46
+                    callbackContext.success();
47
+                } catch (Exception e) {
48
+                    callbackContext.error(e.toString());
49
+                }
50
+            }
51
+        } else if (action.equals("listen")) {
52
+            try {
53
+                // Set up listener
54
+                SocketListener listener = new SocketListener(socket, callbackContext);
55
+                listeners.put(instanceId, listener);
56
+                listener.start();
57
+                // Don't run callbackContext.success() since that 'closes' the callbackcontext
58
+                // Such that is prevents us to send further .success(PluginResult.Status.OK) messages when the listener receives a message
59
+            } catch (Exception e) {
60
+                callbackContext.error(e.toString());
61
+            }
62
+        }  else if (action.equals("send")) {
63
+            String message = data.getString(1);
64
+            String host = data.getString(2);
65
+            int port = data.getInt(3);
66
+
67
+            try {
68
+                byte[] bytes = message.getBytes("UTF-8");
69
+                DatagramPacket packet = new DatagramPacket(bytes, bytes.length, InetAddress.getByName(host), port);
70
+                socket.send(packet);
71
+                callbackContext.success(InetAddress.getByName(host).getHostAddress() + ":" + message);
72
+            } catch (IOException ioe) {
73
+                callbackContext.error("IOException: " + ioe.toString());
74
+            } catch (Exception e) {
75
+                callbackContext.error("Exception: " + e.toString());
76
+            }
77
+        } else if (action.equals("close")) {
78
+            if (socket != null) {
79
+                socket.close();
80
+                sockets.remove(instanceId);
81
+                SocketListener listener = listeners.get(instanceId);
82
+                if (listener != null) {
83
+                    listener.interrupt();
84
+                    listeners.remove(instanceId);
85
+                }
86
+            }
87
+            callbackContext.success();
88
+        } else {
89
+            return false; // 'MethodNotFound'
90
+        }
91
+        return true;
92
+    }
93
+
94
+    private class SocketListener extends Thread {
95
+
96
+        MulticastSocket socket;
97
+        PluginResult result;
98
+        CallbackContext callbackContext;
99
+
100
+        public SocketListener(MulticastSocket socket, CallbackContext callbackContextParam) {
101
+            this.socket = socket;
102
+            callbackContext = callbackContextParam;
103
+        }
104
+
105
+        public void run() {
106
+            byte[] data = new byte[2048];
107
+            DatagramPacket packet = new DatagramPacket(data, data.length);
108
+            while (true) {
109
+                try {
110
+                    this.socket.receive(packet);
111
+                    String msg = new String(data, 0, packet.getLength(), "UTF-8")
112
+                                    .replace("'", "\'")
113
+                                    .replace("\r", "\\r")
114
+                                    .replace("\n", "\\n");
115
+
116
+                    result = new PluginResult(PluginResult.Status.OK, msg);
117
+                    result.setKeepCallback(true); // Allow for additional callbacks
118
+                    callbackContext.sendPluginResult(result);
119
+
120
+                } catch (Exception e) {
121
+                    return;
122
+                }
123
+            }
124
+        }
125
+    }
126
+
127
+}

+ 221 - 0
plugins/cordova-plugin-diont/www/diont.js

@@ -0,0 +1,221 @@
1
+var exec = cordova.require('cordova/exec');
2
+
3
+var MULTICAST_HOST = "224.0.0.236";
4
+var MULTICAST_PORT = 60540;
5
+
6
+module.exports = function(options) {
7
+
8
+	var instanceId = guid();
9
+
10
+	var exports = {};
11
+	var serviceInfos = {};
12
+	var events = {};
13
+
14
+	var options = options || {};
15
+	var host = options.host || MULTICAST_HOST;
16
+	var port = options.port || MULTICAST_PORT;
17
+
18
+	// Services is a map (service.host+":"+service.port+":"+service.name) => Object serviceInfo
19
+	// where serviceInfo is an object like
20
+	// { isOurService : Boolean, service: Object }
21
+
22
+	// =====
23
+	// Set up UDP Multicast connection
24
+	// =====
25
+
26
+	function initCallbackSuccess() {
27
+		queryForServices();
28
+	}
29
+	function initCallbackFail(err) {
30
+		// ...
31
+	}
32
+	exec(initCallbackSuccess, initCallbackFail, 'Diont', 'init', [ instanceId, host, port ]);
33
+
34
+
35
+	function messageCallback(message) {
36
+		try {
37
+			var messageObject = JSON.parse(message);
38
+			var eventType = messageObject.eventType;
39
+			var fromDiontId = messageObject.fromDiontInstance;
40
+			if (fromDiontId == instanceId) {
41
+				return;
42
+			}
43
+			if (eventType == "query") {
44
+				var serviceInfosToAnnounce = [];
45
+				for(var index in serviceInfos) {
46
+					serviceInfosToAnnounce.push(serviceInfos[index]);
47
+				}
48
+				sendAnnouncement(serviceInfosToAnnounce);
49
+			} else {
50
+				var receivedServiceInfos = messageObject.serviceInfos;
51
+				for(var serviceInfoIndex in receivedServiceInfos) {
52
+					var serviceInfo = receivedServiceInfos[serviceInfoIndex];
53
+					if(!serviceInfo.service) {
54
+						continue;
55
+					}
56
+					var service = serviceInfo.service;
57
+					if (!service.host || !service.port || !service.name) {
58
+						continue;
59
+					}
60
+					if (eventType == "announce") {
61
+						var id = service.host + ":" + service.port + ":" + service.name;
62
+						if(!serviceInfos[id]) {
63
+							var serviceInfo = serviceInfos[id] = {
64
+								isOurService: false,
65
+								service: service
66
+							}
67
+							if (events["serviceAnnounced"]) {
68
+								for(var callbackId in events["serviceAnnounced"]) {
69
+									var callback = events["serviceAnnounced"][callbackId];
70
+									callback(serviceInfo);
71
+								}
72
+							}
73
+						}
74
+					} else if (eventType == "renounce") {
75
+						var id = service.host + ":" + service.port + ":" + service.name;
76
+						if(serviceInfos[id]) {
77
+							var serviceInfo = serviceInfos[id];
78
+							delete serviceInfos[id];
79
+							if (events["serviceRenounced"]) {
80
+								for(var callbackId in events["serviceRenounced"]) {
81
+									var callback = events["serviceRenounced"][callbackId];
82
+									callback(serviceInfo);
83
+								}
84
+							}
85
+						}
86
+					}
87
+				}
88
+			}
89
+		} catch(e) {
90
+			// ignore...
91
+		}
92
+	}
93
+	exec(messageCallback, null, 'Diont', 'listen', [ instanceId ]);
94
+
95
+	// =====
96
+	// Exported functions
97
+	// =====
98
+
99
+	exports.announceService = function(service) {
100
+		if (!service.host) {
101
+		        chrome.system.network.getNetworkInterfaces(function(networkInterfaces) {
102
+	                	var eth1 = networkInterfaces[1],
103
+		                        address = eth1.address;
104
+		                service.host = address;
105
+		        });
106
+		}
107
+		if (!service.host || !service.port || !service.name) {
108
+			return false;
109
+		}
110
+		var id = service.host + ":" + service.port + ":" + service.name;
111
+		if(!serviceInfos[id]) {
112
+			var serviceInfo = serviceInfos[id] = {
113
+				isOurService: true,
114
+				service: service
115
+			}
116
+			sendAnnouncement(serviceInfo);
117
+		}
118
+	}
119
+
120
+	exports.renounceService = function(service) {
121
+		if (!service.host || !service.port || !service.name) {
122
+			return false;
123
+		}
124
+		var id = service.host + ":" + service.port + ":" + service.name;
125
+		if(serviceInfos[id] && serviceInfos[id].isOurService) {
126
+			sendRenouncement(serviceInfos[id]);
127
+			delete serviceInfos[id];
128
+		}
129
+	}
130
+
131
+	exports.queryForServices = function() {
132
+		queryForServices();
133
+	}
134
+
135
+	exports.on = function(eventName, callback) {
136
+		if(!events[eventName]) {
137
+			events[eventName] = {};
138
+		}
139
+		var callbackId = guid();
140
+		events[eventName][callbackId] = callback;
141
+		return callbackId;
142
+	}
143
+
144
+	exports.off = function(eventName, callbackId) {
145
+		if(!events[eventName]) {
146
+			return false;
147
+		}
148
+		delete events[eventName][callbackId];
149
+		return true;
150
+	}
151
+
152
+	exports.getServiceInfos = function() {
153
+		return JSON.parse(JSON.stringify(serviceInfos));
154
+	}
155
+
156
+	// =====
157
+	// Helper functions
158
+	// =====
159
+
160
+	function generalSuccessCallback(success) {
161
+		// ...
162
+	}
163
+
164
+	function generalFailCallback(error) {
165
+		// ...
166
+	}
167
+
168
+	function sendAnnouncement(serviceInfo) {
169
+		var serviceInfosToAnnounce = [];
170
+		if (serviceInfo instanceof Array) {
171
+			serviceInfosToAnnounce = serviceInfo;
172
+		} else {
173
+			serviceInfosToAnnounce = [serviceInfo];
174
+		}
175
+		var messageObject = {
176
+			eventType: "announce",
177
+			fromDiontInstance: instanceId,
178
+			serviceInfos: serviceInfosToAnnounce
179
+		}
180
+		var message = JSON.stringify(messageObject);
181
+		exec(generalSuccessCallback, generalFailCallback, 'Diont', 'send', [ instanceId, message, host, port ]);
182
+	}
183
+
184
+	function sendRenouncement(serviceInfo) {
185
+		var serviceInfosToRenounce = [];
186
+		if (serviceInfo instanceof Array) {
187
+			serviceInfosToRenounce = serviceInfo;
188
+		} else {
189
+			serviceInfosToRenounce = [serviceInfo];
190
+		}
191
+		var messageObject = {
192
+			eventType: "renounce",
193
+			fromDiontInstance: instanceId,
194
+			serviceInfos: serviceInfosToRenounce
195
+		}
196
+		var message = JSON.stringify(messageObject);
197
+		exec(generalSuccessCallback, generalFailCallback, 'Diont', 'send', [ instanceId, message, host, port ]);
198
+	}
199
+
200
+	function queryForServices() {
201
+		var messageObject = {
202
+			eventType: "query",
203
+			fromDiontInstance: instanceId
204
+		}
205
+		var message = JSON.stringify(messageObject);
206
+		exec(generalSuccessCallback, generalFailCallback, 'Diont', 'send', [ instanceId, message, host, port ]);
207
+	}
208
+
209
+	function guid() {
210
+		function s4() {
211
+			return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
212
+		}
213
+		return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
214
+	}
215
+
216
+	// =====
217
+	// Export
218
+	// =====
219
+
220
+	return exports;
221
+}

+ 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/).

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

@@ -0,0 +1,163 @@
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
+:warning: Report issues on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Whitelist%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC)
29
+
30
+## Installation
31
+
32
+You can install whitelist plugin with Cordova CLI, from npm:
33
+
34
+```
35
+$ cordova plugin add cordova-plugin-whitelist
36
+$ cordova prepare
37
+```
38
+
39
+## Supported Cordova Platforms
40
+
41
+* Android 4.0.0 or above
42
+
43
+## Navigation Whitelist
44
+Controls which URLs the WebView itself can be navigated to. Applies to
45
+top-level navigations only.
46
+
47
+Quirks: on Android it also applies to iframes for non-http(s) schemes.
48
+
49
+By default, navigations only to `file://` URLs, are allowed. To allow others URLs, you must add `<allow-navigation>` tags to your `config.xml`:
50
+
51
+    <!-- Allow links to example.com -->
52
+    <allow-navigation href="http://example.com/*" />
53
+
54
+    <!-- Wildcards are allowed for the protocol, as a prefix
55
+         to the host, or as a suffix to the path -->
56
+    <allow-navigation href="*://*.example.com/*" />
57
+
58
+    <!-- A wildcard can be used to whitelist the entire network,
59
+         over HTTP and HTTPS.
60
+         *NOT RECOMMENDED* -->
61
+    <allow-navigation href="*" />
62
+
63
+    <!-- The above is equivalent to these three declarations -->
64
+    <allow-navigation href="http://*/*" />
65
+    <allow-navigation href="https://*/*" />
66
+    <allow-navigation href="data:*" />
67
+
68
+## Intent Whitelist
69
+Controls which URLs the app is allowed to ask the system to open.
70
+By default, no external URLs are allowed.
71
+
72
+On Android, this equates to sending an intent of type BROWSEABLE.
73
+
74
+This whitelist does not apply to plugins, only hyperlinks and calls to `window.open()`.
75
+
76
+In `config.xml`, add `<allow-intent>` tags, like this:
77
+
78
+    <!-- Allow links to web pages to open in a browser -->
79
+    <allow-intent href="http://*/*" />
80
+    <allow-intent href="https://*/*" />
81
+
82
+    <!-- Allow links to example.com to open in a browser -->
83
+    <allow-intent href="http://example.com/*" />
84
+
85
+    <!-- Wildcards are allowed for the protocol, as a prefix
86
+         to the host, or as a suffix to the path -->
87
+    <allow-intent href="*://*.example.com/*" />
88
+
89
+    <!-- Allow SMS links to open messaging app -->
90
+    <allow-intent href="sms:*" />
91
+
92
+    <!-- Allow tel: links to open the dialer -->
93
+    <allow-intent href="tel:*" />
94
+
95
+    <!-- Allow geo: links to open maps -->
96
+    <allow-intent href="geo:*" />
97
+
98
+    <!-- Allow all unrecognized URLs to open installed apps
99
+         *NOT RECOMMENDED* -->
100
+    <allow-intent href="*" />
101
+
102
+## Network Request Whitelist
103
+Controls which network requests (images, XHRs, etc) are allowed to be made (via cordova native hooks).
104
+
105
+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.
106
+
107
+In `config.xml`, add `<access>` tags, like this:
108
+
109
+    <!-- Allow images, xhrs, etc. to google.com -->
110
+    <access origin="http://google.com" />
111
+    <access origin="https://google.com" />
112
+
113
+    <!-- Access to the subdomain maps.google.com -->
114
+    <access origin="http://maps.google.com" />
115
+
116
+    <!-- Access to all the subdomains on google.com -->
117
+    <access origin="http://*.google.com" />
118
+
119
+    <!-- Enable requests to content: URLs -->
120
+    <access origin="content:///*" />
121
+
122
+    <!-- Don't block any requests -->
123
+    <access origin="*" />
124
+
125
+Without any `<access>` tags, only requests to `file://` URLs are allowed. However, the default Cordova application includes `<access origin="*">` by default.
126
+
127
+
128
+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.
129
+
130
+Quirk: Android also allows requests to https://ssl.gstatic.com/accessibility/javascript/android/ by default, since this is required for TalkBack to function properly.
131
+
132
+### Content Security Policy
133
+Controls which network requests (images, XHRs, etc) are allowed to be made (via webview directly).
134
+
135
+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.
136
+
137
+On Android, support for CSP within the system webview starts with KitKat (but is available on all versions using Crosswalk WebView).
138
+
139
+Here are some example CSP declarations for your `.html` pages:
140
+
141
+    <!-- Good default declaration:
142
+        * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
143
+        * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
144
+        * Disables use of eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
145
+            * Enable inline JS: add 'unsafe-inline' to default-src
146
+            * Enable eval(): add 'unsafe-eval' to default-src
147
+    -->
148
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">
149
+
150
+    <!-- Allow everything but only from the same origin and foo.com -->
151
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' foo.com">
152
+
153
+    <!-- This policy allows everything (eg CSS, AJAX, object, frame, media, etc) except that 
154
+        * CSS only from the same origin and inline styles,
155
+        * scripts only from the same origin and inline styles, and eval()
156
+    -->
157
+    <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
158
+
159
+    <!-- Allows XHRs only over HTTPS on the same domain. -->
160
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' https:">
161
+
162
+    <!-- Allow iframe to https://cordova.apache.org/ -->
163
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self' https://cordova.apache.org">

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

@@ -0,0 +1,75 @@
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.3 (Nov 06, 2017)
24
+* [CB-12847](https://issues.apache.org/jira/browse/CB-12847) added `bugs` entry to `package.json`.
25
+
26
+### 1.3.2 (Feb 28, 2017)
27
+* [CB-12236](https://issues.apache.org/jira/browse/CB-12236) Fixed `RELEASENOTES` for `cordova-plugin-whitelist`
28
+
29
+### 1.3.1 (Dec 07, 2016)
30
+* [CB-12224](https://issues.apache.org/jira/browse/CB-12224) Updated version and RELEASENOTES.md for release 1.3.1
31
+* [CB-11917](https://issues.apache.org/jira/browse/CB-11917) - Remove pull request template checklist item: "iCLA has been submitted…"
32
+* Edit package.json license to match SPDX id
33
+* [CB-11832](https://issues.apache.org/jira/browse/CB-11832) Incremented plugin version.
34
+
35
+### 1.3.0 (Sep 08, 2016)
36
+* [CB-11795](https://issues.apache.org/jira/browse/CB-11795) Add 'protective' entry to cordovaDependencies
37
+* Updated installation section
38
+* Plugin uses `Android Log class` and not `Cordova LOG class`
39
+* Add pull request template.
40
+* [CB-10866](https://issues.apache.org/jira/browse/CB-10866) Adding engine info to `package.json`
41
+* [CB-10996](https://issues.apache.org/jira/browse/CB-10996) Adding front matter to README.md
42
+
43
+### 1.2.2 (Apr 15, 2016)
44
+* add note about redirects
45
+* [CB-10624](https://issues.apache.org/jira/browse/CB-10624) remove error message from `whitelist.js`, which leaves it empty
46
+
47
+### 1.2.1 (Jan 15, 2016)
48
+* [CB-10194](https://issues.apache.org/jira/browse/CB-10194) info tag prints for ios when not applicable
49
+
50
+### 1.2.0 (Nov 18, 2015)
51
+* removed **iOS** engine check from `plugin.xml`
52
+* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest
53
+* [CB-9972](https://issues.apache.org/jira/browse/CB-9972) - Remove **iOS** whitelist
54
+* Updated the text, it should read 4.0.x and greater, since this plugin will be required for `cordova-android 5.0`
55
+* Fixing contribute link.
56
+* Updated `plugin.xml <info>` tag to remove warning about not needing this plugin if you are using the **iOS 9 SDK**
57
+* [CB-9738](https://issues.apache.org/jira/browse/CB-9738) - Disable whitelist use when runtime environment is **iOS 9**
58
+* [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`
59
+* [CB-9568](https://issues.apache.org/jira/browse/CB-9568) - Update whitelist plugin to allow all network access by default
60
+* [CB-9337](https://issues.apache.org/jira/browse/CB-9337) - enable use of `<access>` tags for native code network requests
61
+
62
+### 1.1.0 (Jun 17, 2015)
63
+* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-whitelist documentation translation: cordova-plugin-whitelist
64
+* fix npm md issue
65
+* Usage of CDVURLRequestFilter protocol.
66
+* [CB-9089](https://issues.apache.org/jira/browse/CB-9089) - iOS whitelist plugin does not compile
67
+* [CB-9090](https://issues.apache.org/jira/browse/CB-9090) - Enable whitelist plugin for cordova-ios 4.0.0
68
+* Fixed error in Content-Security-Policy example
69
+
70
+### 1.0.0 (Mar 25, 2015)
71
+* [CB-8739](https://issues.apache.org/jira/browse/CB-8739) added missing license headers
72
+* Add @Override to CustomConfigXmlParser methods
73
+* Change ID to cordova-plugin-whitelist rather than reverse-DNS-style
74
+* Tweak CSP examples in README
75
+* [CB-8660](https://issues.apache.org/jira/browse/CB-8660) remove extra commas from package.json

+ 148 - 0
plugins/cordova-plugin-whitelist/doc/de/README.md

@@ -0,0 +1,148 @@
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
21
+
22
+Dieses Plugin implementiert eine Whitelist-Politik für die Navigation in der Anwendung Webview Cordova 4.0
23
+
24
+## Cordova unterstützte Plattformen
25
+
26
+  * Android 4.0.0 oder höher
27
+  * iOS 4.0.0 oder höher
28
+
29
+## Navigation-Whitelist
30
+
31
+Steuert, welche URLs die WebView selbst zu navigiert werden kann. Bezieht sich auf der obersten Ebene Navigationen nur.
32
+
33
+Macken: auf Android es gilt auch für Iframes für nicht-http(s) Systeme.
34
+
35
+In der Standardeinstellung Navigationen nur auf `file://` URLs, sind zulässig. Wenn andere andere URLs zulassen möchten, müssen Sie Ihre `"config.xml"` `<allow-navigation>` Markierungen hinzufügen:
36
+
37
+    <!-- Allow links to example.com -->
38
+    <allow-navigation href="http://example.com/*" />
39
+    
40
+    <!-- Wildcards are allowed for the protocol, as a prefix
41
+         to the host, or as a suffix to the path -->
42
+    <allow-navigation href="*://*.example.com/*" />
43
+    
44
+    <!-- A wildcard can be used to whitelist the entire network,
45
+         over HTTP and HTTPS.
46
+         *NOT RECOMMENDED* -->
47
+    <allow-navigation href="*" />
48
+    
49
+    <!-- The above is equivalent to these three declarations -->
50
+    <allow-navigation href="http://*/*" />
51
+    <allow-navigation href="https://*/*" />
52
+    <allow-navigation href="data:*" />
53
+    
54
+
55
+## Vorsatz-Whitelist
56
+
57
+Steuert, welche URLs die app zulässig ist, um das System zu öffnen Fragen. Standardmäßig dürfen keine externe URLs.
58
+
59
+Das entspricht auf Android eine Absicht des Typs BROWSEABLE senden.
60
+
61
+Diese Whitelist gilt nicht für Plugins, nur Hyperlinks und Aufrufe von `window.open()`.
62
+
63
+Fügen Sie in `"config.xml"` `<allow-intent>` Tags hinzu, wie folgt:
64
+
65
+    <!-- Allow links to web pages to open in a browser -->
66
+    <allow-intent href="http://*/*" />
67
+    <allow-intent href="https://*/*" />
68
+    
69
+    <!-- Allow links to example.com to open in a browser -->
70
+    <allow-intent href="http://example.com/*" />
71
+    
72
+    <!-- Wildcards are allowed for the protocol, as a prefix
73
+         to the host, or as a suffix to the path -->
74
+    <allow-intent href="*://*.example.com/*" />
75
+    
76
+    <!-- Allow SMS links to open messaging app -->
77
+    <allow-intent href="sms:*" />
78
+    
79
+    <!-- Allow tel: links to open the dialer -->
80
+    <allow-intent href="tel:*" />
81
+    
82
+    <!-- Allow geo: links to open maps -->
83
+    <allow-intent href="geo:*" />
84
+    
85
+    <!-- Allow all unrecognized URLs to open installed apps
86
+         *NOT RECOMMENDED* -->
87
+    <allow-intent href="*" />
88
+    
89
+
90
+## Netzwerk-Anforderung-Whitelist
91
+
92
+Steuert, welche-Anforderungen Netzwerk (Bilder, XHRs, etc.) dürfen (über Cordova native Haken) erfolgen.
93
+
94
+Hinweis: Wir empfehlen Ihnen eine Content Security Policy (siehe unten), das ist sicherer. Diese Whitelist ist vor allem historisch für Webansichten für die CSP nicht unterstützen.
95
+
96
+Fügen Sie in `"config.xml"` `<access>` Tags hinzu, wie folgt:
97
+
98
+    <!-- Allow images, xhrs, etc. to google.com -->
99
+    <access origin="http://google.com" />
100
+    <access origin="https://google.com" />
101
+    
102
+    <!-- Access to the subdomain maps.google.com -->
103
+    <access origin="http://maps.google.com" />
104
+    
105
+    <!-- Access to all the subdomains on google.com -->
106
+    <access origin="http://*.google.com" />
107
+    
108
+    <!-- Enable requests to content: URLs -->
109
+    <access origin="content:///*" />
110
+    
111
+    <!-- Don't block any requests -->
112
+    <access origin="*" />
113
+    
114
+
115
+Ohne `<access>` -Tags dürfen nur Anforderungen an `file://` URLs. Enthält jedoch die Standardanwendung Cordova `<access origin="*">` standardmäßig.
116
+
117
+Eigenart: Android kann auch Anforderungen an https://ssl.gstatic.com/accessibility/javascript/android/ standardmäßig, da dies für TalkBack ordnungsgemäß erforderlich ist.
118
+
119
+### Content-Security-Policy
120
+
121
+Steuert, welche-Anforderungen Netzwerk (Bilder, XHRs, etc.) dürfen (über Webview direkt) erfolgen.
122
+
123
+Auf Android und iOS ist die Netzwerk Anfrage Whitelist (s.o.) nicht in der Lage, alle Arten von Anfragen (z.B. `< video >` & WebSockets nicht blockiert) filtern. Also, sollten Sie neben der Whitelist, [Content Security Policy](http://content-security-policy.com/) `< Meta >` -Tags auf allen Ihren Seiten verwenden.
124
+
125
+Auf Android Unterstützung für CSP innerhalb der System-Webview beginnt mit KitKat (aber ist in allen Versionen mit Crosswalk WebView verfügbar).
126
+
127
+Hier sind einige Beispiel-CSP-Deklarationen für Ihre `HTML` -Seiten:
128
+
129
+    <!-- Good default declaration:
130
+        * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
131
+        * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
132
+        * Disables use of eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
133
+            * Enable inline JS: add 'unsafe-inline' to default-src
134
+            * Enable eval(): add 'unsafe-eval' to default-src
135
+    -->
136
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">
137
+    
138
+    <!-- Allow requests to foo.com -->
139
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' foo.com">
140
+    
141
+    <!-- Enable all requests, inline styles, and eval() -->
142
+    <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
143
+    
144
+    <!-- Allow XHRs via https only -->
145
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' https:">
146
+    
147
+    <!-- Allow iframe to https://cordova.apache.org/ -->
148
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self' https://cordova.apache.org">

+ 148 - 0
plugins/cordova-plugin-whitelist/doc/es/README.md

@@ -0,0 +1,148 @@
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
21
+
22
+Este plugin implementa una política de lista blanca para navegar la aplicación webview en Cordova 4.0
23
+
24
+## Plataformas soportadas Cordova
25
+
26
+  * Android 4.0 o superior
27
+  * iOS 4.0.0 o superior
28
+
29
+## Lista blanca de navegación
30
+
31
+Controla que las URLs del WebView se puede navegar a. Se aplica a nivel superior navegaciones solo.
32
+
33
+Peculiaridades: en Android también se aplica a iframes para esquemas que son de http (s).
34
+
35
+Por defecto, navegaciones solo a direcciones URL `file://` , son permitidas. Para permitir que otros otras URL, debe agregar `< allow-navegación >` etiquetas en el `archivo config.xml`:
36
+
37
+    <!-- Allow links to example.com -->
38
+    <allow-navigation href="http://example.com/*" />
39
+    
40
+    <!-- Wildcards are allowed for the protocol, as a prefix
41
+         to the host, or as a suffix to the path -->
42
+    <allow-navigation href="*://*.example.com/*" />
43
+    
44
+    <!-- A wildcard can be used to whitelist the entire network,
45
+         over HTTP and HTTPS.
46
+         *NOT RECOMMENDED* -->
47
+    <allow-navigation href="*" />
48
+    
49
+    <!-- The above is equivalent to these three declarations -->
50
+    <allow-navigation href="http://*/*" />
51
+    <allow-navigation href="https://*/*" />
52
+    <allow-navigation href="data:*" />
53
+    
54
+
55
+## Intención de lista blanca
56
+
57
+Controla qué URLs de la aplicación se permite hacer el sistema para abrir. De forma predeterminada, se permiten ninguÌ n external URLs.
58
+
59
+En Android, esto equivale a enviar una intención de tipo BROWSEABLE.
60
+
61
+Esta lista blanca no se aplica a plugins, sólo los hipervínculos y las llamadas a `window.Open)`.
62
+
63
+En `config.xml`, agregar etiquetas `< allow-intent >` , como este:
64
+
65
+    <!-- Allow links to web pages to open in a browser -->
66
+    <allow-intent href="http://*/*" />
67
+    <allow-intent href="https://*/*" />
68
+    
69
+    <!-- Allow links to example.com to open in a browser -->
70
+    <allow-intent href="http://example.com/*" />
71
+    
72
+    <!-- Wildcards are allowed for the protocol, as a prefix
73
+         to the host, or as a suffix to the path -->
74
+    <allow-intent href="*://*.example.com/*" />
75
+    
76
+    <!-- Allow SMS links to open messaging app -->
77
+    <allow-intent href="sms:*" />
78
+    
79
+    <!-- Allow tel: links to open the dialer -->
80
+    <allow-intent href="tel:*" />
81
+    
82
+    <!-- Allow geo: links to open maps -->
83
+    <allow-intent href="geo:*" />
84
+    
85
+    <!-- Allow all unrecognized URLs to open installed apps
86
+         *NOT RECOMMENDED* -->
87
+    <allow-intent href="*" />
88
+    
89
+
90
+## Solicitud de red blanca
91
+
92
+Controles que las peticiones de la red (imágenes, XHRs, etc.) se les permite hacer (a través de ganchos nativa de Córdoba).
93
+
94
+Nota: Le sugerimos que utilice una política de seguridad de contenido (véase abajo), que es más seguro. Esta lista blanca es sobre todo histórico para webviews que no admiten la CSP.
95
+
96
+En `config.xml`, agregue etiquetas de `< access >` , como este:
97
+
98
+    <!-- Allow images, xhrs, etc. to google.com -->
99
+    <access origin="http://google.com" />
100
+    <access origin="https://google.com" />
101
+    
102
+    <!-- Access to the subdomain maps.google.com -->
103
+    <access origin="http://maps.google.com" />
104
+    
105
+    <!-- Access to all the subdomains on google.com -->
106
+    <access origin="http://*.google.com" />
107
+    
108
+    <!-- Enable requests to content: URLs -->
109
+    <access origin="content:///*" />
110
+    
111
+    <!-- Don't block any requests -->
112
+    <access origin="*" />
113
+    
114
+
115
+Sin las etiquetas `< access >` , se admiten sólo las solicitudes a direcciones URL `file://` . Sin embargo, la aplicación por defecto de Cordova incluye `< access origin = "*" >` por defecto.
116
+
117
+Quirk: Android también permite las solicitudes de https://ssl.gstatic.com/accessibility/javascript/android/ por defecto, puesto que es necesario para TalkBack funcionar correctamente.
118
+
119
+### Política de seguridad de contenido
120
+
121
+Controles que las peticiones de la red (imágenes, XHRs, etc.) se les permite hacer (vía webview directamente).
122
+
123
+En iOS y Android, la red solicitud lista blanca (véase arriba) no es capaz de filtrar todos los tipos de solicitudes (por ejemplo, `< video >` y WebSockets no estén bloqueadas). Así, además de la lista blanca, usted debe utilizar una etiqueta `< meta >` de [Contenido la política de seguridad](http://content-security-policy.com/) en todas las páginas.
124
+
125
+En Android, soporte para CSP en el sistema webview comienza con KitKat (pero está disponible en todas las versiones con WebView de paso de peatones).
126
+
127
+Aquí están algunas declaraciones de CSP de ejemplo para las páginas `.html` :
128
+
129
+    <!-- Good default declaration:
130
+        * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
131
+        * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
132
+        * Disables use of eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
133
+            * Enable inline JS: add 'unsafe-inline' to default-src
134
+            * Enable eval(): add 'unsafe-eval' to default-src
135
+    -->
136
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">
137
+    
138
+    <!-- Allow requests to foo.com -->
139
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' foo.com">
140
+    
141
+    <!-- Enable all requests, inline styles, and eval() -->
142
+    <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
143
+    
144
+    <!-- Allow XHRs via https only -->
145
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' https:">
146
+    
147
+    <!-- Allow iframe to https://cordova.apache.org/ -->
148
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self' https://cordova.apache.org">

+ 148 - 0
plugins/cordova-plugin-whitelist/doc/fr/README.md

@@ -0,0 +1,148 @@
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
21
+
22
+Ce plugin met en œuvre une politique de liste blanche pour naviguer le webview application sur Cordova 4.0
23
+
24
+## Plates-formes prises en charge Cordova
25
+
26
+  * 4.0.0 Android ou supérieur
27
+  * iOS 4.0.0 ou supérieur
28
+
29
+## Navigation liste blanche
30
+
31
+Contrôle quels URL le WebView lui-même peut être parcourus à. S'applique à des navigations niveau supérieur seulement.
32
+
33
+Particularités : sur Android il s'applique également aux iframes pour non-schémas http (s).
34
+
35
+Par défaut, navigations qu'aux URL `file://` , sont autorisés. Pour permettre aux autres d'autres URL, vous devez ajouter des balises `<allow-navigation>` à votre `fichier config.xml`:
36
+
37
+    <!-- Allow links to example.com -->
38
+    <allow-navigation href="http://example.com/*" />
39
+    
40
+    <!-- Wildcards are allowed for the protocol, as a prefix
41
+         to the host, or as a suffix to the path -->
42
+    <allow-navigation href="*://*.example.com/*" />
43
+    
44
+    <!-- A wildcard can be used to whitelist the entire network,
45
+         over HTTP and HTTPS.
46
+         *NOT RECOMMENDED* -->
47
+    <allow-navigation href="*" />
48
+    
49
+    <!-- The above is equivalent to these three declarations -->
50
+    <allow-navigation href="http://*/*" />
51
+    <allow-navigation href="https://*/*" />
52
+    <allow-navigation href="data:*" />
53
+    
54
+
55
+## Intent Whitelist
56
+
57
+Contrôle quels URL l'app n'est autorisé à poser le système d'ouverture. Par défaut, aucun external URL est autorisés.
58
+
59
+Sur Android, cela équivaut à envoyer une intention de type BROWSEABLE.
60
+
61
+Cette autorisation ne s'applique pas aux plugins, uniquement les liens hypertexte et les appels à `window.open()`.
62
+
63
+Dans le `fichier config.xml`, ajouter des balises `<allow-intent>` , comme ceci :
64
+
65
+    <!-- Allow links to web pages to open in a browser -->
66
+    <allow-intent href="http://*/*" />
67
+    <allow-intent href="https://*/*" />
68
+    
69
+    <!-- Allow links to example.com to open in a browser -->
70
+    <allow-intent href="http://example.com/*" />
71
+    
72
+    <!-- Wildcards are allowed for the protocol, as a prefix
73
+         to the host, or as a suffix to the path -->
74
+    <allow-intent href="*://*.example.com/*" />
75
+    
76
+    <!-- Allow SMS links to open messaging app -->
77
+    <allow-intent href="sms:*" />
78
+    
79
+    <!-- Allow tel: links to open the dialer -->
80
+    <allow-intent href="tel:*" />
81
+    
82
+    <!-- Allow geo: links to open maps -->
83
+    <allow-intent href="geo:*" />
84
+    
85
+    <!-- Allow all unrecognized URLs to open installed apps
86
+         *NOT RECOMMENDED* -->
87
+    <allow-intent href="*" />
88
+    
89
+
90
+## Réseau demande liste blanche
91
+
92
+Les contrôles dont les demandes de réseau (images, XHRs, etc.) sont autorisés à effectuer (via cordova natif crochets).
93
+
94
+Remarque : Nous vous suggérons de qu'utiliser un contenu politique de sécurité (voir ci-dessous), qui est plus sûr. Cette liste blanche est surtout historique pour webviews qui ne prennent pas en charge les CSP.
95
+
96
+Dans le `fichier config.xml`, ajouter des balises `<access>` , comme ceci :
97
+
98
+    <!-- Allow images, xhrs, etc. to google.com -->
99
+    <access origin="http://google.com" />
100
+    <access origin="https://google.com" />
101
+    
102
+    <!-- Access to the subdomain maps.google.com -->
103
+    <access origin="http://maps.google.com" />
104
+    
105
+    <!-- Access to all the subdomains on google.com -->
106
+    <access origin="http://*.google.com" />
107
+    
108
+    <!-- Enable requests to content: URLs -->
109
+    <access origin="content:///*" />
110
+    
111
+    <!-- Don't block any requests -->
112
+    <access origin="*" />
113
+    
114
+
115
+Sans les balises `<access>` , seules les demandes d'URL `file://` sont autorisés. Toutefois, l'application de Cordoue par défaut inclut `<access origin="*" >` par défaut.
116
+
117
+Bizarrerie : Android permet également aux requêtes à https://ssl.gstatic.com/accessibility/javascript/android/ par défaut, puisque c'est nécessaire pour TalkBack fonctionner correctement.
118
+
119
+### Politique de sécurité du contenu
120
+
121
+Les contrôles dont les demandes de réseau (images, XHRs, etc.) sont autorisés à effectuer (via webview directement).
122
+
123
+Sur Android et iOS, la réseau demande liste blanche (voir ci-dessus) n'est pas en mesure de filtrer tous les types de demandes (p. ex. `< video >` & WebSockets ne sont pas bloquées). Ainsi, en plus de la liste blanche, vous devez utiliser une balise `< meta >` de [Contenu politique de sécurité](http://content-security-policy.com/) sur toutes vos pages.
124
+
125
+Sur Android, support pour le CSP dans le système webview commence par KitKat (mais n'est disponible sur toutes les versions à l'aide du tableau de concordance WebView).
126
+
127
+Voici quelques exemples de déclarations de CSP pour vos pages `.html` :
128
+
129
+    <!-- Good default declaration:
130
+        * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
131
+        * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
132
+        * Disables use of eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
133
+            * Enable inline JS: add 'unsafe-inline' to default-src
134
+            * Enable eval(): add 'unsafe-eval' to default-src
135
+    -->
136
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">
137
+    
138
+    <!-- Allow requests to foo.com -->
139
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' foo.com">
140
+    
141
+    <!-- Enable all requests, inline styles, and eval() -->
142
+    <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
143
+    
144
+    <!-- Allow XHRs via https only -->
145
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' https:">
146
+    
147
+    <!-- Allow iframe to https://cordova.apache.org/ -->
148
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self' https://cordova.apache.org">

+ 148 - 0
plugins/cordova-plugin-whitelist/doc/it/README.md

@@ -0,0 +1,148 @@
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
21
+
22
+Questo plugin attua una politica di whitelist per spostarsi all'interno dell'applicazione webview in Cordova 4.0
23
+
24
+## Piattaforme supportate Cordova
25
+
26
+  * Android 4.0.0 o superiore
27
+  * iOS 4.0.0 o superiore
28
+
29
+## Navigazione Whitelist
30
+
31
+Controlla quali URL WebView stessa può essere esplorato. Si applica al solo primo livello navigazioni.
32
+
33
+Stranezze: su Android vale anche per gli iframe per non-schemi di http (s).
34
+
35
+Per impostazione predefinita, navigazioni solo agli URL `file://` , sono ammessi. Per consentire altri altri URL, è necessario aggiungere `<allow-navigation>` tag per il tuo `config. XML`:
36
+
37
+    <!-- Allow links to example.com -->
38
+    <allow-navigation href="http://example.com/*" />
39
+    
40
+    <!-- Wildcards are allowed for the protocol, as a prefix
41
+         to the host, or as a suffix to the path -->
42
+    <allow-navigation href="*://*.example.com/*" />
43
+    
44
+    <!-- A wildcard can be used to whitelist the entire network,
45
+         over HTTP and HTTPS.
46
+         *NOT RECOMMENDED* -->
47
+    <allow-navigation href="*" />
48
+    
49
+    <!-- The above is equivalent to these three declarations -->
50
+    <allow-navigation href="http://*/*" />
51
+    <allow-navigation href="https://*/*" />
52
+    <allow-navigation href="data:*" />
53
+    
54
+
55
+## Whitelist intento
56
+
57
+Controlla quali URL app è consentito richiedere il sistema di apertura. Per impostazione predefinita, nessun esterno URL sono ammessi.
58
+
59
+Su Android, ciò equivale all'invio di un intento di tipo BROWSEABLE.
60
+
61
+Questa whitelist non si applica ai plugin, solo i collegamenti ipertestuali e chiamate a `Window`.
62
+
63
+In `config. XML`, aggiungere tag `<allow-intent>` , simile al seguente:
64
+
65
+    <!-- Allow links to web pages to open in a browser -->
66
+    <allow-intent href="http://*/*" />
67
+    <allow-intent href="https://*/*" />
68
+    
69
+    <!-- Allow links to example.com to open in a browser -->
70
+    <allow-intent href="http://example.com/*" />
71
+    
72
+    <!-- Wildcards are allowed for the protocol, as a prefix
73
+         to the host, or as a suffix to the path -->
74
+    <allow-intent href="*://*.example.com/*" />
75
+    
76
+    <!-- Allow SMS links to open messaging app -->
77
+    <allow-intent href="sms:*" />
78
+    
79
+    <!-- Allow tel: links to open the dialer -->
80
+    <allow-intent href="tel:*" />
81
+    
82
+    <!-- Allow geo: links to open maps -->
83
+    <allow-intent href="geo:*" />
84
+    
85
+    <!-- Allow all unrecognized URLs to open installed apps
86
+         *NOT RECOMMENDED* -->
87
+    <allow-intent href="*" />
88
+    
89
+
90
+## Rete richiesta Whitelist
91
+
92
+Controlli che le richieste di rete (immagini, XHRs, ecc.) sono consentiti (tramite ganci nativo di cordova).
93
+
94
+Nota: Si consiglia di che utilizzare un criterio di protezione contenuti (Vedi sotto), che è più sicuro. La whitelist è principalmente storico per visualizzazioni Web che non supportano la CSP.
95
+
96
+In `config. XML`, aggiungere tag `< access >` , simile al seguente:
97
+
98
+    <!-- Allow images, xhrs, etc. to google.com -->
99
+    <access origin="http://google.com" />
100
+    <access origin="https://google.com" />
101
+    
102
+    <!-- Access to the subdomain maps.google.com -->
103
+    <access origin="http://maps.google.com" />
104
+    
105
+    <!-- Access to all the subdomains on google.com -->
106
+    <access origin="http://*.google.com" />
107
+    
108
+    <!-- Enable requests to content: URLs -->
109
+    <access origin="content:///*" />
110
+    
111
+    <!-- Don't block any requests -->
112
+    <access origin="*" />
113
+    
114
+
115
+Senza qualsiasi tag `< access >` , sono consentite solo le richieste di URL `file://` . Tuttavia, l'applicazione di Cordova predefinito include `< access origin = "*" >` per impostazione predefinita.
116
+
117
+Stranezza: Android consente anche alle richieste di https://ssl.gstatic.com/accessibility/javascript/android/ per impostazione predefinita, poiché questa operazione è necessaria per TalkBack funzionare correttamente.
118
+
119
+### Politica di sicurezza del contenuto
120
+
121
+Controlli che le richieste di rete (immagini, XHRs, ecc.) possono essere effettuate (via webview direttamente).
122
+
123
+Su Android e iOS, la rete richiesta whitelist (Vedi sopra) non è in grado di filtrare tutti i tipi di richieste (ad esempio non sono bloccate `< video >` & WebSockets). Così, oltre alla whitelist, è necessario utilizzare un tag `< meta >` [Content Security Policy](http://content-security-policy.com/) su tutte le pagine.
124
+
125
+Su Android, supporto per CSP all'interno webview sistema inizia con KitKat (ma è disponibile su tutte le versioni usando Crosswalk WebView).
126
+
127
+Ecco alcuni esempi di dichiarazioni di CSP per le pagine `HTML` :
128
+
129
+    <!-- Good default declaration:
130
+        * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
131
+        * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
132
+        * Disables use of eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
133
+            * Enable inline JS: add 'unsafe-inline' to default-src
134
+            * Enable eval(): add 'unsafe-eval' to default-src
135
+    -->
136
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">
137
+    
138
+    <!-- Allow requests to foo.com -->
139
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' foo.com">
140
+    
141
+    <!-- Enable all requests, inline styles, and eval() -->
142
+    <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
143
+    
144
+    <!-- Allow XHRs via https only -->
145
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' https:">
146
+    
147
+    <!-- Allow iframe to https://cordova.apache.org/ -->
148
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self' https://cordova.apache.org">

+ 148 - 0
plugins/cordova-plugin-whitelist/doc/ja/README.md

@@ -0,0 +1,148 @@
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
21
+
22
+このプラグイン実装コルドバ 4.0 アプリケーション webview をナビゲートするためのホワイト リスト ポリシー
23
+
24
+## サポートされているコルドバのプラットフォーム
25
+
26
+  * アンドロイド 4.0.0 以上
27
+  * iOS 4.0.0 以上
28
+
29
+## ナビゲーションのホワイト リスト
30
+
31
+WebView 自体に移動に Url を制御します。最上位ナビゲーションのみに適用されます。
32
+
33
+癖: Android にもに適用されますの iframe 非-[http スキーム。
34
+
35
+既定では、ナビゲーション、 `file://`の Url にのみ許可されます。その他の他の Url を許可するように、 `config.xml`に`<allow-navigation>`タグを追加する必要があります。
36
+
37
+    <!-- Allow links to example.com -->
38
+    <allow-navigation href="http://example.com/*" />
39
+    
40
+    <!-- Wildcards are allowed for the protocol, as a prefix
41
+         to the host, or as a suffix to the path -->
42
+    <allow-navigation href="*://*.example.com/*" />
43
+    
44
+    <!-- A wildcard can be used to whitelist the entire network,
45
+         over HTTP and HTTPS.
46
+         *NOT RECOMMENDED* -->
47
+    <allow-navigation href="*" />
48
+    
49
+    <!-- The above is equivalent to these three declarations -->
50
+    <allow-navigation href="http://*/*" />
51
+    <allow-navigation href="https://*/*" />
52
+    <allow-navigation href="data:*" />
53
+    
54
+
55
+## インテントのホワイト リスト
56
+
57
+どの Url を開くようにシステムを聞いて、アプリに許可を制御します。 既定では、外部 Url 許可されません。
58
+
59
+人造人間、これは型 BROWSEABLE の意図を送信することに相当します。
60
+
61
+このホワイト リストはプラグインのみハイパーリンクおよび`window.open()`への呼び出しには適用されません。.
62
+
63
+`Config.xml`内の`<allow-intent>`タグは、このようなを追加します。
64
+
65
+    <!-- Allow links to web pages to open in a browser -->
66
+    <allow-intent href="http://*/*" />
67
+    <allow-intent href="https://*/*" />
68
+    
69
+    <!-- Allow links to example.com to open in a browser -->
70
+    <allow-intent href="http://example.com/*" />
71
+    
72
+    <!-- Wildcards are allowed for the protocol, as a prefix
73
+         to the host, or as a suffix to the path -->
74
+    <allow-intent href="*://*.example.com/*" />
75
+    
76
+    <!-- Allow SMS links to open messaging app -->
77
+    <allow-intent href="sms:*" />
78
+    
79
+    <!-- Allow tel: links to open the dialer -->
80
+    <allow-intent href="tel:*" />
81
+    
82
+    <!-- Allow geo: links to open maps -->
83
+    <allow-intent href="geo:*" />
84
+    
85
+    <!-- Allow all unrecognized URLs to open installed apps
86
+         *NOT RECOMMENDED* -->
87
+    <allow-intent href="*" />
88
+    
89
+
90
+## ネットワーク要求のホワイト リスト
91
+
92
+ネットワーク要求コントロール (画像、XHRs 等) (コルドバ ネイティブ フック) を介して行われることが。
93
+
94
+注: より安全なコンテンツ セキュリティ ポリシー (下記参照) を使用してお勧めします。 このホワイト リストほとんどの CSP をサポートしていない web 表示のために歴史的です。
95
+
96
+`Config.xml`内のこのような`<access>`タグを追加します。
97
+
98
+    <!-- Allow images, xhrs, etc. to google.com -->
99
+    <access origin="http://google.com" />
100
+    <access origin="https://google.com" />
101
+    
102
+    <!-- Access to the subdomain maps.google.com -->
103
+    <access origin="http://maps.google.com" />
104
+    
105
+    <!-- Access to all the subdomains on google.com -->
106
+    <access origin="http://*.google.com" />
107
+    
108
+    <!-- Enable requests to content: URLs -->
109
+    <access origin="content:///*" />
110
+    
111
+    <!-- Don't block any requests -->
112
+    <access origin="*" />
113
+    
114
+
115
+`<access>`タグ、なし`file://` Url に要求のみを許可します。 ただし、既定のコルドバ アプリケーションが含まれています`<access origin="*">`デフォルトで。
116
+
117
+気まぐれ: アンドロイドも要求できます https://ssl.gstatic.com/accessibility/javascript/android/デフォルトでは、トークが正常に機能するために必要ですので。
118
+
119
+### コンテンツのセキュリティ ポリシー
120
+
121
+ネットワーク要求コントロール (画像、XHRs 等) (直接 webview) を介して行われることが。
122
+
123
+Android と iOS は、ネットワーク要求ホワイト リスト (上記参照) はすべての種類の要求 (例: `< ビデオ >` & Websocket がふさがれていない) をフィルター処理できません。 だから、ホワイト リストに加えてすべてのページに[コンテンツ セキュリティ ポリシー](http://content-security-policy.com/) `< meta >`タグを使用する必要があります。
124
+
125
+Android 上システム webview 内 CSP サポート キットカットから始まります (しかし横断歩道 WebView を使用してすべてのバージョンで利用可能です)。
126
+
127
+`.Html`ページのいくつかの例 CSP の宣言は次のとおりです。
128
+
129
+    <!-- Good default declaration:
130
+        * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
131
+        * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
132
+        * Disables use of eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
133
+            * Enable inline JS: add 'unsafe-inline' to default-src
134
+            * Enable eval(): add 'unsafe-eval' to default-src
135
+    -->
136
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">
137
+    
138
+    <!-- Allow requests to foo.com -->
139
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' foo.com">
140
+    
141
+    <!-- Enable all requests, inline styles, and eval() -->
142
+    <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
143
+    
144
+    <!-- Allow XHRs via https only -->
145
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' https:">
146
+    
147
+    <!-- Allow iframe to https://cordova.apache.org/ -->
148
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self' https://cordova.apache.org">

+ 148 - 0
plugins/cordova-plugin-whitelist/doc/ko/README.md

@@ -0,0 +1,148 @@
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
21
+
22
+이 플러그인 구현 코르도바 4.0 응용 프로그램 webview를 탐색에 대 한 허용 정책
23
+
24
+## 지원된 코르도바 플랫폼
25
+
26
+  * 안 드 로이드 4.0.0 이상
27
+  * iOS 4.0.0 이상
28
+
29
+## 탐색 허용
30
+
31
+WebView 자체가 탐색할 수 있는 Url을 제어 합니다. 최상위 탐색에만 적용 됩니다.
32
+
33
+단점: 안 드 로이드에도 적용 됩니다 iframe에 대 한 비-프로토콜인 계획.
34
+
35
+기본적으로 탐색 `file://` Url에만 사용할 수 있습니다. 다른 다른 Url을 허용 하려면 `config.xml`에 `< allow-navigation >` 태그를 추가 해야 합니다.
36
+
37
+    <!-- Allow links to example.com -->
38
+    <allow-navigation href="http://example.com/*" />
39
+    
40
+    <!-- Wildcards are allowed for the protocol, as a prefix
41
+         to the host, or as a suffix to the path -->
42
+    <allow-navigation href="*://*.example.com/*" />
43
+    
44
+    <!-- A wildcard can be used to whitelist the entire network,
45
+         over HTTP and HTTPS.
46
+         *NOT RECOMMENDED* -->
47
+    <allow-navigation href="*" />
48
+    
49
+    <!-- The above is equivalent to these three declarations -->
50
+    <allow-navigation href="http://*/*" />
51
+    <allow-navigation href="https://*/*" />
52
+    <allow-navigation href="data:*" />
53
+    
54
+
55
+## 의도 허용
56
+
57
+App 시스템 열을 게 허용 되는 Url을 제어 합니다. 기본적으로 외부 Url은 사용할 수 있습니다.
58
+
59
+안 드 로이드에이 형식의 BROWSEABLE 의도 보내는 것 같습니다.
60
+
61
+이 허용 된 플러그인, 하이퍼링크 및 `window.open ()` 호출에 적용 되지 않습니다..
62
+
63
+`Config.xml`에이 같은 `< allow-intent >` 태그를 추가 합니다.
64
+
65
+    <!-- Allow links to web pages to open in a browser -->
66
+    <allow-intent href="http://*/*" />
67
+    <allow-intent href="https://*/*" />
68
+    
69
+    <!-- Allow links to example.com to open in a browser -->
70
+    <allow-intent href="http://example.com/*" />
71
+    
72
+    <!-- Wildcards are allowed for the protocol, as a prefix
73
+         to the host, or as a suffix to the path -->
74
+    <allow-intent href="*://*.example.com/*" />
75
+    
76
+    <!-- Allow SMS links to open messaging app -->
77
+    <allow-intent href="sms:*" />
78
+    
79
+    <!-- Allow tel: links to open the dialer -->
80
+    <allow-intent href="tel:*" />
81
+    
82
+    <!-- Allow geo: links to open maps -->
83
+    <allow-intent href="geo:*" />
84
+    
85
+    <!-- Allow all unrecognized URLs to open installed apps
86
+         *NOT RECOMMENDED* -->
87
+    <allow-intent href="*" />
88
+    
89
+
90
+## 네트워크 요청 허용
91
+
92
+요청을 네트워크 컨트롤 (이미지, XHRs, 등) (코르도바 네이티브 후크)를 통해 할 수 있습니다.
93
+
94
+참고: 당신이 사용 콘텐츠 보안 정책 (아래 참조), 더 안전한 것이 좋습니다. 이 허용은 CSP를 지원 하지 않는 webviews에 대 한 역사적.
95
+
96
+`Config.xml`에이 같은 `< access >` 태그를 추가 합니다.
97
+
98
+    <!-- Allow images, xhrs, etc. to google.com -->
99
+    <access origin="http://google.com" />
100
+    <access origin="https://google.com" />
101
+    
102
+    <!-- Access to the subdomain maps.google.com -->
103
+    <access origin="http://maps.google.com" />
104
+    
105
+    <!-- Access to all the subdomains on google.com -->
106
+    <access origin="http://*.google.com" />
107
+    
108
+    <!-- Enable requests to content: URLs -->
109
+    <access origin="content:///*" />
110
+    
111
+    <!-- Don't block any requests -->
112
+    <access origin="*" />
113
+    
114
+
115
+어떤 `< access >` 태그 없이 요청 `file://` Url 사용할 수 있습니다. 그러나 기본 코르도바 응용 프로그램을 포함 하는, `< access origin="*" >` 기본적으로.
116
+
117
+특질: 안 드 로이드 또한 수 있습니다 요청을 https://ssl.gstatic.com/accessibility/javascript/android/ 기본적으로 필요 제대로 작동 하려면 의견 이므로.
118
+
119
+### 콘텐츠 보안 정책
120
+
121
+요청을 네트워크 컨트롤 (이미지, XHRs, 등) (webview 직접)를 통해 할 수 있습니다.
122
+
123
+안 드 로이드와 iOS에 네트워크 요청 허용 (위 참조)는 모든 종류의 요청 (예: `< 비디오 >` & WebSockets 차단 되지 않습니다)를 필터링 할 수 없습니다. 그래서, 허용, 뿐만 아니라 귀하의 모든 페이지에 [콘텐츠 보안 정책](http://content-security-policy.com/) `< meta >` 태그를 사용 해야 합니다.
124
+
125
+안 드 로이드, 시스템 webview 내에서 CSP에 대 한 지원을 KitKat 시작 (하지만 횡단 보도 WebView를 사용 하 여 모든 버전에서 사용할 수).
126
+
127
+다음은 `.html` 페이지에 대 한 몇 가지 예제 CSP 선언입니다.
128
+
129
+    <!-- Good default declaration:
130
+        * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
131
+        * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
132
+        * Disables use of eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
133
+            * Enable inline JS: add 'unsafe-inline' to default-src
134
+            * Enable eval(): add 'unsafe-eval' to default-src
135
+    -->
136
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">
137
+    
138
+    <!-- Allow requests to foo.com -->
139
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' foo.com">
140
+    
141
+    <!-- Enable all requests, inline styles, and eval() -->
142
+    <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
143
+    
144
+    <!-- Allow XHRs via https only -->
145
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' https:">
146
+    
147
+    <!-- Allow iframe to https://cordova.apache.org/ -->
148
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self' https://cordova.apache.org">

+ 148 - 0
plugins/cordova-plugin-whitelist/doc/pl/README.md

@@ -0,0 +1,148 @@
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
21
+
22
+Ten plugin wdraża polityki białej nawigacja widoku sieci Web aplikacji na Cordova 4.0
23
+
24
+## Cordova obsługiwanych platform
25
+
26
+  * Android 4.0.0 lub powyżej
27
+  * iOS 4.0.0 lub powyżej
28
+
29
+## Biała lista nawigacji
30
+
31
+Kontroluje, których adresy URL widoku sieci Web, samej można nawigować do. Dotyczy tylko najwyższego poziomu nawigacje.
32
+
33
+Dziwactwa: na Android to dotyczy także IFRAME do nie-http (s) systemów.
34
+
35
+Domyślnie, nawigacje tylko do URLi `file://` , są dozwolone. Aby zezwolić na inne adresy URL, należy dodać Tagi `< allow-navigation >` do pliku `config.xml`:
36
+
37
+    <!-- Allow links to example.com -->
38
+    <allow-navigation href="http://example.com/*" />
39
+    
40
+    <!-- Wildcards are allowed for the protocol, as a prefix
41
+         to the host, or as a suffix to the path -->
42
+    <allow-navigation href="*://*.example.com/*" />
43
+    
44
+    <!-- A wildcard can be used to whitelist the entire network,
45
+         over HTTP and HTTPS.
46
+         *NOT RECOMMENDED* -->
47
+    <allow-navigation href="*" />
48
+    
49
+    <!-- The above is equivalent to these three declarations -->
50
+    <allow-navigation href="http://*/*" />
51
+    <allow-navigation href="https://*/*" />
52
+    <allow-navigation href="data:*" />
53
+    
54
+
55
+## Zamiarem biała
56
+
57
+Kontroluje, których adresy URL aplikacji jest możliwość zapytać systemem otwierania. Domyślnie nie ma zewnętrznych adresów URL są dozwolone.
58
+
59
+Na Android to przyrównuje do wysyłania zamiarem typu BROWSEABLE.
60
+
61
+Ta biała nie ma zastosowania do pluginów, tylko hiperłącza i wywołania `window.open()`.
62
+
63
+W `pliku config.xml`dodawanie tagów `< allow-intent >` , jak to:
64
+
65
+    <!-- Allow links to web pages to open in a browser -->
66
+    <allow-intent href="http://*/*" />
67
+    <allow-intent href="https://*/*" />
68
+    
69
+    <!-- Allow links to example.com to open in a browser -->
70
+    <allow-intent href="http://example.com/*" />
71
+    
72
+    <!-- Wildcards are allowed for the protocol, as a prefix
73
+         to the host, or as a suffix to the path -->
74
+    <allow-intent href="*://*.example.com/*" />
75
+    
76
+    <!-- Allow SMS links to open messaging app -->
77
+    <allow-intent href="sms:*" />
78
+    
79
+    <!-- Allow tel: links to open the dialer -->
80
+    <allow-intent href="tel:*" />
81
+    
82
+    <!-- Allow geo: links to open maps -->
83
+    <allow-intent href="geo:*" />
84
+    
85
+    <!-- Allow all unrecognized URLs to open installed apps
86
+         *NOT RECOMMENDED* -->
87
+    <allow-intent href="*" />
88
+    
89
+
90
+## Sieci wniosek biała
91
+
92
+Formanty, które sieci żądań (obrazy, XHRs, itp.) mogą być wykonane (za pośrednictwem cordova rodzimych haki).
93
+
94
+Uwaga: Zalecamy, że używasz treści polityki bezpieczeństwa (patrz poniżej), który jest bardziej bezpieczne. Ta Biała jest głównie historyczne dla webviews, które nie obsługują CSP.
95
+
96
+W `pliku config.xml`dodawanie tagów `< access >` , jak to:
97
+
98
+    <!-- Allow images, xhrs, etc. to google.com -->
99
+    <access origin="http://google.com" />
100
+    <access origin="https://google.com" />
101
+    
102
+    <!-- Access to the subdomain maps.google.com -->
103
+    <access origin="http://maps.google.com" />
104
+    
105
+    <!-- Access to all the subdomains on google.com -->
106
+    <access origin="http://*.google.com" />
107
+    
108
+    <!-- Enable requests to content: URLs -->
109
+    <access origin="content:///*" />
110
+    
111
+    <!-- Don't block any requests -->
112
+    <access origin="*" />
113
+    
114
+
115
+Bez żadnych tagów `< access >` dozwolone są tylko żądania do URLi `file://` . Jednak domyślnie Cordova aplikacja zawiera `< access origin = "*" >` domyślnie.
116
+
117
+Cokół: Android pozwala również żądania do https://ssl.gstatic.com/accessibility/javascript/android/ domyślnie, ponieważ jest to wymagane dla TalkBack wobec funkcja poprawnie.
118
+
119
+### Zasady zabezpieczeń zawartości
120
+
121
+Formanty, które sieci żądań (obrazy, XHRs, itp.) mogą być wykonane (za pomocą widoku sieci Web bezpośrednio).
122
+
123
+Na Androida i iOS biała żądanie sieci (patrz wyżej) nie jest w stanie filtrować wszystkie rodzaje wniosków (np. `< video >` & WebSockets nie są zablokowane). Tak oprócz białej listy, należy użyć tagu `< meta >` [Treści polityki bezpieczeństwa](http://content-security-policy.com/) na wszystkich stronach.
124
+
125
+Na Android wsparcie dla CSP w ramach systemu widoku sieci Web zaczyna KitKat (ale jest dostępne we wszystkich wersjach przy użyciu widoku sieci Web przejście dla pieszych).
126
+
127
+Oto niektóre przykład CSP deklaracje dla strony `HTML` :
128
+
129
+    <!-- Good default declaration:
130
+        * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
131
+        * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
132
+        * Disables use of eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
133
+            * Enable inline JS: add 'unsafe-inline' to default-src
134
+            * Enable eval(): add 'unsafe-eval' to default-src
135
+    -->
136
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">
137
+    
138
+    <!-- Allow requests to foo.com -->
139
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' foo.com">
140
+    
141
+    <!-- Enable all requests, inline styles, and eval() -->
142
+    <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
143
+    
144
+    <!-- Allow XHRs via https only -->
145
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' https:">
146
+    
147
+    <!-- Allow iframe to https://cordova.apache.org/ -->
148
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self' https://cordova.apache.org">

+ 148 - 0
plugins/cordova-plugin-whitelist/doc/zh/README.md

@@ -0,0 +1,148 @@
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
21
+
22
+這個外掛程式實現一個用於導航在科爾多瓦 4.0 應用程式 web 視圖的白名單策略
23
+
24
+## 支援的科爾多瓦平臺
25
+
26
+  * Android 4.0.0 或以上
27
+  * iOS 4.0.0 或以上
28
+
29
+## 導航白名單
30
+
31
+控制 web 視圖本身可以導航到的 Url。適用于頂級導航只。
32
+
33
+怪癖: 在 Android 上它也適用于 iframe 的非-結計畫。
34
+
35
+預設情況下,只有到`file://` Url 導航允許。若要允許其他其他 Url,必須將`<allow-navigation>`標籤添加到您的`config.xml`:
36
+
37
+    <!-- Allow links to example.com -->
38
+    <allow-navigation href="http://example.com/*" />
39
+    
40
+    <!-- Wildcards are allowed for the protocol, as a prefix
41
+         to the host, or as a suffix to the path -->
42
+    <allow-navigation href="*://*.example.com/*" />
43
+    
44
+    <!-- A wildcard can be used to whitelist the entire network,
45
+         over HTTP and HTTPS.
46
+         *NOT RECOMMENDED* -->
47
+    <allow-navigation href="*" />
48
+    
49
+    <!-- The above is equivalent to these three declarations -->
50
+    <allow-navigation href="http://*/*" />
51
+    <allow-navigation href="https://*/*" />
52
+    <allow-navigation href="data:*" />
53
+    
54
+
55
+## 科爾多瓦-外掛程式-白名單
56
+
57
+控制應用程式允許讓系統打開的 Url。 預設情況下,沒有外部 Url 允許。
58
+
59
+在 android 系統,這相當於發送類型 BROWSEABLE 的意圖。
60
+
61
+此白名單並不適用于只超連結和對`window.open ()`調用的外掛程式.
62
+
63
+在`config.xml`中添加`<allow-intent>`標籤,像這樣:
64
+
65
+    <!-- Allow links to web pages to open in a browser -->
66
+    <allow-intent href="http://*/*" />
67
+    <allow-intent href="https://*/*" />
68
+    
69
+    <!-- Allow links to example.com to open in a browser -->
70
+    <allow-intent href="http://example.com/*" />
71
+    
72
+    <!-- Wildcards are allowed for the protocol, as a prefix
73
+         to the host, or as a suffix to the path -->
74
+    <allow-intent href="*://*.example.com/*" />
75
+    
76
+    <!-- Allow SMS links to open messaging app -->
77
+    <allow-intent href="sms:*" />
78
+    
79
+    <!-- Allow tel: links to open the dialer -->
80
+    <allow-intent href="tel:*" />
81
+    
82
+    <!-- Allow geo: links to open maps -->
83
+    <allow-intent href="geo:*" />
84
+    
85
+    <!-- Allow all unrecognized URLs to open installed apps
86
+         *NOT RECOMMENDED* -->
87
+    <allow-intent href="*" />
88
+    
89
+
90
+## 網路請求白名單
91
+
92
+網路請求的控制項 (圖像,XHRs 等) 允許 (通過科爾多瓦本機掛鉤)。
93
+
94
+注意: 我們建議你使用內容的安全性原則 (見下文),這是更安全。 此白名單大多是為 webviews 不支援 CSP 的歷史。
95
+
96
+在`config.xml`中添加`<access>`標記,像這樣:
97
+
98
+    <!-- Allow images, xhrs, etc. to google.com -->
99
+    <access origin="http://google.com" />
100
+    <access origin="https://google.com" />
101
+    
102
+    <!-- Access to the subdomain maps.google.com -->
103
+    <access origin="http://maps.google.com" />
104
+    
105
+    <!-- Access to all the subdomains on google.com -->
106
+    <access origin="http://*.google.com" />
107
+    
108
+    <!-- Enable requests to content: URLs -->
109
+    <access origin="content:///*" />
110
+    
111
+    <!-- Don't block any requests -->
112
+    <access origin="*" />
113
+    
114
+
115
+沒有任何`<access>`標籤,只到`file://` Url 允許請求。 但是,預設的科爾多瓦應用程式包括`<access origin="*">` ,預設情況。
116
+
117
+怪癖: Android 還允許對 HTTPs://ssl.gstatic.com/accessibility/javascript/android/ 請求預設情況下,因為這是對講正常所需。
118
+
119
+### 內容安全政策
120
+
121
+網路請求的控制項 (圖像,XHRs 等) 允許 (通過 web 視圖直接)。
122
+
123
+對 Android 和 iOS,網路請求白名單 (見上文) 是不能夠過濾所有類型的請求 (例如`<video>` & Websocket 未被阻止)。 那麼,除了白名單中,你應使用[內容安全性原則](http://content-security-policy.com/) `< 元 >`標記您的所有頁面。
124
+
125
+在 android 系統,對 CSP 系統 web 視圖的支援開始奇巧 (但是是上使用 web 視圖人行橫道上的所有版本可用)。
126
+
127
+下面是一些示例 CSP 聲明為`.html`頁面:
128
+
129
+    <!-- Good default declaration:
130
+        * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
131
+        * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
132
+        * Disables use of eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
133
+            * Enable inline JS: add 'unsafe-inline' to default-src
134
+            * Enable eval(): add 'unsafe-eval' to default-src
135
+    -->
136
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">
137
+    
138
+    <!-- Allow requests to foo.com -->
139
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' foo.com">
140
+    
141
+    <!-- Enable all requests, inline styles, and eval() -->
142
+    <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
143
+    
144
+    <!-- Allow XHRs via https only -->
145
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self' https:">
146
+    
147
+    <!-- Allow iframe to https://cordova.apache.org/ -->
148
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self' https://cordova.apache.org">

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

@@ -0,0 +1,64 @@
1
+{
2
+  "_from": "cordova-plugin-whitelist@1",
3
+  "_id": "cordova-plugin-whitelist@1.3.3",
4
+  "_inBundle": false,
5
+  "_integrity": "sha1-tehezbv+Wu3tQKG/TuI3LmfZb7Q=",
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
+    "#USER",
20
+    "/"
21
+  ],
22
+  "_resolved": "http://registry.npm.taobao.org/cordova-plugin-whitelist/download/cordova-plugin-whitelist-1.3.3.tgz",
23
+  "_shasum": "b5e85ecdbbfe5aeded40a1bf4ee2372e67d96fb4",
24
+  "_spec": "cordova-plugin-whitelist@1",
25
+  "_where": "/Users/young/开发/udp-discover-client",
26
+  "author": {
27
+    "name": "Apache Software Foundation"
28
+  },
29
+  "bugs": {
30
+    "url": "https://issues.apache.org/jira/browse/CB"
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
+  "version": "1.3.3"
64
+}

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

@@ -0,0 +1,48 @@
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.3">
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
+
43
+        	<info>
44
+               This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in.
45
+          </info>
46
+    </platform>
47
+
48
+</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
+}

+ 26 - 0
plugins/fetch.json

@@ -0,0 +1,26 @@
1
+{
2
+  "cordova-plugin-diont": {
3
+    "source": {
4
+      "type": "registry",
5
+      "id": "https://github.com/willemmulder/Diont-for-Cordova.git"
6
+    },
7
+    "is_top_level": true,
8
+    "variables": {}
9
+  },
10
+  "cordova-plugin-chrome-apps-system-network": {
11
+    "source": {
12
+      "type": "registry",
13
+      "id": "https://github.com/MobileChromeApps/cordova-plugin-chrome-apps-system-network"
14
+    },
15
+    "is_top_level": false,
16
+    "variables": {}
17
+  },
18
+  "cordova-plugin-whitelist": {
19
+    "source": {
20
+      "type": "registry",
21
+      "id": "cordova-plugin-whitelist@1"
22
+    },
23
+    "is_top_level": true,
24
+    "variables": {}
25
+  }
26
+}

+ 29 - 0
res/README.md

@@ -0,0 +1,29 @@
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
+Note that these image resources are not copied into a project when a project
23
+is created with the CLI. Although there are default image resources in a
24
+newly-created project, those come from the platform-specific project template,
25
+which can generally be found in the platform's `template` directory. Until
26
+icon and splashscreen support is added to the CLI, these image resources
27
+aren't used directly.
28
+
29
+See https://issues.apache.org/jira/browse/CB-5145

二進制
res/icon/android/icon-36-ldpi.png


二進制
res/icon/android/icon-48-mdpi.png


二進制
res/icon/android/icon-72-hdpi.png


二進制
res/icon/android/icon-96-xhdpi.png


二進制
res/icon/bada-wac/icon-48-type5.png


二進制
res/icon/bada-wac/icon-50-type3.png


二進制
res/icon/bada-wac/icon-80-type4.png


二進制
res/icon/bada/icon-128.png


二進制
res/icon/blackberry/icon-80.png


二進制
res/icon/blackberry10/icon-80.png


二進制
res/icon/ios/icon-57-2x.png


二進制
res/icon/ios/icon-57.png


二進制
res/icon/ios/icon-72-2x.png


二進制
res/icon/ios/icon-72.png


二進制
res/icon/tizen/icon-128.png


二進制
res/icon/webos/icon-64.png


二進制
res/icon/windows-phone/icon-173-tile.png


二進制
res/icon/windows-phone/icon-48.png


二進制
res/icon/windows-phone/icon-62-tile.png


二進制
res/screen/android/screen-hdpi-landscape.png


二進制
res/screen/android/screen-hdpi-portrait.png


二進制
res/screen/android/screen-ldpi-landscape.png


二進制
res/screen/android/screen-ldpi-portrait.png


二進制
res/screen/android/screen-mdpi-landscape.png


二進制
res/screen/android/screen-mdpi-portrait.png


二進制
res/screen/android/screen-xhdpi-landscape.png


二進制
res/screen/android/screen-xhdpi-portrait.png


二進制
res/screen/bada-wac/screen-type3.png


二進制
res/screen/bada-wac/screen-type4.png


二進制
res/screen/bada-wac/screen-type5.png


二進制
res/screen/bada/screen-portrait.png


二進制
res/screen/blackberry/screen-225.png


二進制
res/screen/blackberry10/splash-1280x768.png


二進制
res/screen/blackberry10/splash-720x720.png


二進制
res/screen/blackberry10/splash-768x1280.png


二進制
res/screen/ios/screen-ipad-landscape-2x.png


二進制
res/screen/ios/screen-ipad-landscape.png


二進制
res/screen/ios/screen-ipad-portrait-2x.png


二進制
res/screen/ios/screen-ipad-portrait.png


二進制
res/screen/ios/screen-iphone-landscape-2x.png


二進制
res/screen/ios/screen-iphone-landscape.png


二進制
res/screen/ios/screen-iphone-portrait-2x.png


二進制
res/screen/ios/screen-iphone-portrait-568h-2x.png


二進制
res/screen/ios/screen-iphone-portrait.png


+ 24 - 0
res/screen/tizen/README.md

@@ -0,0 +1,24 @@
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
+# Tizen Splash Screen
23
+
24
+Splash screens are unsupported on the Tizen platform.

二進制
res/screen/webos/screen-64.png


二進制
res/screen/windows-phone/screen-portrait.jpg


+ 115 - 0
www/css/index.css

@@ -0,0 +1,115 @@
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
+    background-image:-webkit-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
30
+    background-image:-ms-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
31
+    background-image:-webkit-gradient(
32
+        linear,
33
+        left top,
34
+        left bottom,
35
+        color-stop(0, #A7A7A7),
36
+        color-stop(0.51, #E4E4E4)
37
+    );
38
+    background-attachment:fixed;
39
+    font-family:'HelveticaNeue-Light', 'HelveticaNeue', Helvetica, Arial, sans-serif;
40
+    font-size:12px;
41
+    height:100%;
42
+    margin:0px;
43
+    padding:0px;
44
+    text-transform:uppercase;
45
+    width:100%;
46
+}
47
+
48
+/* Portrait layout (default) */
49
+.app {
50
+    background:url(../img/logo.png) no-repeat center top; /* 170px x 200px */
51
+    position:absolute;             /* position in the center of the screen */
52
+    left:50%;
53
+    top:50%;
54
+    height:50px;                   /* text area height */
55
+    width:225px;                   /* text area width */
56
+    text-align:center;
57
+    padding:180px 0px 0px 0px;     /* image height is 200px (bottom 20px are overlapped with text) */
58
+    margin:-115px 0px 0px -112px;  /* offset vertical: half of image height and text area height */
59
+                                   /* offset horizontal: half of text area width */
60
+}
61
+
62
+/* Landscape layout (with min-width) */
63
+@media screen and (min-aspect-ratio: 1/1) and (min-width:400px) {
64
+    .app {
65
+        background-position:left center;
66
+        padding:75px 0px 75px 170px;  /* padding-top + padding-bottom + text area = image height */
67
+        margin:-90px 0px 0px -198px;  /* offset vertical: half of image height */
68
+                                      /* offset horizontal: half of image width and text area width */
69
+    }
70
+}
71
+
72
+h1 {
73
+    font-size:24px;
74
+    font-weight:normal;
75
+    margin:0px;
76
+    overflow:visible;
77
+    padding:0px;
78
+    text-align:center;
79
+}
80
+
81
+.event {
82
+    border-radius:4px;
83
+    -webkit-border-radius:4px;
84
+    color:#FFFFFF;
85
+    font-size:12px;
86
+    margin:0px 30px;
87
+    padding:2px 0px;
88
+}
89
+
90
+.event.listening {
91
+    background-color:#333333;
92
+    display:block;
93
+}
94
+
95
+.event.received {
96
+    background-color:#4B946A;
97
+    display:none;
98
+}
99
+
100
+@keyframes fade {
101
+    from { opacity: 1.0; }
102
+    50% { opacity: 0.4; }
103
+    to { opacity: 1.0; }
104
+}
105
+ 
106
+@-webkit-keyframes fade {
107
+    from { opacity: 1.0; }
108
+    50% { opacity: 0.4; }
109
+    to { opacity: 1.0; }
110
+}
111
+ 
112
+.blink {
113
+    animation:fade 3000ms infinite;
114
+    -webkit-animation:fade 3000ms infinite;
115
+}

二進制
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="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
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>

+ 66 - 0
www/js/index.js

@@ -0,0 +1,66 @@
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
+        var diont = Diont();
32
+	
33
+        // ======
34
+        // Listen for announcements and renouncements in services
35
+        // ======
36
+        diont.on("serviceAnnounced", function(serviceInfo) {
37
+            // A service was announced
38
+            // This function triggers for services not yet available in diont.getServiceInfos()
39
+            // serviceInfo is an Object { isOurService : Boolean, service: Object }
40
+            // service.name, service.host and service.port are always filled
41
+            console.log("A new service was announced", serviceInfo.service);
42
+            // List currently known services
43
+            console.log("All known services", diont.getServiceInfos());
44
+            alert('found'+ serviceInfo.service.host+" "+serviceInfo.service.port)
45
+        });
46
+        
47
+        diont.on("serviceRenounced", function(serviceInfo) {
48
+            console.log("A service was renounced", serviceInfo.service);
49
+            console.log("All known services", diont.getServiceInfos());
50
+        });
51
+    },
52
+
53
+    // Update DOM on a Received Event
54
+    receivedEvent: function(id) {
55
+        var parentElement = document.getElementById(id);
56
+        var listeningElement = parentElement.querySelector('.listening');
57
+        var receivedElement = parentElement.querySelector('.received');
58
+
59
+        listeningElement.setAttribute('style', 'display:none;');
60
+        receivedElement.setAttribute('style', 'display:block;');
61
+
62
+        console.log('Received Event: ' + id);
63
+    }
64
+};
65
+
66
+app.initialize();