@falconeta/capacitor-aws-amplify 0.0.1 → 0.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.
@@ -4,5 +4,7 @@
4
4
  // Define the plugin using the CAP_PLUGIN Macro, and
5
5
  // each method the plugin supports using the CAP_PLUGIN_METHOD macro.
6
6
  CAP_PLUGIN(AwsAmplifyPlugin, "AwsAmplify",
7
- CAP_PLUGIN_METHOD(echo, CAPPluginReturnPromise);
7
+ CAP_PLUGIN_METHOD(signIn, CAPPluginReturnPromise);
8
+ CAP_PLUGIN_METHOD(signOut, CAPPluginReturnPromise);
9
+ CAP_PLUGIN_METHOD(federatedSignIn, CAPPluginReturnPromise);
8
10
  )
@@ -9,10 +9,74 @@ import Capacitor
9
9
  public class AwsAmplifyPlugin: CAPPlugin {
10
10
  private let implementation = AwsAmplify()
11
11
 
12
- @objc func echo(_ call: CAPPluginCall) {
13
- let value = call.getString("value") ?? ""
14
- call.resolve([
15
- "value": implementation.echo(value)
16
- ])
12
+ @objc func signIn(_ call: CAPPluginCall) {
13
+ let email = call.getString("email") ?? ""
14
+ let password = call.getString("password") ?? ""
15
+
16
+ self.awsCapacitor.signIn(
17
+ email: email,
18
+ password: password,
19
+ onSuccess: {data in
20
+ self.awsCapacitor.fetchAuthSession(
21
+ onSuccess: {session in
22
+ call.resolve(session)
23
+ },
24
+ onError: {error in
25
+ call.reject(error.localizedDescription)
26
+ })
27
+ },
28
+ onError: {error in
29
+ print(error)
30
+ call.reject(error.localizedDescription)
31
+ })
17
32
  }
33
+
34
+ @objc func signOut(_ call: CAPPluginCall) {
35
+ self.awsCapacitor.signOut(
36
+ onSuccess: { success in
37
+ call.resolve([
38
+ "logout": success
39
+ ])
40
+ }, onError: { error in
41
+ call.reject(error.localizedDescription)
42
+ })
43
+ }
44
+
45
+ @objc func federatedSignIn(_ call: CAPPluginCall) {
46
+ let provider = call.getString("provider") ?? ""
47
+
48
+ self.awsCapacitor.federatedSignIn(
49
+ provider: provider,
50
+ onSuccess: { data in
51
+ print("federatedSignIn onSuccess \(data)")
52
+ self.awsCapacitor.fetchAuthSession(
53
+ onSuccess: {session in
54
+ call.resolve(session)
55
+ },
56
+ onError: {error in
57
+ call.reject(error.localizedDescription)
58
+ })
59
+ },
60
+ onError: { error in
61
+ print(error)
62
+ call.reject(error.localizedDescription)
63
+ })
64
+ }
65
+
66
+ // var permissionCallID: String?
67
+ // var locationManager: CLLocationManager?
68
+
69
+ // @objc override public func requestPermissions(_ call: CAPPluginCall) {
70
+ // if let manager = locationManager, CLLocationManager.locationServicesEnabled() {
71
+ // if CLLocationManager.authorizationStatus() == .notDetermined {
72
+ // bridge?.saveCall(call)
73
+ // permissionCallID = call.callbackId
74
+ // manager.requestWhenInUseAuthorization()
75
+ // } else {
76
+ // checkPermissions(call)
77
+ // }
78
+ // } else {
79
+ // call.reject("Location services are disabled")
80
+ // }
81
+ // }
18
82
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@falconeta/capacitor-aws-amplify",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "plugin that handle amplify features",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -62,7 +62,9 @@
62
62
  "typescript": "~4.1.5"
63
63
  },
64
64
  "peerDependencies": {
65
- "@capacitor/core": "^5.0.0"
65
+ "@capacitor/core": "^5.0.0",
66
+ "@aws-amplify/auth": "^5.6.5",
67
+ "aws-amplify": "^5.3.11"
66
68
  },
67
69
  "prettier": "@ionic/prettier-config",
68
70
  "swiftlint": "@ionic/swiftlint-config",