cordova-plugin-oauth 3.0.1 → 3.0.2

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/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "cordova-plugin-oauth",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
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",
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="3.0.2">
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>
@@ -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