cordova-plugin-oauth 3.0.1 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <!--
2
- Copyright 2021 Ayogo Health Inc.
2
+ Copyright 2021-2022 Ayogo Health Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -29,6 +29,10 @@ falling back to their browser.
29
29
 
30
30
  **Note:** This plugin might conflict with the Cordova In-App Browser plugin!
31
31
 
32
+ > ℹ️ **This plugin uses AndroidX!**
33
+ >
34
+ > Use version 3.x if you are building without AndroidX enabled.
35
+
32
36
 
33
37
  Installation
34
38
  ------------
@@ -51,7 +55,7 @@ Supported Platforms
51
55
  -------------------
52
56
 
53
57
  * **iOS** (cordova-ios >= 6.1.0)
54
- * **Android** (cordova-android >= 8.0.0)
58
+ * **Android** (cordova-android >= 9.0.0)
55
59
 
56
60
 
57
61
  Usage
@@ -107,6 +111,6 @@ Licence
107
111
  -------
108
112
 
109
113
  Released under the Apache 2.0 Licence.
110
- Copyright © 2020 Ayogo Health Inc.
114
+ Copyright © 2020-2022 Ayogo Health Inc.
111
115
 
112
- [coc]: https://github.com/AyogoHealth/cordova-plugin-oauth/blob/master/CODE_OF_CONDUCT.md
116
+ [coc]: https://github.com/AyogoHealth/cordova-plugin-oauth/blob/main/CODE_OF_CONDUCT.md
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "cordova-plugin-oauth",
3
- "version": "3.0.1",
3
+ "version": "4.0.1",
4
4
  "author": "Ayogo Health Inc. <info@ayogo.com>",
5
5
  "contributors": [
6
6
  "Darryl Pogue <darryl@dpogue.ca>",
7
- "Charalampos Pournaris <charpour@gmail.com>"
7
+ "Charalampos Pournaris <charpour@gmail.com>",
8
+ "Harel Mazor"
8
9
  ],
9
10
  "description": "Cordova plugin for performing OAuth login flows.",
10
11
  "license": "Apache-2.0",
@@ -18,6 +19,11 @@
18
19
  "cordova-android",
19
20
  "cordova-ios"
20
21
  ],
22
+ "files": [
23
+ "src",
24
+ "www",
25
+ "plugin.xml"
26
+ ],
21
27
  "cordova": {
22
28
  "platforms": [
23
29
  "ios",
@@ -27,7 +33,7 @@
27
33
  "engines": [
28
34
  {
29
35
  "name": "cordova-android",
30
- "version": ">= 8.0.0"
36
+ "version": ">= 9.0.0"
31
37
  },
32
38
  {
33
39
  "name": "cordova-ios",
package/plugin.xml CHANGED
@@ -14,7 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
14
  See the License for the specific language governing permissions and
15
15
  limitations under the License.
16
16
  -->
17
- <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-oauth" version="3.0.1">
17
+ <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-oauth" version="4.0.1">
18
18
  <name>cordova-plugin-oauth</name>
19
19
  <description>Cordova plugin for performing OAuth login flows.</description>
20
20
  <keywords>cordova,ios,android,oauth</keywords>
@@ -26,7 +26,7 @@ limitations under the License.
26
26
 
27
27
  <engines>
28
28
  <engine name="cordova-ios" version=">= 6.1.0" />
29
- <engine name="cordova-android" version=">= 8.0.0" />
29
+ <engine name="cordova-android" version=">= 9.0.0" />
30
30
  </engines>
31
31
 
32
32
  <js-module src="www/oauth.js" name="OAuth">
@@ -82,8 +82,8 @@ limitations under the License.
82
82
 
83
83
  <source-file src="src/android/OAuthPlugin.java" target-dir="src/com/ayogo/cordova/oauth" />
84
84
 
85
- <preference name="ANDROID_SUPPORT_CUSTOM_TABS_VERSION" default="28.+" />
85
+ <preference name="ANDROID_SUPPORT_CUSTOM_TABS_VERSION" default="1.3.0" />
86
86
 
87
- <framework src="com.android.support:customtabs:$ANDROID_SUPPORT_CUSTOM_TABS_VERSION" />
87
+ <framework src="androidx.browser:browser:$ANDROID_SUPPORT_CUSTOM_TABS_VERSION" />
88
88
  </platform>
89
89
  </plugin>
@@ -23,7 +23,7 @@ import android.content.IntentFilter;
23
23
  import android.content.pm.PackageManager;
24
24
  import android.content.pm.ResolveInfo;
25
25
  import android.net.Uri;
26
- import android.support.customtabs.CustomTabsIntent;
26
+ import androidx.browser.customtabs.CustomTabsIntent;
27
27
  import android.text.TextUtils;
28
28
 
29
29
  import java.util.ArrayList;
@@ -33,6 +33,7 @@ import org.apache.cordova.CallbackContext;
33
33
  import org.apache.cordova.CordovaInterface;
34
34
  import org.apache.cordova.CordovaPlugin;
35
35
  import org.apache.cordova.CordovaWebView;
36
+ import org.apache.cordova.CordovaWebViewEngine;
36
37
  import org.apache.cordova.LOG;
37
38
  import org.apache.cordova.PluginResult;
38
39
 
@@ -121,7 +122,14 @@ public class OAuthPlugin extends CordovaPlugin {
121
122
  }
122
123
 
123
124
  final String msg = jsobj.toString();
124
- this.webView.getEngine().evaluateJavascript("window.dispatchEvent(new MessageEvent('message', { data: 'oauth::" + msg + "' }));", null);
125
+ CordovaWebViewEngine engine = this.webView.getEngine();
126
+ final String jsCode = "window.dispatchEvent(new MessageEvent('message', { data: 'oauth::" + msg + "' }));";
127
+ if (engine != null) {
128
+ engine.evaluateJavascript(jsCode, null);
129
+ } else {
130
+ this.webView.sendJavascript(jsCode);
131
+ }
132
+
125
133
  } catch (JSONException e) {
126
134
  LOG.e(TAG, "JSON Serialization failed");
127
135
  e.printStackTrace();
@@ -32,7 +32,9 @@ class ASWebAuthenticationSessionOAuthSessionProvider : OAuthSessionProvider {
32
32
  var delegate : AnyObject?
33
33
 
34
34
  required init(_ endpoint : URL, callbackScheme : String) {
35
- self.aswas = ASWebAuthenticationSession(url: endpoint, callbackURLScheme: callbackScheme, completionHandler: { (callBack:URL?, error:Error?) in
35
+ let url: URL = URL(string: callbackScheme)!
36
+ let callbackURLScheme: String = url.scheme ?? callbackScheme
37
+ self.aswas = ASWebAuthenticationSession(url: endpoint, callbackURLScheme: callbackURLScheme, completionHandler: { (callBack:URL?, error:Error?) in
36
38
  if let incomingUrl = callBack {
37
39
  NotificationCenter.default.post(name: NSNotification.Name.CDVPluginHandleOpenURL, object: incomingUrl)
38
40
  }
@@ -125,7 +127,9 @@ class OAuthPlugin : CDVPlugin, SFSafariViewControllerDelegate, ASWebAuthenticati
125
127
  let urlScheme = self.commandDelegate.settings["oauthscheme"] as! String
126
128
 
127
129
  self.callbackScheme = "\(urlScheme)://oauth_callback"
128
- self.logger = OSLog(subsystem: urlScheme, category: "Cordova")
130
+ if #available(iOS 10.0, *) {
131
+ self.logger = OSLog(subsystem: urlScheme, category: "Cordova")
132
+ }
129
133
 
130
134
  NotificationCenter.default.addObserver(self,
131
135
  selector: #selector(OAuthPlugin._handleOpenURL(_:)),
@@ -184,7 +188,11 @@ class OAuthPlugin : CDVPlugin, SFSafariViewControllerDelegate, ASWebAuthenticati
184
188
  jsobj[$0.name] = $0.value
185
189
  }
186
190
 
187
- os_log("OAuth called back with parameters.", log: self.logger!, type: .info)
191
+ if #available(iOS 10.0, *) {
192
+ os_log("OAuth called back with parameters.", log: self.logger!, type: .info)
193
+ } else {
194
+ NSLog("OAuth called back with parameters.")
195
+ }
188
196
 
189
197
  do {
190
198
  let data = try JSONSerialization.data(withJSONObject: jsobj)
@@ -193,7 +201,11 @@ class OAuthPlugin : CDVPlugin, SFSafariViewControllerDelegate, ASWebAuthenticati
193
201
  self.webViewEngine.evaluateJavaScript("window.dispatchEvent(new MessageEvent('message', { data: 'oauth::\(msg)' }));", completionHandler: nil)
194
202
  } catch {
195
203
  let errStr = "JSON Serialization failed: \(error)"
196
- os_log("%@", log: self.logger!, type: .error, errStr)
204
+ if #available(iOS 10.0, *) {
205
+ os_log("%@", log: self.logger!, type: .error, errStr)
206
+ } else {
207
+ NSLog(errStr)
208
+ }
197
209
  }
198
210
  }
199
211
 
package/.editorconfig DELETED
@@ -1,20 +0,0 @@
1
- # Copyright 2017 Ayogo Health Inc
2
- root = true
3
-
4
- [*]
5
- end_of_line = lf
6
- indent_style = space
7
- insert_final_newline = true
8
- charset = utf-8
9
- trim_trailing_whitespace = true
10
- indent_size = 2
11
-
12
- [*.java]
13
- indent_size = 4
14
-
15
- [*.swift]
16
- indent_size = 4
17
-
18
- [*.md]
19
- indent_size = 4
20
- trim_trailing_whitespace = false
@@ -1,77 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, sex characteristics, gender identity and expression,
9
- level of experience, education, socio-economic status, nationality, personal
10
- appearance, race, religion, or sexual identity and orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at opensource@ayogo.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72
-
73
- [homepage]: https://www.contributor-covenant.org
74
-
75
- For answers to common questions about this code of conduct, see
76
- https://www.contributor-covenant.org/faq
77
-