@frontegg/ionic-capacitor 2.0.8 → 2.0.9-alpha.10663474341

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.
@@ -36,12 +36,13 @@ public class FronteggNativePlugin: CAPPlugin {
36
36
 
37
37
  array.forEach {item in
38
38
  if let dict = item as? [String:String] {
39
- regions.append(RegionConfig(
40
- key: dict["key"]!,
41
- baseUrl: dict["baseUrl"]!,
42
- clientId: dict["clientId"]!,
43
- applicationId: dict["applicationId"]
44
- ))
39
+ do {
40
+ let jsonData = try JSONSerialization.data(withJSONObject: dict, options: [])
41
+ let regionConfig = try JSONDecoder().decode(RegionConfig.self, from: jsonData)
42
+ regions.append(regionConfig)
43
+ } catch {
44
+ print("Failed to decode RegionConfig: \(error)")
45
+ }
45
46
  }
46
47
  }
47
48
 
@@ -160,23 +161,31 @@ public class FronteggNativePlugin: CAPPlugin {
160
161
  }
161
162
  call.resolve()
162
163
  }
163
-
164
-
164
+
165
+
165
166
  @objc func directLoginAction(_ call: CAPPluginCall) {
166
167
  guard let type = call.options["type"] as? String else {
167
168
  call.reject("No type provided")
168
169
  return
169
170
  }
170
-
171
+
171
172
  guard let data = call.options["data"] as? String else {
172
173
  call.reject("No data provided")
173
174
  return
174
175
  }
175
-
176
+ let ephemeralSession = call.getBool("ephemeralSession", true)
177
+
176
178
  DispatchQueue.main.sync {
177
- fronteggApp.auth.directLoginAction(window: nil, type: type, data: data)
179
+ fronteggApp.auth.directLoginAction(window: nil, type: type, data: data, ephemeralSession: ephemeralSession) { res in
180
+ switch(res) {
181
+ case .failure(let error):
182
+ call.reject("\((error as NSError).code)")
183
+ case .success(let user):
184
+ call.resolve()
185
+ }
186
+ }
178
187
  }
179
- call.resolve()
188
+
180
189
  }
181
190
 
182
191
  @objc func logout(_ call: CAPPluginCall) {
@@ -210,8 +219,12 @@ public class FronteggNativePlugin: CAPPlugin {
210
219
 
211
220
  DispatchQueue.global(qos: .background).async {
212
221
  Task {
213
- await self.fronteggApp.auth.refreshTokenIfNeeded()
214
- call.resolve()
222
+ let result = await self.fronteggApp.auth.refreshTokenIfNeeded()
223
+
224
+ let response: [String: Any?] = [
225
+ "success": result
226
+ ]
227
+ call.resolve(response as PluginCallResultData)
215
228
  }
216
229
  }
217
230
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontegg/ionic-capacitor",
3
- "version": "2.0.8",
3
+ "version": "2.0.9-alpha.10663474341",
4
4
  "description": "Frontegg Ionic Capacitor SDK",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -51,6 +51,11 @@
51
51
  "@frontegg/rest-api": "^3.1.56"
52
52
  },
53
53
  "devDependencies": {
54
+ "@angular-eslint/builder": "^16.0.0",
55
+ "@angular-eslint/eslint-plugin": "^16.0.0",
56
+ "@angular-eslint/eslint-plugin-template": "^16.0.0",
57
+ "@angular-eslint/schematics": "^16.0.0",
58
+ "@angular-eslint/template-parser": "^16.0.0",
54
59
  "@angular/core": ">=14.0.0",
55
60
  "@capacitor/android": "^5.0.0",
56
61
  "@capacitor/core": "^5.0.0",
@@ -65,12 +70,7 @@
65
70
  "rimraf": "^3.0.2",
66
71
  "rollup": "^2.32.0",
67
72
  "swiftlint": "^1.0.1",
68
- "typescript": "~4.1.5",
69
- "@angular-eslint/builder": "^16.0.0",
70
- "@angular-eslint/eslint-plugin": "^16.0.0",
71
- "@angular-eslint/eslint-plugin-template": "^16.0.0",
72
- "@angular-eslint/schematics": "^16.0.0",
73
- "@angular-eslint/template-parser": "^16.0.0"
73
+ "typescript": "~4.1.5"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "@capacitor/core": "^5.0.0"