@frontegg/ionic-capacitor 0.0.4 → 0.0.6-alpha.0
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/FronteggIonicCapacitor.podspec +1 -1
- package/README.md +218 -165
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/frontegg/ionic/Debouncer.java +27 -0
- package/android/src/main/java/com/frontegg/ionic/FronteggNativePlugin.java +17 -2
- package/dist/esm/definitions.d.ts +8 -2
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/frontegg.service.d.ts +3 -1
- package/dist/esm/frontegg.service.js +21 -6
- package/dist/esm/frontegg.service.js.map +1 -1
- package/dist/esm/web.d.ts +3 -0
- package/dist/esm/web.js +3 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +24 -6
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +24 -6
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/FronteggNativePlugin.m +2 -0
- package/ios/Plugin/FronteggNativePlugin.swift +27 -1
- package/package.json +6 -3
- package/dist/docs.json +0 -1107
|
@@ -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.0.
|
|
16
|
+
s.dependency "FronteggSwift", "1.0.5"
|
|
17
17
|
s.swift_version = '5.1'
|
|
18
18
|
s.pod_target_xcconfig = {
|
|
19
19
|
'CODE_SIGNING_ALLOWED' => 'YES'
|
package/README.md
CHANGED
|
@@ -1,230 +1,283 @@
|
|
|
1
1
|
# @frontegg/ionic-capacitor
|
|
2
2
|
|
|
3
|
-
Frontegg
|
|
3
|
+
Frontegg is a first-of-its-kind full-stack user management platform, empowering software teams with user infrastructure features for the product-led era.
|
|
4
4
|
|
|
5
|
-
## Install
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
npm install @frontegg/ionic-capacitor
|
|
9
|
-
npx cap sync
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
## API
|
|
6
|
+
## Table of Contents
|
|
13
7
|
|
|
14
|
-
|
|
8
|
+
- [Project Requirements](#project-requirements)
|
|
9
|
+
- [Getting Started](#getting-started)
|
|
10
|
+
- [Prepare Frontegg workspace](#prepare-frontegg-workspace)
|
|
11
|
+
- [Setup Hosted Login](#setup-hosted-login)
|
|
12
|
+
- [Add frontegg package to the project](#add-frontegg-package-to-the-project)
|
|
13
|
+
- [Configure your application](#configure-your-application)
|
|
14
|
+
- [Setup iOS Project](#setup-ios-project)
|
|
15
|
+
- [Create Frontegg plist file](#create-frontegg-plist-file)
|
|
16
|
+
- [Config iOS associated domain](#config-ios-associated-domain)
|
|
17
|
+
- [Setup Android Project](#setup-android-project)
|
|
18
|
+
- [Set minimum SDK version](#set-minimum-sdk-version)
|
|
19
|
+
- [Configure build config fields](#configure-build-config-fields)
|
|
20
|
+
- [Config Android AssetLinks](#config-ios-associated-domain)
|
|
21
|
+
- [Usages](#usages)
|
|
22
|
+
- [Ionic with Angular](#ionic-with-angular)
|
|
23
|
+
- [Login with frontegg](#login-with-frontegg)
|
|
24
|
+
- [Check if user is authenticated](#check-if-user-is-authenticated)
|
|
15
25
|
|
|
16
|
-
* [`login()`](#login)
|
|
17
|
-
* [`logout()`](#logout)
|
|
18
|
-
* [`addListener(string, ...)`](#addlistenerstring)
|
|
19
|
-
* [`getConstants()`](#getconstants)
|
|
20
|
-
* [`getAuthState()`](#getauthstate)
|
|
21
|
-
* [Interfaces](#interfaces)
|
|
22
|
-
* [Type Aliases](#type-aliases)
|
|
23
|
-
* [Enums](#enums)
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
## Project Requirements
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
- Minimum iOS deployment version **=> 14**
|
|
30
|
+
- Min Android SDK **=> 26**
|
|
29
31
|
|
|
30
|
-
### login()
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
login() => void
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
--------------------
|
|
33
|
+
## Getting Started
|
|
37
34
|
|
|
35
|
+
### Prepare Frontegg workspace
|
|
38
36
|
|
|
39
|
-
|
|
37
|
+
Navigate to [Frontegg Portal Settings](https://portal.frontegg.com/development/settings), If you don't have application
|
|
38
|
+
follow integration steps after signing up.
|
|
39
|
+
Copy FronteggDomain to future steps from [Frontegg Portal Domain](https://portal.frontegg.com/development/settings/domains)
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
logout() => void
|
|
43
|
-
```
|
|
41
|
+
### Setup Hosted Login
|
|
44
42
|
|
|
45
|
-
|
|
43
|
+
- Navigate to [Login Method Settings](https://portal.frontegg.com/development/authentication/hosted)
|
|
44
|
+
- Toggle Hosted login method
|
|
45
|
+
- Add `{{IOS_BUNDLE_IDENTIFIER}}://{{FRONTEGG_BASE_URL}}/ios/oauth/callback`
|
|
46
|
+
- Add `{{ANDROID_PACKAGE_NAME}}://{{FRONTEGG_BASE_URL}}/android/oauth/callback`
|
|
47
|
+
- Replace `IOS_BUNDLE_IDENTIFIER` with your application identifier
|
|
48
|
+
- Replace `FRONTEGG_BASE_URL` with your frontegg base url
|
|
49
|
+
- Replace `ANDROID_PACKAGE_NAME` with your android package name
|
|
50
|
+
-
|
|
46
51
|
|
|
52
|
+
### Add frontegg package to the project
|
|
47
53
|
|
|
48
|
-
|
|
54
|
+
Add capacitor to the ionic project if not exists:
|
|
49
55
|
|
|
50
|
-
```
|
|
51
|
-
|
|
56
|
+
```bash
|
|
57
|
+
ionic integrations enable capacitor
|
|
52
58
|
```
|
|
53
59
|
|
|
54
|
-
|
|
55
|
-
| ------------------ | ------------------------------------------------------------- |
|
|
56
|
-
| **`eventName`** | <code>string</code> |
|
|
57
|
-
| **`listenerFunc`** | <code><a href="#listenercallback">ListenerCallback</a></code> |
|
|
58
|
-
|
|
59
|
-
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>> & <a href="#pluginlistenerhandle">PluginListenerHandle</a></code>
|
|
60
|
-
|
|
61
|
-
--------------------
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
### getConstants()
|
|
60
|
+
Use a package manager npm/yarn to install frontegg React Native library.
|
|
65
61
|
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
**NPM:**
|
|
63
|
+
```bash
|
|
64
|
+
npm install -s @frontegg/react-native
|
|
68
65
|
```
|
|
69
66
|
|
|
70
|
-
**
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
### getAuthState()
|
|
76
|
-
|
|
77
|
-
```typescript
|
|
78
|
-
getAuthState() => Promise<FronteggState>
|
|
67
|
+
**Yarn:**
|
|
68
|
+
```bash
|
|
69
|
+
yarn add @frontegg/react-native
|
|
79
70
|
```
|
|
80
71
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
72
|
+
## Configure your application
|
|
73
|
+
|
|
74
|
+
1. Create or Modify your `capacitor.config.ts` file:
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { CapacitorConfig } from '@capacitor/cli';
|
|
78
|
+
|
|
79
|
+
const config: CapacitorConfig = {
|
|
80
|
+
appId: '{YOUR_APPLICATION_ID}',
|
|
81
|
+
appName: '{YOUR_APPLICATION_NAME}',
|
|
82
|
+
webDir: 'www',
|
|
83
|
+
server: {
|
|
84
|
+
androidScheme: 'https'
|
|
85
|
+
},
|
|
86
|
+
ios: {
|
|
87
|
+
path: 'ios',
|
|
88
|
+
},
|
|
89
|
+
android: {
|
|
90
|
+
path: 'android',
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export default config;
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
2. Add the iOS and Android projects to your ionic app by running the following commands:
|
|
98
|
+
|
|
99
|
+
**NOTE: skip the command if you already have the project added.**
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
ionic capacitor add android
|
|
103
|
+
ionic capacitor add ios
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
## Setup iOS Project
|
|
108
|
+
|
|
109
|
+
### Create Frontegg plist file
|
|
110
|
+
|
|
111
|
+
To setup your SwiftUI application to communicate with Frontegg.
|
|
112
|
+
|
|
113
|
+
1. Open the ios folder created by capacitor, and run this command:
|
|
114
|
+
```bash
|
|
115
|
+
ionic capacitor open ios
|
|
116
|
+
```
|
|
117
|
+
or open the Xcode manually.
|
|
118
|
+
2. Create a new file named `Frontegg.plist` under your root project directory, this file will store values to be used variables by Frontegg SDK:
|
|
119
|
+
|
|
120
|
+
```xml
|
|
121
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
122
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
123
|
+
<plist version="1.0">
|
|
124
|
+
<dict>
|
|
125
|
+
<key>baseUrl</key>
|
|
126
|
+
<string>https://[DOMAIN_HOST_FROM_PREVIOUS_STEP]</string>
|
|
127
|
+
<key>clientId</key>
|
|
128
|
+
<string>[CLIENT_ID_FROM_PREVIOUS_STEP]</string>
|
|
129
|
+
</dict>
|
|
130
|
+
</plist>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
3. Enable `CODE_SIGNING_ALLOWED` in the Podfile under `/ios/App` folder.
|
|
134
|
+
|
|
135
|
+
### Config iOS associated domain
|
|
136
|
+
|
|
137
|
+
Configuring your iOS associated domain is required for Magic Link authentication / Reset Password / Activate Account.
|
|
138
|
+
|
|
139
|
+
In order to add your iOS associated domain to your Frontegg application, you will need to update in each of your integrated Frontegg Environments the iOS associated domain that you would like to use with that Environment. Send a POST request to `https://api.frontegg.com/vendors/resources/associated-domains/v1/ios` with the following payload:
|
|
140
|
+
```
|
|
141
|
+
{
|
|
142
|
+
“appId”:[YOUR_ASSOCIATED_DOMAIN]
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
In order to use our API’s, follow [this guide](‘https://docs.frontegg.com/reference/getting-started-with-your-api’) to generate a vendor token.
|
|
115
146
|
|
|
116
147
|
|
|
117
|
-
#### Date
|
|
118
148
|
|
|
119
|
-
|
|
149
|
+
### Setup Android Project
|
|
120
150
|
|
|
121
|
-
|
|
122
|
-
| ---------------------- | ------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------- |
|
|
123
|
-
| **toString** | () => string | Returns a string representation of a date. The format of the string depends on the locale. |
|
|
124
|
-
| **toDateString** | () => string | Returns a date as a string value. |
|
|
125
|
-
| **toTimeString** | () => string | Returns a time as a string value. |
|
|
126
|
-
| **toLocaleString** | () => string | Returns a value as a string value appropriate to the host environment's current locale. |
|
|
127
|
-
| **toLocaleDateString** | () => string | Returns a date as a string value appropriate to the host environment's current locale. |
|
|
128
|
-
| **toLocaleTimeString** | () => string | Returns a time as a string value appropriate to the host environment's current locale. |
|
|
129
|
-
| **valueOf** | () => number | Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC. |
|
|
130
|
-
| **getTime** | () => number | Gets the time value in milliseconds. |
|
|
131
|
-
| **getFullYear** | () => number | Gets the year, using local time. |
|
|
132
|
-
| **getUTCFullYear** | () => number | Gets the year using Universal Coordinated Time (UTC). |
|
|
133
|
-
| **getMonth** | () => number | Gets the month, using local time. |
|
|
134
|
-
| **getUTCMonth** | () => number | Gets the month of a <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
135
|
-
| **getDate** | () => number | Gets the day-of-the-month, using local time. |
|
|
136
|
-
| **getUTCDate** | () => number | Gets the day-of-the-month, using Universal Coordinated Time (UTC). |
|
|
137
|
-
| **getDay** | () => number | Gets the day of the week, using local time. |
|
|
138
|
-
| **getUTCDay** | () => number | Gets the day of the week using Universal Coordinated Time (UTC). |
|
|
139
|
-
| **getHours** | () => number | Gets the hours in a date, using local time. |
|
|
140
|
-
| **getUTCHours** | () => number | Gets the hours value in a <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
141
|
-
| **getMinutes** | () => number | Gets the minutes of a <a href="#date">Date</a> object, using local time. |
|
|
142
|
-
| **getUTCMinutes** | () => number | Gets the minutes of a <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
143
|
-
| **getSeconds** | () => number | Gets the seconds of a <a href="#date">Date</a> object, using local time. |
|
|
144
|
-
| **getUTCSeconds** | () => number | Gets the seconds of a <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
145
|
-
| **getMilliseconds** | () => number | Gets the milliseconds of a <a href="#date">Date</a>, using local time. |
|
|
146
|
-
| **getUTCMilliseconds** | () => number | Gets the milliseconds of a <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
147
|
-
| **getTimezoneOffset** | () => number | Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). |
|
|
148
|
-
| **setTime** | (time: number) => number | Sets the date and time value in the <a href="#date">Date</a> object. |
|
|
149
|
-
| **setMilliseconds** | (ms: number) => number | Sets the milliseconds value in the <a href="#date">Date</a> object using local time. |
|
|
150
|
-
| **setUTCMilliseconds** | (ms: number) => number | Sets the milliseconds value in the <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
151
|
-
| **setSeconds** | (sec: number, ms?: number \| undefined) => number | Sets the seconds value in the <a href="#date">Date</a> object using local time. |
|
|
152
|
-
| **setUTCSeconds** | (sec: number, ms?: number \| undefined) => number | Sets the seconds value in the <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
153
|
-
| **setMinutes** | (min: number, sec?: number \| undefined, ms?: number \| undefined) => number | Sets the minutes value in the <a href="#date">Date</a> object using local time. |
|
|
154
|
-
| **setUTCMinutes** | (min: number, sec?: number \| undefined, ms?: number \| undefined) => number | Sets the minutes value in the <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
155
|
-
| **setHours** | (hours: number, min?: number \| undefined, sec?: number \| undefined, ms?: number \| undefined) => number | Sets the hour value in the <a href="#date">Date</a> object using local time. |
|
|
156
|
-
| **setUTCHours** | (hours: number, min?: number \| undefined, sec?: number \| undefined, ms?: number \| undefined) => number | Sets the hours value in the <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
157
|
-
| **setDate** | (date: number) => number | Sets the numeric day-of-the-month value of the <a href="#date">Date</a> object using local time. |
|
|
158
|
-
| **setUTCDate** | (date: number) => number | Sets the numeric day of the month in the <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
159
|
-
| **setMonth** | (month: number, date?: number \| undefined) => number | Sets the month value in the <a href="#date">Date</a> object using local time. |
|
|
160
|
-
| **setUTCMonth** | (month: number, date?: number \| undefined) => number | Sets the month value in the <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
161
|
-
| **setFullYear** | (year: number, month?: number \| undefined, date?: number \| undefined) => number | Sets the year of the <a href="#date">Date</a> object using local time. |
|
|
162
|
-
| **setUTCFullYear** | (year: number, month?: number \| undefined, date?: number \| undefined) => number | Sets the year value in the <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
163
|
-
| **toUTCString** | () => string | Returns a date converted to a string using Universal Coordinated Time (UTC). |
|
|
164
|
-
| **toISOString** | () => string | Returns a date as a string value in ISO format. |
|
|
165
|
-
| **toJSON** | (key?: any) => string | Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization. |
|
|
151
|
+
## Setup Android Project
|
|
166
152
|
|
|
153
|
+
### Set minimum sdk version
|
|
167
154
|
|
|
168
|
-
|
|
155
|
+
To set up your Android minimum sdk version, open root gradle file at`android/variables.gradle`,
|
|
169
156
|
|
|
157
|
+
Modify the minSdkVersion to 26:
|
|
158
|
+
```groovy
|
|
159
|
+
ext {
|
|
160
|
+
minSdkVersion = 26
|
|
161
|
+
...
|
|
162
|
+
}
|
|
163
|
+
```
|
|
170
164
|
|
|
171
|
-
|
|
165
|
+
### Configure build config fields
|
|
172
166
|
|
|
173
|
-
|
|
167
|
+
To set up your Android application on to communicate with Frontegg, you have to add `buildConfigField` property the gradle `android/app/build.gradle`.
|
|
168
|
+
This property will store frontegg hostname (without https) and client id from previous step:
|
|
174
169
|
|
|
170
|
+
```groovy
|
|
175
171
|
|
|
176
|
-
|
|
172
|
+
def fronteggDomain = "FRONTEGG_DOMAIN_HOST.com" // without protocol https://
|
|
173
|
+
def fronteggClientId = "FRONTEGG_CLIENT_ID"
|
|
177
174
|
|
|
178
|
-
|
|
175
|
+
android {
|
|
176
|
+
defaultConfig {
|
|
179
177
|
|
|
180
|
-
<code>{
|
|
181
178
|
[P in K]: T;
|
|
182
179
|
}</code>
|
|
180
|
+
manifestPlaceholders = [
|
|
181
|
+
"package_name" : applicationId,
|
|
182
|
+
"frontegg_domain" : fronteggDomain,
|
|
183
|
+
"frontegg_client_id": fronteggClientId
|
|
184
|
+
]
|
|
183
185
|
|
|
186
|
+
buildConfigField "String", 'FRONTEGG_DOMAIN', "\"$fronteggDomain\""
|
|
187
|
+
buildConfigField "String", 'FRONTEGG_CLIENT_ID', "\"$fronteggClientId\""
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
}
|
|
192
|
+
```
|
|
184
193
|
|
|
185
|
-
|
|
194
|
+
Add bundleConfig=true if not exists inside the android section inside the app gradle `android/app/build.gradle`
|
|
186
195
|
|
|
187
|
-
|
|
196
|
+
```groovy
|
|
197
|
+
android {
|
|
198
|
+
buildFeatures {
|
|
199
|
+
buildConfig = true
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
```
|
|
188
203
|
|
|
189
204
|
|
|
190
|
-
|
|
205
|
+
### Add permissions to AndroidManifest.xml
|
|
191
206
|
|
|
192
|
-
|
|
207
|
+
Add `INTERNET` permission to the app's manifest file.
|
|
193
208
|
|
|
209
|
+
```xml
|
|
194
210
|
|
|
195
|
-
|
|
211
|
+
<uses-permission android:name="android.permission.INTERNET"/>
|
|
212
|
+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
|
213
|
+
```
|
|
196
214
|
|
|
197
|
-
<code>{ id: string; key: string; isDefault: boolean; name: string; description?: null; permissions: string[]; tenantId?: string; vendorId: string; createdAt: <a href="#date">Date</a>; updatedAt: <a href="#date">Date</a>; }</code>
|
|
198
215
|
|
|
216
|
+
### Config Android AssetLinks
|
|
199
217
|
|
|
200
|
-
|
|
218
|
+
Configuring your Android `AssetLinks` is required for Magic Link authentication / Reset Password / Activate Account /
|
|
219
|
+
login with IdPs.
|
|
201
220
|
|
|
202
|
-
|
|
221
|
+
To add your `AssetLinks` to your Frontegg application, you will need to update in each of your integrated Frontegg
|
|
222
|
+
Environments the `AssetLinks` that you would like to use with that Environment. Send a POST request
|
|
223
|
+
to `https://api.frontegg.com/vendors/resources/associated-domains/v1/android` with the following payload:
|
|
203
224
|
|
|
225
|
+
```
|
|
226
|
+
{
|
|
227
|
+
"packageName": "YOUR_APPLICATION_PACKAGE_NAME",
|
|
228
|
+
"sha256CertFingerprints": ["YOUR_KEYSTORE_CERT_FINGERPRINTS"]
|
|
229
|
+
}
|
|
230
|
+
```
|
|
204
231
|
|
|
205
|
-
|
|
232
|
+
Each Android app has multiple certificate fingerprint, to get your `DEBUG` sha256CertFingerprint you have to run the
|
|
233
|
+
following command:
|
|
206
234
|
|
|
207
|
-
|
|
235
|
+
For Debug mode, run the following command and copy the `SHA-256` value
|
|
208
236
|
|
|
209
|
-
<code>{
|
|
210
237
|
[P in K]: T[P];
|
|
211
238
|
}</code>
|
|
239
|
+
NOTE: make sure to choose the Variant and Config equals to `debug`
|
|
212
240
|
|
|
241
|
+
```bash
|
|
242
|
+
./gradlew signingReport
|
|
213
243
|
|
|
214
|
-
|
|
244
|
+
###################
|
|
245
|
+
# Example Output:
|
|
246
|
+
###################
|
|
215
247
|
|
|
216
|
-
|
|
248
|
+
# Variant: debug
|
|
249
|
+
# Config: debug
|
|
250
|
+
# Store: /Users/davidfrontegg/.android/debug.keystore
|
|
251
|
+
# Alias: AndroidDebugKey
|
|
252
|
+
# MD5: 25:F5:99:23:FC:12:CA:10:8C:43:F4:02:7D:AD:DC:B6
|
|
253
|
+
# SHA1: FC:3C:88:D6:BF:4E:62:2E:F0:24:1D:DB:D7:15:36:D6:3E:14:84:50
|
|
254
|
+
# SHA-256: D9:6B:4A:FD:62:45:81:65:98:4D:5C:8C:A0:68:7B:7B:A5:31:BD:2B:9B:48:D9:CF:20:AE:56:FD:90:C1:C5:EE
|
|
255
|
+
# Valid until: Tuesday, 18 June 2052
|
|
217
256
|
|
|
257
|
+
```
|
|
218
258
|
|
|
219
|
-
|
|
259
|
+
For Release mode, Extract the SHA256 using keytool from your `Release` keystore file:
|
|
220
260
|
|
|
221
|
-
|
|
261
|
+
```bash
|
|
262
|
+
keytool -list -v -keystore /PATH/file.jks -alias YourAlias -storepass *** -keypass ***
|
|
263
|
+
```
|
|
222
264
|
|
|
265
|
+
In order to use our API’s, follow [this guide](https://docs.frontegg.com/reference/getting-started-with-your-api) to
|
|
266
|
+
generate a vendor token.
|
|
223
267
|
|
|
224
|
-
### Enums
|
|
225
268
|
|
|
226
269
|
|
|
227
|
-
|
|
270
|
+
## Usages
|
|
228
271
|
|
|
229
|
-
|
|
230
|
-
| -------------- | ----------------------- |
|
|
231
|
-
| **`FRONTEGG`** | <code>"frontegg"</code> |
|
|
232
|
-
| **`SCIM2`** | <code>"scim2"</code> |
|
|
272
|
+
### Ionic with Angular:
|
|
233
273
|
|
|
234
|
-
|
|
274
|
+
1. Open the `src/app/app.module.ts` file and add the following line to the before `@NgModule` section:
|
|
275
|
+
```typescript
|
|
276
|
+
import { FronteggService } from '@frontegg/ionic-capacitor';
|
|
277
|
+
|
|
278
|
+
@NgModule({
|
|
279
|
+
// ...
|
|
280
|
+
providers: [ {
|
|
281
|
+
provide: 'Frontegg',
|
|
282
|
+
useValue: new FronteggService(),
|
|
283
|
+
}]
|
|
284
|
+
// ...
|
|
285
|
+
})
|
|
286
|
+
```
|
|
287
|
+
2. Find full example under `example/src/app/tab1` and `example/src/app/tab2` files.
|
package/android/build.gradle
CHANGED
|
@@ -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.8.9'
|
|
58
|
-
implementation 'com.frontegg.sdk:android:1.0.
|
|
58
|
+
implementation 'com.frontegg.sdk:android:1.0.6'
|
|
59
59
|
|
|
60
60
|
testImplementation "junit:junit:$junitVersion"
|
|
61
61
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
package com.frontegg.ionic;
|
|
2
|
+
|
|
3
|
+
import java.util.Timer;
|
|
4
|
+
import java.util.TimerTask;
|
|
5
|
+
|
|
6
|
+
public class Debouncer {
|
|
7
|
+
private final long delayMillis;
|
|
8
|
+
private Timer timer = new Timer();
|
|
9
|
+
private TimerTask task;
|
|
10
|
+
|
|
11
|
+
public Debouncer(long delayMillis) {
|
|
12
|
+
this.delayMillis = delayMillis;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public void debounce(final Runnable action) {
|
|
16
|
+
if (task != null) {
|
|
17
|
+
task.cancel();
|
|
18
|
+
}
|
|
19
|
+
task = new TimerTask() {
|
|
20
|
+
@Override
|
|
21
|
+
public void run() {
|
|
22
|
+
action.run();
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
timer.schedule(task, delayMillis);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -23,7 +23,7 @@ import io.reactivex.rxjava3.disposables.Disposable;
|
|
|
23
23
|
@CapacitorPlugin(name = "FronteggNative")
|
|
24
24
|
public class FronteggNativePlugin extends Plugin {
|
|
25
25
|
private Disposable disposable = null;
|
|
26
|
-
|
|
26
|
+
private Debouncer debouncer = new Debouncer(200); // 200ms delay
|
|
27
27
|
@Override
|
|
28
28
|
public void load() {
|
|
29
29
|
Map<String, String> constants = this.getConstants();
|
|
@@ -49,8 +49,10 @@ public class FronteggNativePlugin extends Plugin {
|
|
|
49
49
|
auth.getInitializing().getObservable(),
|
|
50
50
|
auth.getShowLoader().getObservable()
|
|
51
51
|
).subscribe(nullableObject -> {
|
|
52
|
-
sendEvent
|
|
52
|
+
debouncer.debounce(this::sendEvent);
|
|
53
53
|
});
|
|
54
|
+
|
|
55
|
+
sendEvent();
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
private void sendEvent() {
|
|
@@ -98,6 +100,19 @@ public class FronteggNativePlugin extends Plugin {
|
|
|
98
100
|
});
|
|
99
101
|
}
|
|
100
102
|
|
|
103
|
+
@PluginMethod
|
|
104
|
+
public void switchTenant(PluginCall call) {
|
|
105
|
+
String tenantId = call.getString("tenantId");
|
|
106
|
+
if (tenantId == null) {
|
|
107
|
+
call.reject("No tenantId provided");
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
FronteggApp.Companion.getInstance().getAuth().switchTenant(tenantId, () -> {
|
|
111
|
+
call.resolve();
|
|
112
|
+
return null;
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
101
116
|
@PluginMethod
|
|
102
117
|
public void getAuthState(PluginCall call) {
|
|
103
118
|
call.resolve(getData());
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { ListenerCallback, PluginListenerHandle } from '@capacitor/core';
|
|
2
|
-
import type { IUserProfile } from '@frontegg/rest-api';
|
|
3
|
-
export declare type User = IUserProfile
|
|
2
|
+
import type { ITenantsResponse, IUserProfile } from '@frontegg/rest-api';
|
|
3
|
+
export declare type User = IUserProfile & {
|
|
4
|
+
tenants: ITenantsResponse[];
|
|
5
|
+
activeTenant: ITenantsResponse;
|
|
6
|
+
};
|
|
4
7
|
export interface FronteggState {
|
|
5
8
|
accessToken: string | null;
|
|
6
9
|
refreshToken: string | null;
|
|
@@ -15,6 +18,9 @@ export declare type SubscribeMap<T> = {
|
|
|
15
18
|
export interface FronteggNativePlugin {
|
|
16
19
|
login(): void;
|
|
17
20
|
logout(): void;
|
|
21
|
+
switchTenant(payload: {
|
|
22
|
+
tenantId: string;
|
|
23
|
+
}): Promise<void>;
|
|
18
24
|
addListener(eventName: string, listenerFunc: ListenerCallback): Promise<PluginListenerHandle> & PluginListenerHandle;
|
|
19
25
|
getConstants(): Promise<Record<string, string>>;
|
|
20
26
|
getAuthState(): Promise<FronteggState>;
|
|
@@ -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 { IUserProfile } from '@frontegg/rest-api';\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}\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\n\nexport interface FronteggNativePlugin {\n login(): void;\n\n logout(): void;\n\n switchTenant(payload:{tenantId: string}): Promise<void>;\n\n addListener(eventName: string, listenerFunc: ListenerCallback): Promise<PluginListenerHandle> & PluginListenerHandle\n\n getConstants(): Promise<Record<string, string>>;\n\n getAuthState(): Promise<FronteggState>;\n\n}\n"]}
|
|
@@ -2,6 +2,7 @@ import { FronteggState } from './definitions';
|
|
|
2
2
|
export declare class FronteggService {
|
|
3
3
|
private state;
|
|
4
4
|
private mapListeners;
|
|
5
|
+
private readonly orderedListenerKeys;
|
|
5
6
|
constructor();
|
|
6
7
|
getState(): FronteggState;
|
|
7
8
|
get $isLoading(): {
|
|
@@ -13,7 +14,7 @@ export declare class FronteggService {
|
|
|
13
14
|
subscribe(listener: import("./definitions").SubscribeFunc<FronteggState, "isAuthenticated">): () => void;
|
|
14
15
|
};
|
|
15
16
|
get $user(): {
|
|
16
|
-
value: import("
|
|
17
|
+
value: import("./definitions").User | null;
|
|
17
18
|
subscribe(listener: import("./definitions").SubscribeFunc<FronteggState, "user">): () => void;
|
|
18
19
|
};
|
|
19
20
|
get $accessToken(): {
|
|
@@ -25,4 +26,5 @@ export declare class FronteggService {
|
|
|
25
26
|
*/
|
|
26
27
|
login(): void;
|
|
27
28
|
logout(): void;
|
|
29
|
+
switchTenant(tenantId: string): Promise<void>;
|
|
28
30
|
}
|