@frontegg/ionic-capacitor 2.0.7 → 2.0.8

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.
@@ -13,7 +13,7 @@ Pod::Spec.new do |s|
13
13
  s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
14
14
  s.ios.deployment_target = '14.0'
15
15
  s.dependency 'Capacitor'
16
- s.dependency "FronteggSwift", "1.2.11"
16
+ s.dependency "FronteggSwift", "1.2.16"
17
17
  s.swift_version = '5.1'
18
18
  s.pod_target_xcconfig = {
19
19
  'CODE_SIGNING_ALLOWED' => 'YES'
package/README.md CHANGED
@@ -31,6 +31,8 @@ features for the product-led era.
31
31
  - [Step 1: Add regions to your Frontegg configuration](#step-1-add-regions-to-your-frontegg-configuration)
32
32
  - [Setup multi-region support for iOS Platform](#setup-multi-region-support-for-ios-platform)
33
33
  - [Setup multi-region support for Android Platform](#setup-multi-region-support-for-android-platform)
34
+ - [Multi-apps Android Support](#multi-apps-support)
35
+ - [Step 1: Add application id to your Frontegg configuration](#step-1-add-application-id-to-your-frontegg-configuration)
34
36
 
35
37
  ## Project Requirements
36
38
 
@@ -832,3 +834,70 @@ NOTE: if you are using `Custom Chrome Tab` you have to use `android:name` `com.f
832
834
  </activity>
833
835
  </application>
834
836
  ```
837
+
838
+ ## Multi-apps Support
839
+
840
+ This guide outlines the steps to configure your application to support multiple applications.
841
+
842
+ ### Step 1: Add application id to your Frontegg configuration
843
+
844
+ Add `applicationId` to your Frontegg configuration in `capacitor.config.ts` file:
845
+
846
+ Find example code in [example/capacitor.config.ts](example/capacitor.config.ts) file.
847
+
848
+
849
+ ```typescript
850
+ import { CapacitorConfig } from '@capacitor/cli';
851
+
852
+ const config: CapacitorConfig = {
853
+ /*...*/
854
+ plugins: {
855
+
856
+ /*...*/
857
+
858
+ FronteggNative: {
859
+ baseUrl: 'https://{FRONTEGG_DOMAIN_HOST.com}',
860
+ clientId: '{FRONTEGG_CLIENT_ID}',
861
+ applicationId: '{FRONTEGG_APPLICATION_ID}',
862
+ }
863
+ }
864
+ };
865
+
866
+ export default config;
867
+ ```
868
+
869
+ Or add `applicationId` to the `regions`:
870
+
871
+ ```typescript
872
+ import { CapacitorConfig } from '@capacitor/cli';
873
+
874
+ const config: CapacitorConfig = {
875
+ /*...*/
876
+ plugins: {
877
+
878
+ /*...*/
879
+
880
+ FronteggNative: {
881
+
882
+ /** Remove baseUrl and clientId from here */
883
+ // baseUrl: 'https://{FRONTEGG_DOMAIN_HOST.com}',
884
+ // clientId: '{FRONTEGG_CLIENT_ID}',
885
+ // applicationId: '{FRONTEGG_APPLICATION_ID}',
886
+
887
+ regions: [ {
888
+ key: 'REGION_1_KEY',
889
+ baseUrl: 'https://region1.forntegg.com',
890
+ clientId: 'REGION_1_CLIEND_ID',
891
+ applicationId: '{FRONTEGG_REGION_1_APPLICATION_ID}'
892
+ }, {
893
+ key: 'REGION_2_KEY',
894
+ baseUrl: 'https://region2.forntegg.com',
895
+ clientId: 'REGION_2_CLIEND_ID',
896
+ applicationId: '{FRONTEGG_REGION_2_APPLICATION_ID}',
897
+ } ]
898
+ }
899
+ }
900
+ };
901
+
902
+ export default config;
903
+ ```
@@ -55,7 +55,7 @@ dependencies {
55
55
  implementation "androidx.browser:browser:1.5.0"
56
56
  implementation 'io.reactivex.rxjava3:rxkotlin:3.0.1'
57
57
  implementation 'com.google.code.gson:gson:2.10'
58
- implementation 'com.frontegg.sdk:android:1.2.10'
58
+ implementation 'com.frontegg.sdk:android:1.2.18'
59
59
 
60
60
  testImplementation "junit:junit:$junitVersion"
61
61
  androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
@@ -40,7 +40,7 @@ public class FronteggNativePlugin extends Plugin {
40
40
 
41
41
  // for regions initialization
42
42
  List<RegionConfig> regions = new ArrayList<>();
43
- boolean useAssetLinks = this.getConfig().getBoolean("useAssetsLinks", true);
43
+ boolean useAssetLinks = this.getConfig().getBoolean("useAssetLinks", true);
44
44
  boolean useChromeCustomTabs = this.getConfig().getBoolean("useChromeCustomTabs", false);
45
45
  JSONArray array;
46
46
  try {
@@ -51,10 +51,15 @@ public class FronteggNativePlugin extends Plugin {
51
51
  }
52
52
  for (int i = 0; i < array.length(); i++) {
53
53
  JSONObject regionJson = (JSONObject) array.get(i);
54
+ String applicationId = null;
55
+ if (regionJson.has("applicationId")) {
56
+ applicationId = regionJson.getString("applicationId");
57
+ }
54
58
  regions.add(new RegionConfig(
55
59
  regionJson.getString("key"),
56
60
  regionJson.getString("baseUrl"),
57
- regionJson.getString("clientId")
61
+ regionJson.getString("clientId"),
62
+ applicationId
58
63
  ));
59
64
  }
60
65
 
@@ -66,6 +71,7 @@ public class FronteggNativePlugin extends Plugin {
66
71
  PluginConfig config = this.getConfig();
67
72
  String baseUrl = config.getString("baseUrl");
68
73
  String clientId = config.getString("clientId");
74
+ String applicationId = config.getString("applicationId");
69
75
 
70
76
  if (baseUrl == null || clientId == null) {
71
77
  throw new RuntimeException("Missing required config parameters: baseUrl, clientId");
@@ -77,15 +83,18 @@ public class FronteggNativePlugin extends Plugin {
77
83
  baseUrl,
78
84
  clientId,
79
85
  this.getContext(),
86
+ applicationId,
80
87
  useAssetLinks,
81
- useChromeCustomTabs
88
+ useChromeCustomTabs,
89
+ null
82
90
  );
83
91
  }else {
84
92
  FronteggApp.Companion.initWithRegions(
85
93
  regions,
86
94
  this.getContext(),
87
95
  useAssetLinks,
88
- useChromeCustomTabs
96
+ useChromeCustomTabs,
97
+ null
89
98
  );
90
99
  }
91
100
 
@@ -176,7 +185,7 @@ public class FronteggNativePlugin extends Plugin {
176
185
  call.reject("No tenantId provided");
177
186
  return;
178
187
  }
179
- FronteggApp.Companion.getInstance().getAuth().switchTenant(tenantId, () -> {
188
+ FronteggApp.Companion.getInstance().getAuth().switchTenant(tenantId, (success) -> {
180
189
  call.resolve();
181
190
  return null;
182
191
  });
@@ -219,6 +228,7 @@ public class FronteggNativePlugin extends Plugin {
219
228
 
220
229
  String baseUrl = FronteggAuth.Companion.getInstance().getBaseUrl();
221
230
  String clientId = FronteggAuth.Companion.getInstance().getClientId();
231
+ String applicationId = FronteggAuth.Companion.getInstance().getApplicationId();
222
232
  String packageName = getContext().getPackageName();
223
233
 
224
234
  List<RegionConfig> regionsData = FronteggApp.Companion.getInstance().getRegions();
@@ -227,6 +237,7 @@ public class FronteggNativePlugin extends Plugin {
227
237
  resultMap.put("baseUrl", baseUrl);
228
238
  resultMap.put("clientId", clientId);
229
239
  resultMap.put("bundleId", packageName);
240
+ resultMap.put("applicationId", applicationId);
230
241
  resultMap.put("isRegional", regionsData.size() > 0);
231
242
  resultMap.put("regionData", Parser.regionsToJSONObject(regionsData));
232
243
 
@@ -19,6 +19,7 @@ export declare type SubscribeMap<T> = {
19
19
  export interface FronteggConstants {
20
20
  baseUrl: string;
21
21
  clientId: string;
22
+ applicationId: string | null;
22
23
  bundleId: string;
23
24
  isRegional: boolean;
24
25
  regionData?: {
@@ -61,10 +62,12 @@ export declare type RegionConfig = {
61
62
  key: string;
62
63
  baseUrl: string;
63
64
  clientId: string;
65
+ applicationId?: string;
64
66
  };
65
67
  declare type FronteggNativeStandardOptions = {
66
68
  baseUrl: string;
67
69
  clientId: string;
70
+ applicationId?: string;
68
71
  };
69
72
  declare type FronteggNativeRegionOptions = {
70
73
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { ListenerCallback, PluginListenerHandle } from '@capacitor/core';\nimport type { ITenantsResponse, IUserProfile } from '@frontegg/rest-api';\n\nexport type User = IUserProfile & {\n tenants: ITenantsResponse[];\n activeTenant: ITenantsResponse;\n};\n\nexport interface FronteggState {\n accessToken: string | null;\n refreshToken: string | null;\n isAuthenticated: boolean;\n user: User | null;\n showLoader: boolean;\n selectedRegion: string | null;\n}\n\nexport type SubscribeFunc<T, K extends keyof T> = (value: T[K]) => void;\nexport type SubscribeMap<T> = {\n [K in keyof T]: Set<SubscribeFunc<T, K>>;\n};\n\nexport interface FronteggConstants {\n baseUrl: string;\n clientId: string;\n bundleId: string;\n isRegional: boolean;\n regionData?: { key: string; baseUrl: string; clientId: string }[];\n}\n\nexport interface FronteggNativePlugin {\n addListener(\n eventName: string,\n listenerFunc: ListenerCallback,\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n\n getConstants(): Promise<FronteggConstants>;\n\n getAuthState(): Promise<FronteggState>;\n\n login(): Promise<void>;\n\n /**\n * Used to log in with social login provider directly without visiting the login page\n * @param payload\n * @param payload.type - the direct login type (direct, social-login, custom-social-login)\n * @param payload.data - the direct login data (for direct it's saml url request, for social-login it's the provider name, for custom-social-login it's the provider entity id)\n */\n directLoginAction(payload: { type: string; data: string }): Promise<void>;\n\n logout(): void;\n\n switchTenant(payload: { tenantId: string }): Promise<void>;\n\n /**\n * used to initialize the plugin with multiple regions\n * for more information see:\n * iOS: https://github.com/frontegg/frontegg-ios-swift#multi-region-support\n * Android: https://github.com/frontegg/frontegg-android-kotlin#multi-region-support\n */\n initWithRegion(payload: { regionKey: string }): Promise<void>;\n\n refreshToken(): Promise<void>;\n}\n\nexport type RegionConfig = {\n key: string;\n baseUrl: string;\n clientId: string;\n};\n\ntype FronteggNativeStandardOptions = {\n baseUrl: string;\n clientId: string;\n};\ntype FronteggNativeRegionOptions = {\n /**\n * This is an array of regions to be used as frontegg app.\n *\n * @since 1.0.0\n * @example [{key: \"us\", baseUrl: \"https://us-api.frontegg.com\", clientId: \"us-client-id\"}]\n */\n regions: RegionConfig[];\n};\ntype FronteggNativeOptions = (\n | FronteggNativeStandardOptions\n | FronteggNativeRegionOptions\n) & {\n /**\n * Weather to handle login with social login in external browser.\n * If set to false, the plugin will navigate to the social login page with application webview.\n *\n * NOTE: some of the social login providers prevent login from embedded webview.\n *\n * @default true\n */\n handleLoginWithSocialLogin?: boolean;\n /**\n * Weather to handle login with SSO in external browser.\n * If set to false, the plugin will navigate to the sso page with application webview.\n *\n * @default false\n */\n handleLoginWithSSO?: boolean;\n /**\n * Weather to use the assetlinks to for oauth/callback, this is the default behavior.\n * disabling this will cause the plugin to use custom url scheme for oauth/callback.\n *\n * NOTE: custom url scheme require user interaction to return to the app.\n * @default true\n */\n useAssetLinks?: boolean;\n\n /**\n * Weather to To enable social login via Chrome Custom Tabs, set the useChromeCustomTabs flag to true.\n * By default, the SDK uses the Chrome browser for social login.\n *\n * NOTE: custom url scheme require user interaction to return to the app.\n * @default true\n */\n useChromeCustomTabs?: boolean;\n};\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\ndeclare module '@capacitor/cli' {\n export interface PluginsConfig {\n /**\n * You can configure the way the push notifications are displayed when the app is in foreground.\n */\n FronteggNative?: FronteggNativeOptions;\n }\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { ListenerCallback, PluginListenerHandle } from '@capacitor/core';\nimport type { ITenantsResponse, IUserProfile } from '@frontegg/rest-api';\n\nexport type User = IUserProfile & {\n tenants: ITenantsResponse[];\n activeTenant: ITenantsResponse;\n};\n\nexport interface FronteggState {\n accessToken: string | null;\n refreshToken: string | null;\n isAuthenticated: boolean;\n user: User | null;\n showLoader: boolean;\n selectedRegion: string | null;\n}\n\nexport type SubscribeFunc<T, K extends keyof T> = (value: T[K]) => void;\nexport type SubscribeMap<T> = {\n [K in keyof T]: Set<SubscribeFunc<T, K>>;\n};\n\nexport interface FronteggConstants {\n baseUrl: string;\n clientId: string;\n applicationId: string | null;\n bundleId: string;\n isRegional: boolean;\n regionData?: { key: string; baseUrl: string; clientId: string }[];\n}\n\nexport interface FronteggNativePlugin {\n addListener(\n eventName: string,\n listenerFunc: ListenerCallback,\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n\n getConstants(): Promise<FronteggConstants>;\n\n getAuthState(): Promise<FronteggState>;\n\n login(): Promise<void>;\n\n /**\n * Used to log in with social login provider directly without visiting the login page\n * @param payload\n * @param payload.type - the direct login type (direct, social-login, custom-social-login)\n * @param payload.data - the direct login data (for direct it's saml url request, for social-login it's the provider name, for custom-social-login it's the provider entity id)\n */\n directLoginAction(payload: { type: string; data: string }): Promise<void>;\n\n logout(): void;\n\n switchTenant(payload: { tenantId: string }): Promise<void>;\n\n /**\n * used to initialize the plugin with multiple regions\n * for more information see:\n * iOS: https://github.com/frontegg/frontegg-ios-swift#multi-region-support\n * Android: https://github.com/frontegg/frontegg-android-kotlin#multi-region-support\n */\n initWithRegion(payload: { regionKey: string }): Promise<void>;\n\n refreshToken(): Promise<void>;\n}\n\nexport type RegionConfig = {\n key: string;\n baseUrl: string;\n clientId: string;\n applicationId?: string;\n};\n\ntype FronteggNativeStandardOptions = {\n baseUrl: string;\n clientId: string;\n applicationId?: string;\n};\ntype FronteggNativeRegionOptions = {\n /**\n * This is an array of regions to be used as frontegg app.\n *\n * @since 1.0.0\n * @example [{key: \"us\", baseUrl: \"https://us-api.frontegg.com\", clientId: \"us-client-id\"}]\n */\n regions: RegionConfig[];\n};\ntype FronteggNativeOptions = (\n | FronteggNativeStandardOptions\n | FronteggNativeRegionOptions\n) & {\n /**\n * Weather to handle login with social login in external browser.\n * If set to false, the plugin will navigate to the social login page with application webview.\n *\n * NOTE: some of the social login providers prevent login from embedded webview.\n *\n * @default true\n */\n handleLoginWithSocialLogin?: boolean;\n /**\n * Weather to handle login with SSO in external browser.\n * If set to false, the plugin will navigate to the sso page with application webview.\n *\n * @default false\n */\n handleLoginWithSSO?: boolean;\n /**\n * Weather to use the assetlinks to for oauth/callback, this is the default behavior.\n * disabling this will cause the plugin to use custom url scheme for oauth/callback.\n *\n * NOTE: custom url scheme require user interaction to return to the app.\n * @default true\n */\n useAssetLinks?: boolean;\n\n /**\n * Weather to To enable social login via Chrome Custom Tabs, set the useChromeCustomTabs flag to true.\n * By default, the SDK uses the Chrome browser for social login.\n *\n * NOTE: custom url scheme require user interaction to return to the app.\n * @default true\n */\n useChromeCustomTabs?: boolean;\n};\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\ndeclare module '@capacitor/cli' {\n export interface PluginsConfig {\n /**\n * You can configure the way the push notifications are displayed when the app is in foreground.\n */\n FronteggNative?: FronteggNativeOptions;\n }\n}\n"]}
@@ -39,7 +39,8 @@ public class FronteggNativePlugin: CAPPlugin {
39
39
  regions.append(RegionConfig(
40
40
  key: dict["key"]!,
41
41
  baseUrl: dict["baseUrl"]!,
42
- clientId: dict["clientId"]!
42
+ clientId: dict["clientId"]!,
43
+ applicationId: dict["applicationId"]
43
44
  ))
44
45
  }
45
46
  }
@@ -57,6 +58,7 @@ public class FronteggNativePlugin: CAPPlugin {
57
58
  let clientId = config.getString("clientId") {
58
59
  fronteggApp.manualInit(baseUrl: baseUrl,
59
60
  cliendId: clientId,
61
+ applicationId: config.getString("applicationId"),
60
62
  handleLoginWithSocialLogin: handleLoginWithSocialLogin,
61
63
  handleLoginWithSSO: handleLoginWithSSO)
62
64
  }else {
@@ -116,21 +118,22 @@ public class FronteggNativePlugin: CAPPlugin {
116
118
  }
117
119
 
118
120
 
119
- func regionToJson(_ region: RegionConfig?) -> [String:String]? {
121
+ func regionToJson(_ region: RegionConfig?) -> [String:String?]? {
120
122
 
121
123
  if let reg = region {
122
124
  return [
123
125
  "baseUrl": reg.baseUrl,
124
126
  "clientId": reg.clientId,
127
+ "applicationId": reg.applicationId,
125
128
  "key": reg.key
126
129
  ]
127
130
  }else {
128
131
  return nil
129
132
  }
130
133
  }
131
- func regionsToJson(_ regions: [RegionConfig]) -> [[String:String]] {
134
+ func regionsToJson(_ regions: [RegionConfig]) -> [[String:String?]] {
132
135
 
133
- var regionData: [[String:String]] = []
136
+ var regionData: [[String:String?]] = []
134
137
  regions.forEach { reg in
135
138
  if let region = regionToJson(reg) {
136
139
  regionData.append(region)
@@ -144,6 +147,7 @@ public class FronteggNativePlugin: CAPPlugin {
144
147
  call.resolve([
145
148
  "baseUrl": fronteggApp.baseUrl,
146
149
  "clientId": fronteggApp.clientId,
150
+ "applicationId": fronteggApp.applicationId as Any,
147
151
  "bundleId": Bundle.main.bundleIdentifier!,
148
152
  "isRegional": fronteggApp.auth.isRegional,
149
153
  "regionData": regionsToJson(fronteggApp.auth.regionData)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontegg/ionic-capacitor",
3
- "version": "2.0.7",
3
+ "version": "2.0.8",
4
4
  "description": "Frontegg Ionic Capacitor SDK",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",