cordova-plugin-oauth 1.1.0 → 2.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 +3 -2
- package/plugin.xml +1 -1
- package/src/ios/OAuthPlugin.swift +21 -15
- package/www/oauth.js +1 -1
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cordova-plugin-oauth",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"author": "Ayogo Health Inc. <info@ayogo.com>",
|
|
5
5
|
"contributors": [
|
|
6
|
-
"Darryl Pogue <darryl@dpogue.ca>"
|
|
6
|
+
"Darryl Pogue <darryl@dpogue.ca>",
|
|
7
|
+
"Harel Mazor"
|
|
7
8
|
],
|
|
8
9
|
"description": "Cordova plugin for performing OAuth login flows.",
|
|
9
10
|
"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="
|
|
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="2.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
|
-
|
|
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
|
}
|
|
@@ -40,13 +42,11 @@ class ASWebAuthenticationSessionOAuthSessionProvider : OAuthSessionProvider {
|
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
func start() {
|
|
43
|
-
|
|
44
|
-
if
|
|
45
|
-
|
|
46
|
-
self.aswas.presentationContextProvider = provider
|
|
47
|
-
}
|
|
45
|
+
if #available(iOS 13.0, *) {
|
|
46
|
+
if let provider = self.delegate as? ASWebAuthenticationPresentationContextProviding {
|
|
47
|
+
self.aswas.presentationContextProvider = provider
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
}
|
|
50
50
|
|
|
51
51
|
self.aswas.start()
|
|
52
52
|
}
|
|
@@ -118,7 +118,7 @@ class SafariAppOAuthSessionProvider : OAuthSessionProvider {
|
|
|
118
118
|
|
|
119
119
|
|
|
120
120
|
@objc(CDVOAuthPlugin)
|
|
121
|
-
class OAuthPlugin : CDVPlugin, SFSafariViewControllerDelegate {
|
|
121
|
+
class OAuthPlugin : CDVPlugin, SFSafariViewControllerDelegate, ASWebAuthenticationPresentationContextProviding {
|
|
122
122
|
var authSystem : OAuthSessionProvider?
|
|
123
123
|
var callbackScheme : String?
|
|
124
124
|
var logger : OSLog?
|
|
@@ -127,7 +127,9 @@ class OAuthPlugin : CDVPlugin, SFSafariViewControllerDelegate {
|
|
|
127
127
|
let appID = Bundle.main.bundleIdentifier!
|
|
128
128
|
|
|
129
129
|
self.callbackScheme = "\(appID)://oauth_callback"
|
|
130
|
-
|
|
130
|
+
if #available(iOS 10.0, *) {
|
|
131
|
+
self.logger = OSLog(subsystem: appID, category: "Cordova")
|
|
132
|
+
}
|
|
131
133
|
|
|
132
134
|
NotificationCenter.default.addObserver(self,
|
|
133
135
|
selector: #selector(OAuthPlugin._handleOpenURL(_:)),
|
|
@@ -186,7 +188,11 @@ class OAuthPlugin : CDVPlugin, SFSafariViewControllerDelegate {
|
|
|
186
188
|
jsobj[$0.name] = $0.value
|
|
187
189
|
}
|
|
188
190
|
|
|
189
|
-
|
|
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
|
+
}
|
|
190
196
|
|
|
191
197
|
do {
|
|
192
198
|
let data = try JSONSerialization.data(withJSONObject: jsobj)
|
|
@@ -195,7 +201,11 @@ class OAuthPlugin : CDVPlugin, SFSafariViewControllerDelegate {
|
|
|
195
201
|
self.webViewEngine.evaluateJavaScript("window.dispatchEvent(new MessageEvent('message', { data: 'oauth::\(msg)' }));", completionHandler: nil)
|
|
196
202
|
} catch {
|
|
197
203
|
let errStr = "JSON Serialization failed: \(error)"
|
|
198
|
-
|
|
204
|
+
if #available(iOS 10.0, *) {
|
|
205
|
+
os_log("%@", log: self.logger!, type: .error, errStr)
|
|
206
|
+
} else {
|
|
207
|
+
NSLog(errStr)
|
|
208
|
+
}
|
|
199
209
|
}
|
|
200
210
|
}
|
|
201
211
|
|
|
@@ -218,13 +228,9 @@ class OAuthPlugin : CDVPlugin, SFSafariViewControllerDelegate {
|
|
|
218
228
|
self.authSystem?.cancel()
|
|
219
229
|
self.authSystem = nil
|
|
220
230
|
}
|
|
221
|
-
}
|
|
222
231
|
|
|
223
|
-
#if swift(>=5.1)
|
|
224
|
-
extension OAuthPlugin : ASWebAuthenticationPresentationContextProviding {
|
|
225
232
|
@available(iOS 13.0, *)
|
|
226
233
|
func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
|
|
227
234
|
return self.viewController.view.window ?? ASPresentationAnchor()
|
|
228
235
|
}
|
|
229
236
|
}
|
|
230
|
-
#endif
|
package/www/oauth.js
CHANGED
|
@@ -20,7 +20,7 @@ var noop = function() { };
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
module.exports = function(url, name, features) {
|
|
23
|
-
if (name.match(/^oauth:/)) {
|
|
23
|
+
if (name && name.match && name.match(/^oauth:/)) {
|
|
24
24
|
cordova.exec(noop, noop, 'OAuth', 'startOAuth', [url]);
|
|
25
25
|
} else {
|
|
26
26
|
var originalWindowOpen = modulemapper.getOriginalSymbol(window, 'open');
|