@falconeta/capacitor-aws-amplify 0.0.5 → 0.0.7

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/README.md CHANGED
@@ -18,6 +18,7 @@ npx cap sync
18
18
  * [`federatedSignIn(...)`](#federatedsignin)
19
19
  * [`signOut()`](#signout)
20
20
  * [Interfaces](#interfaces)
21
+ * [Enums](#enums)
21
22
 
22
23
  </docgen-index>
23
24
 
@@ -55,12 +56,12 @@ signIn(options: { email: string; password: string; }) => Promise<CognitoAuthSess
55
56
  ### federatedSignIn(...)
56
57
 
57
58
  ```typescript
58
- federatedSignIn(options: { provider: string; }) => Promise<CognitoAuthSession>
59
+ federatedSignIn(options: { provider: CognitoHostedUIIdentityProvider; }) => Promise<CognitoAuthSession>
59
60
  ```
60
61
 
61
- | Param | Type |
62
- | ------------- | ---------------------------------- |
63
- | **`options`** | <code>{ provider: string; }</code> |
62
+ | Param | Type |
63
+ | ------------- | ---------------------------------------------------------------------------------------------------------- |
64
+ | **`options`** | <code>{ provider: <a href="#cognitohosteduiidentityprovider">CognitoHostedUIIdentityProvider</a>; }</code> |
64
65
 
65
66
  **Returns:** <code>Promise&lt;<a href="#cognitoauthsession">CognitoAuthSession</a>&gt;</code>
66
67
 
@@ -103,4 +104,18 @@ signOut() => Promise<any>
103
104
  | **`refreshToken`** | <code>string</code> |
104
105
  | **`deviceKey`** | <code>string \| null</code> |
105
106
 
107
+
108
+ ### Enums
109
+
110
+
111
+ #### CognitoHostedUIIdentityProvider
112
+
113
+ | Members | Value |
114
+ | -------------- | ------------------------------ |
115
+ | **`Cognito`** | <code>"COGNITO"</code> |
116
+ | **`Google`** | <code>"Google"</code> |
117
+ | **`Facebook`** | <code>"Facebook"</code> |
118
+ | **`Amazon`** | <code>"LoginWithAmazon"</code> |
119
+ | **`Apple`** | <code>"SignInWithApple"</code> |
120
+
106
121
  </docgen-api>
@@ -55,4 +55,9 @@ dependencies {
55
55
  testImplementation "junit:junit:$junitVersion"
56
56
  androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
57
57
  androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
58
+ // Amplify core dependency
59
+ implementation 'com.amplifyframework:core:1.38.7'
60
+
61
+ // AWS Cognito dependency
62
+ implementation 'com.amplifyframework:aws-auth-cognito:1.38.7'
58
63
  }
@@ -1,2 +1,12 @@
1
1
  <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <queries>
3
+ <intent>
4
+ <action android:name="android.intent.action.VIEW" />
5
+ <data android:scheme="https" />
6
+ </intent>
7
+ <intent>
8
+ <action android:name=
9
+ "android.support.customtabs.action.CustomTabsService" />
10
+ </intent>
11
+ </queries>
2
12
  </manifest>
@@ -1,11 +1,282 @@
1
1
  package com.capacitor.aws.amplify;
2
2
 
3
+ import android.app.Activity;
4
+ import android.content.Context;
5
+ import android.os.Build;
3
6
  import android.util.Log;
4
7
 
8
+ import androidx.annotation.NonNull;
9
+ import androidx.annotation.Nullable;
10
+ import androidx.annotation.RequiresApi;
11
+
12
+ import com.amazonaws.mobile.client.AWSMobileClient;
13
+ import com.amazonaws.mobile.client.DeviceOperations;
14
+ import com.amazonaws.mobile.client.results.Device;
15
+ import com.amazonaws.mobile.client.results.ListDevicesResult;
16
+ import com.amazonaws.mobile.client.results.Tokens;
17
+ import com.amplifyframework.AmplifyException;
18
+ import com.amplifyframework.auth.AuthCategoryConfiguration;
19
+ import com.amplifyframework.auth.AuthException;
20
+ import com.amplifyframework.auth.AuthProvider;
21
+ import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin;
22
+ import com.amplifyframework.auth.cognito.AWSCognitoAuthSession;
23
+ import com.amplifyframework.auth.result.AuthSessionResult;
24
+ import com.amplifyframework.auth.result.AuthSignInResult;
25
+ import com.amplifyframework.core.Amplify;
26
+ import com.amplifyframework.core.AmplifyConfiguration;
27
+ import com.amplifyframework.core.category.CategoryConfiguration;
28
+ import com.getcapacitor.JSObject;
29
+
30
+ import org.json.JSONException;
31
+ import org.json.JSONObject;
32
+
33
+ import java.util.HashMap;
34
+ import java.util.List;
35
+ import java.util.Map;
36
+ import java.util.Objects;
37
+ import java.util.function.Consumer;
38
+
5
39
  public class AwsAmplify {
6
40
 
7
- public String echo(String value) {
8
- Log.i("Echo", value);
9
- return value;
41
+ @RequiresApi(api = Build.VERSION_CODES.N)
42
+ public void load(JSObject cognitoConfig, Context context, @NonNull Consumer onSuccess, @NonNull Consumer<Exception> onError) {
43
+
44
+ JSObject oauth = (JSObject) cognitoConfig.getJSObject("oauth");
45
+
46
+ try {
47
+ JSONObject auth = new JSONObject();
48
+ auth.put("plugins", new JSONObject().put(
49
+ "awsCognitoAuthPlugin", new JSONObject().put(
50
+ "IdentityManager", new JSONObject().put(
51
+ "Default", new JSONObject())
52
+ ).put(
53
+ "CredentialsProvider", new JSONObject().put(
54
+ "CognitoIdentity", new JSONObject().put(
55
+ "Default", new JSONObject().put(
56
+ "PoolId", cognitoConfig.get("aws_cognito_identity_pool_id")
57
+ ).put(
58
+ "Region", cognitoConfig.get("aws_cognito_region")
59
+ )
60
+ )
61
+ )
62
+ ).put(
63
+ "CognitoUserPool", new JSONObject().put(
64
+ "Default", new JSONObject().put(
65
+ "PoolId", cognitoConfig.get("aws_user_pools_id")
66
+ ).put(
67
+ "AppClientId", cognitoConfig.get("aws_user_pools_web_client_id")
68
+ ).put(
69
+ "Region", cognitoConfig.get("aws_cognito_region")
70
+ )
71
+ )
72
+ ).put(
73
+ "Auth", new JSONObject().put(
74
+ "Default", new JSONObject().put(
75
+ "authenticationFlowType", "USER_SRP_AUTH"
76
+ ).put(
77
+ "OAuth", new JSONObject().put(
78
+ "WebDomain", oauth.get("domain")
79
+ ).put(
80
+ "AppClientId", cognitoConfig.get("aws_user_pools_web_client_id")
81
+ ).put(
82
+ "SignInRedirectURI", oauth.get("redirectSignIn")
83
+ ).put(
84
+ "SignOutRedirectURI", oauth.get("redirectSignOut")
85
+ ).put(
86
+ "Scopes", oauth.getJSONArray("scope")
87
+ )
88
+ )
89
+ )
90
+ )
91
+ )
92
+ );
93
+
94
+ Amplify.addPlugin(new AWSCognitoAuthPlugin());
95
+ AuthCategoryConfiguration authConfig = new AuthCategoryConfiguration();
96
+ authConfig.populateFromJSON(auth);
97
+ Map<String, CategoryConfiguration> config = new HashMap();
98
+ config.put("auth", authConfig);
99
+ AmplifyConfiguration configuration = new AmplifyConfiguration(config);
100
+ Amplify.configure(configuration, context);
101
+ onSuccess.accept(null);
102
+ } catch (AmplifyException e) {
103
+ onError.accept(e);
104
+ } catch (JSONException e) {
105
+ onError.accept(e);
106
+ throw new RuntimeException(e);
107
+ }
108
+
109
+ }
110
+
111
+
112
+ @RequiresApi(api = Build.VERSION_CODES.N)
113
+ public void federatedSignIn(String providerString, Activity activity, @NonNull Consumer<AuthSignInResult> onSuccess,
114
+ @NonNull Consumer<AuthException> onError) {
115
+ AuthProvider provider = null;
116
+
117
+ if (providerString != null) {
118
+ if (providerString.equals("Google")) {
119
+ provider = AuthProvider.google();
120
+ }
121
+
122
+ if (providerString.equals("facebook")) {
123
+ provider = AuthProvider.facebook();
124
+ }
125
+
126
+ if (providerString.equals("apple")) {
127
+ provider = AuthProvider.apple();
128
+ }
129
+
130
+
131
+ if (provider != null) {
132
+ Amplify.Auth.signInWithSocialWebUI(
133
+ provider,
134
+ activity,
135
+ result -> {
136
+ onSuccess.accept(result);
137
+
138
+ // mAwsService.fetchAuthSession(
139
+ // call::resolve,
140
+ // error -> {
141
+ // Log.e(TAG, "session error: ", error);
142
+ // call.reject(error.toString());
143
+ // });
144
+ },
145
+ error -> {
146
+ onError.accept(error);
147
+ });
148
+ }
149
+ }
150
+ }
151
+
152
+ @RequiresApi(api = Build.VERSION_CODES.N)
153
+ public void fetchAuthSession(@Nullable Consumer<JSObject> onSuccess,
154
+ @Nullable Consumer<Exception> onError) {
155
+ // mFetching = true;
156
+
157
+ fetchSessionInternal(
158
+ authSession -> {
159
+ // mFetching = false;
160
+
161
+ if (authSession != null && onSuccess != null) {
162
+ onSuccess.accept(authSession.toJson());
163
+ }
164
+ },
165
+ error -> {
166
+ // mFetching = false;
167
+
168
+ if (onError != null) {
169
+ String message = error.getMessage();
170
+ String suggestion = error.getRecoverySuggestion();
171
+ Throwable cause = error.getCause();
172
+
173
+ // AwsAuthException authException;
174
+ //
175
+ // if (message != null && cause != null) {
176
+ // authException = new AwsAuthException(message, cause, suggestion);
177
+ // } else
178
+ // authException = new AwsAuthException(
179
+ // Objects.requireNonNullElse(message, "Aws Auth Error"), "Generic");
180
+
181
+ onError.accept(error);
182
+ }
183
+ });
184
+ }
185
+
186
+ @RequiresApi(api = Build.VERSION_CODES.N)
187
+ private void fetchSessionInternal(@Nullable Consumer<AwsAuthSession> onSuccess,
188
+ @Nullable Consumer<AuthException> onError) {
189
+ Amplify.Auth.fetchAuthSession(
190
+ session -> {
191
+ AWSCognitoAuthSession cognitoAuthSession = (AWSCognitoAuthSession) session;
192
+ AuthSessionResult<String> authSessionResult = cognitoAuthSession.getIdentityId();
193
+ AuthSessionResult.Type type = authSessionResult.getType();
194
+ String identityId = authSessionResult.getValue();
195
+
196
+ // Success.
197
+ if (type == AuthSessionResult.Type.SUCCESS && identityId != null) {
198
+ // Log.i(TAG, "IdentityId: " + identityId);
199
+
200
+ try {
201
+ AwsAuthSession authSession = getSessionInternal();
202
+ // setSession(authSession);
203
+
204
+ if (authSession != null && onSuccess != null) {
205
+ onSuccess.accept(authSession);
206
+ }
207
+
208
+ } catch (Exception e) {
209
+ e.printStackTrace();
210
+
211
+ if (onError != null) {
212
+ onError.accept(new AuthException("Error", e.toString()));
213
+ }
214
+ }
215
+ }
216
+
217
+ // Error.
218
+ else {
219
+ AuthException error = cognitoAuthSession.getIdentityId().getError();
220
+ // Log.e(TAG, "IdentityId not present because: " + error);
221
+
222
+ if (onError != null) {
223
+ onError.accept(error);
224
+ }
225
+ }
226
+ },
227
+ error -> {
228
+ // Log.e(TAG, "Session error: ", error);
229
+
230
+ if (onError != null) {
231
+ onError.accept(error);
232
+ }
233
+ });
234
+ }
235
+
236
+ private AwsAuthSession getSessionInternal() {
237
+ try {
238
+ AWSMobileClient mClient = AWSMobileClient.getInstance();
239
+ Tokens tokens = mClient.getTokens();
240
+
241
+ String accessToken = tokens.getAccessToken().getTokenString();
242
+ String idToken = tokens.getIdToken().getTokenString();
243
+ String refreshToken = tokens.getRefreshToken().getTokenString();
244
+
245
+ DeviceOperations deviceOperations = mClient.getDeviceOperations();
246
+ ListDevicesResult devicesList = deviceOperations.list();
247
+ List<Device> devices = devicesList.getDevices();
248
+
249
+ String deviceKey = null;
250
+
251
+ if (!devices.isEmpty()) {
252
+ deviceKey = deviceOperations.get().getDeviceKey();
253
+ }
254
+
255
+ return AwsAuthSession.builder(mClient.getIdentityId())
256
+ .setAccessToken(accessToken)
257
+ .setIdToken(idToken)
258
+ .setRefreshToken(refreshToken)
259
+ .setDeviceKey(deviceKey)
260
+ .build();
261
+ } catch (Exception e) {
262
+ return null;
10
263
  }
264
+ }
265
+
266
+ /**
267
+ * Sign out of the current device.
268
+ *
269
+ * @param onSuccess success callback.
270
+ * @param onError error callback.
271
+ */
272
+ @RequiresApi(api = Build.VERSION_CODES.N)
273
+ public void signOut(@NonNull Consumer<Boolean> onSuccess,
274
+ @NonNull Consumer<AuthException> onError) {
275
+ Amplify.Auth.signOut(
276
+ () -> onSuccess.accept(true),
277
+ error -> {
278
+ onError.accept(error);
279
+ }
280
+ );
281
+ }
11
282
  }
@@ -1,5 +1,9 @@
1
1
  package com.capacitor.aws.amplify;
2
2
 
3
+ import android.os.Build;
4
+
5
+ import androidx.annotation.RequiresApi;
6
+
3
7
  import com.getcapacitor.JSObject;
4
8
  import com.getcapacitor.Plugin;
5
9
  import com.getcapacitor.PluginCall;
@@ -11,12 +15,55 @@ public class AwsAmplifyPlugin extends Plugin {
11
15
 
12
16
  private AwsAmplify implementation = new AwsAmplify();
13
17
 
18
+ @RequiresApi(api = Build.VERSION_CODES.N)
14
19
  @PluginMethod
15
- public void echo(PluginCall call) {
16
- String value = call.getString("value");
20
+ public void load(PluginCall call) {
21
+ var cognitoConfig = call.getObject("cognitoConfig");
17
22
 
18
- JSObject ret = new JSObject();
19
- ret.put("value", implementation.echo(value));
20
- call.resolve(ret);
23
+ implementation.load(
24
+ cognitoConfig,
25
+ bridge.getContext(),
26
+ result -> call.resolve(),
27
+ error -> {
28
+ call.reject(error.toString());
29
+ });
21
30
  }
31
+
32
+ @RequiresApi(api = Build.VERSION_CODES.N)
33
+ @PluginMethod
34
+ public void signOut(PluginCall call) {
35
+
36
+ implementation.signOut(
37
+ result -> call.resolve(),
38
+ error -> {
39
+ call.reject(error.toString());
40
+ });
41
+ }
42
+
43
+ @RequiresApi(api = Build.VERSION_CODES.N)
44
+ @PluginMethod
45
+ public void federatedSignIn(PluginCall call) {
46
+ String provider = call.getString("provider");
47
+
48
+ implementation.federatedSignIn(
49
+ provider,
50
+ this.getActivity(),
51
+ result -> call.resolve(),
52
+ error -> {
53
+ call.reject(error.toString());
54
+ });
55
+ // onSuccess: { data in
56
+ // self.implementation.fetchAuthSession(
57
+ // onSuccess: {session in
58
+ // call.resolve(session)
59
+ // },
60
+ // onError: {error in
61
+ // call.reject(error.localizedDescription)
62
+ // })
63
+
64
+ // onError: { error in
65
+ // print(error)
66
+ // call.reject(error.localizedDescription)
67
+ // })
68
+ }
22
69
  }
@@ -0,0 +1,126 @@
1
+ package com.capacitor.aws.amplify;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import androidx.annotation.Nullable;
5
+
6
+ import com.getcapacitor.JSObject;
7
+ import com.google.gson.Gson;
8
+
9
+ import org.json.JSONException;
10
+
11
+ public class AwsAuthSession {
12
+ @NonNull
13
+ private final String identityId;
14
+
15
+ @NonNull
16
+ private final String accessToken;
17
+
18
+ @NonNull
19
+ private final String idToken;
20
+
21
+ @NonNull
22
+ private final String refreshToken;
23
+
24
+ @Nullable
25
+ private final String deviceKey;
26
+
27
+ /**
28
+ * Constructs a new builder of {@link AwsAuthSession}.
29
+ */
30
+ @NonNull
31
+ public static Builder builder(@NonNull String id) {
32
+ return new Builder(id);
33
+ }
34
+
35
+ AwsAuthSession(@NonNull Builder builder) {
36
+ identityId = builder.mIdentityId;
37
+ accessToken = builder.mAccessToken;
38
+ idToken = builder.mIdToken;
39
+ refreshToken = builder.mRefreshToken;
40
+ deviceKey = builder.mDeviceKey;
41
+ }
42
+
43
+ @NonNull
44
+ public String getIdentityId() {
45
+ return identityId;
46
+ }
47
+
48
+ @NonNull
49
+ public String getAccessToken() {
50
+ return accessToken;
51
+ }
52
+
53
+ @NonNull
54
+ public String getIdToken() {
55
+ return idToken;
56
+ }
57
+
58
+ @NonNull
59
+ public String getRefreshToken() {
60
+ return refreshToken;
61
+ }
62
+
63
+ @Nullable
64
+ public String getDeviceKey() {
65
+ return deviceKey;
66
+ }
67
+
68
+ @Nullable
69
+ public JSObject toJson() {
70
+ try {
71
+ String jsonInString = new Gson().toJson(this);
72
+ return new JSObject(jsonInString);
73
+ } catch (JSONException e) {
74
+ return null;
75
+ }
76
+ }
77
+
78
+ /**
79
+ * Builder for creating an {@link AwsAuthSession}.
80
+ */
81
+ public static final class Builder {
82
+ String mIdentityId;
83
+
84
+ String mAccessToken;
85
+
86
+ String mIdToken;
87
+
88
+ String mRefreshToken;
89
+
90
+ @Nullable
91
+ String mDeviceKey;
92
+
93
+ public Builder(@NonNull String identityId) {
94
+ mIdentityId = identityId;
95
+ }
96
+
97
+ public Builder setAccessToken(String accessToken) {
98
+ mAccessToken = accessToken;
99
+ return this;
100
+ }
101
+
102
+ public Builder setIdToken(String idToken) {
103
+ mIdToken = idToken;
104
+ return this;
105
+ }
106
+
107
+ public Builder setRefreshToken(String refreshToken) {
108
+ mRefreshToken = refreshToken;
109
+ return this;
110
+ }
111
+
112
+ public Builder setDeviceKey(@Nullable String deviceKey) {
113
+ mDeviceKey = deviceKey;
114
+ return this;
115
+ }
116
+
117
+ /**
118
+ * Constructs the {@link AwsAuthSession} defined by this builder.
119
+ */
120
+ @NonNull
121
+ public AwsAuthSession build() {
122
+ return new AwsAuthSession(this);
123
+ }
124
+ }
125
+ }
126
+
package/dist/docs.json CHANGED
@@ -43,19 +43,20 @@
43
43
  },
44
44
  {
45
45
  "name": "federatedSignIn",
46
- "signature": "(options: { provider: string; }) => Promise<CognitoAuthSession>",
46
+ "signature": "(options: { provider: CognitoHostedUIIdentityProvider; }) => Promise<CognitoAuthSession>",
47
47
  "parameters": [
48
48
  {
49
49
  "name": "options",
50
50
  "docs": "",
51
- "type": "{ provider: string; }"
51
+ "type": "{ provider: CognitoHostedUIIdentityProvider; }"
52
52
  }
53
53
  ],
54
54
  "returns": "Promise<CognitoAuthSession>",
55
55
  "tags": [],
56
56
  "docs": "",
57
57
  "complexTypes": [
58
- "CognitoAuthSession"
58
+ "CognitoAuthSession",
59
+ "CognitoHostedUIIdentityProvider"
59
60
  ],
60
61
  "slug": "federatedsignin"
61
62
  },
@@ -169,7 +170,44 @@
169
170
  ]
170
171
  }
171
172
  ],
172
- "enums": [],
173
+ "enums": [
174
+ {
175
+ "name": "CognitoHostedUIIdentityProvider",
176
+ "slug": "cognitohosteduiidentityprovider",
177
+ "members": [
178
+ {
179
+ "name": "Cognito",
180
+ "value": "\"COGNITO\"",
181
+ "tags": [],
182
+ "docs": ""
183
+ },
184
+ {
185
+ "name": "Google",
186
+ "value": "\"Google\"",
187
+ "tags": [],
188
+ "docs": ""
189
+ },
190
+ {
191
+ "name": "Facebook",
192
+ "value": "\"Facebook\"",
193
+ "tags": [],
194
+ "docs": ""
195
+ },
196
+ {
197
+ "name": "Amazon",
198
+ "value": "\"LoginWithAmazon\"",
199
+ "tags": [],
200
+ "docs": ""
201
+ },
202
+ {
203
+ "name": "Apple",
204
+ "value": "\"SignInWithApple\"",
205
+ "tags": [],
206
+ "docs": ""
207
+ }
208
+ ]
209
+ }
210
+ ],
173
211
  "typeAliases": [],
174
212
  "pluginConfigs": []
175
213
  }
@@ -7,7 +7,7 @@ export interface AwsAmplifyPlugin {
7
7
  password: string;
8
8
  }): Promise<CognitoAuthSession>;
9
9
  federatedSignIn(options: {
10
- provider: string;
10
+ provider: CognitoHostedUIIdentityProvider;
11
11
  }): Promise<CognitoAuthSession>;
12
12
  signOut(): Promise<any>;
13
13
  }
@@ -32,3 +32,10 @@ export interface AWSCognitoConfig {
32
32
  responseType: 'code';
33
33
  };
34
34
  }
35
+ export declare enum CognitoHostedUIIdentityProvider {
36
+ Cognito = "COGNITO",
37
+ Google = "Google",
38
+ Facebook = "Facebook",
39
+ Amazon = "LoginWithAmazon",
40
+ Apple = "SignInWithApple"
41
+ }
@@ -1,2 +1,9 @@
1
- export {};
1
+ export var CognitoHostedUIIdentityProvider;
2
+ (function (CognitoHostedUIIdentityProvider) {
3
+ CognitoHostedUIIdentityProvider["Cognito"] = "COGNITO";
4
+ CognitoHostedUIIdentityProvider["Google"] = "Google";
5
+ CognitoHostedUIIdentityProvider["Facebook"] = "Facebook";
6
+ CognitoHostedUIIdentityProvider["Amazon"] = "LoginWithAmazon";
7
+ CognitoHostedUIIdentityProvider["Apple"] = "SignInWithApple";
8
+ })(CognitoHostedUIIdentityProvider || (CognitoHostedUIIdentityProvider = {}));
2
9
  //# sourceMappingURL=definitions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface AwsAmplifyPlugin {\n load(options: { cognitoConfig: AWSCognitoConfig }): Promise<void>;\n signIn(options: {\n email: string;\n password: string;\n }): Promise<CognitoAuthSession>;\n federatedSignIn(options: {\n provider: string;\n }): Promise<CognitoAuthSession>;\n signOut(): Promise<any>;\n}\n\nexport interface CognitoAuthSession {\n accessToken: string;\n idToken: string;\n identityId: string;\n refreshToken: string;\n deviceKey: string | null;\n}\n\nexport interface AWSCognitoConfig {\n aws_cognito_region: string;\n aws_user_pools_id: string;\n aws_user_pools_web_client_id: string;\n aws_cognito_identity_pool_id: string;\n aws_mandatory_sign_in: string;\n oauth: {\n domain: string;\n scope: string[];\n redirectSignIn: string;\n redirectSignOut: string;\n responseType: 'code';\n };\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAkCA,MAAM,CAAN,IAAY,+BAMX;AAND,WAAY,+BAA+B;IACzC,sDAAmB,CAAA;IACnB,oDAAiB,CAAA;IACjB,wDAAqB,CAAA;IACrB,6DAA0B,CAAA;IAC1B,4DAAyB,CAAA;AAC3B,CAAC,EANW,+BAA+B,KAA/B,+BAA+B,QAM1C","sourcesContent":["export interface AwsAmplifyPlugin {\n load(options: { cognitoConfig: AWSCognitoConfig }): Promise<void>;\n signIn(options: {\n email: string;\n password: string;\n }): Promise<CognitoAuthSession>;\n federatedSignIn(options: {\n provider: CognitoHostedUIIdentityProvider;\n }): Promise<CognitoAuthSession>;\n signOut(): Promise<any>;\n}\n\nexport interface CognitoAuthSession {\n accessToken: string;\n idToken: string;\n identityId: string;\n refreshToken: string;\n deviceKey: string | null;\n}\n\nexport interface AWSCognitoConfig {\n aws_cognito_region: string;\n aws_user_pools_id: string;\n aws_user_pools_web_client_id: string;\n aws_cognito_identity_pool_id: string;\n aws_mandatory_sign_in: string;\n oauth: {\n domain: string;\n scope: string[];\n redirectSignIn: string;\n redirectSignOut: string;\n responseType: 'code';\n };\n}\nexport enum CognitoHostedUIIdentityProvider {\n Cognito = \"COGNITO\",\n Google = \"Google\",\n Facebook = \"Facebook\",\n Amazon = \"LoginWithAmazon\",\n Apple = \"SignInWithApple\"\n}\n"]}
@@ -5,6 +5,15 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var core = require('@capacitor/core');
6
6
  var awsAmplify = require('aws-amplify');
7
7
 
8
+ exports.CognitoHostedUIIdentityProvider = void 0;
9
+ (function (CognitoHostedUIIdentityProvider) {
10
+ CognitoHostedUIIdentityProvider["Cognito"] = "COGNITO";
11
+ CognitoHostedUIIdentityProvider["Google"] = "Google";
12
+ CognitoHostedUIIdentityProvider["Facebook"] = "Facebook";
13
+ CognitoHostedUIIdentityProvider["Amazon"] = "LoginWithAmazon";
14
+ CognitoHostedUIIdentityProvider["Apple"] = "SignInWithApple";
15
+ })(exports.CognitoHostedUIIdentityProvider || (exports.CognitoHostedUIIdentityProvider = {}));
16
+
8
17
  const AwsAmplify = core.registerPlugin('AwsAmplify', {
9
18
  web: () => Promise.resolve().then(function () { return web; }).then(m => new m.AwsAmplifyWeb()),
10
19
  });
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst AwsAmplify = registerPlugin('AwsAmplify', {\n web: () => import('./web').then(m => new m.AwsAmplifyWeb()),\n});\nexport * from './definitions';\nexport { AwsAmplify };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nimport { Amplify, Auth } from 'aws-amplify';\nexport class AwsAmplifyWeb extends WebPlugin {\n async load(options) {\n this.cognitoConfig = options.cognitoConfig;\n Amplify.configure(Object.assign({}, options.cognitoConfig));\n }\n async signIn(options) {\n // console.log(LOG_PREFIX, options);\n if (!this.cognitoConfig) {\n throw new Error('call load first');\n }\n return new Promise((resolve, reject) => {\n Auth.signIn(options.email, options.password).then((user) => {\n const cognitoAuthSession = this.getCognitoAuthSession(user, \n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.cognitoConfig.aws_cognito_identity_pool_id);\n cognitoAuthSession ? resolve(cognitoAuthSession) : reject();\n });\n });\n }\n async federatedSignIn(options) {\n // console.log(LOG_PREFIX, options);\n if (!this.cognitoConfig) {\n throw new Error('call load first');\n }\n return new Promise((resolve, reject) => {\n Auth.federatedSignIn(options)\n .then(_ => {\n // console.log(LOG_PREFIX + \" credential\", cred);\n Auth.currentAuthenticatedUser().then(user => {\n // console.log(LOG_PREFIX + \" user\", user);\n const cognitoAuthSession = this.getCognitoAuthSession(user, \n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.cognitoConfig.aws_cognito_identity_pool_id);\n cognitoAuthSession ? resolve(cognitoAuthSession) : reject();\n });\n })\n .catch(err => reject(err));\n });\n }\n async signOut() {\n return Auth.signOut();\n }\n getCognitoAuthSession(user, identityId) {\n const userSession = user.getSignInUserSession();\n if (userSession) {\n const res = {\n accessToken: userSession.getAccessToken().getJwtToken(),\n idToken: userSession.getIdToken().getJwtToken(),\n identityId: identityId,\n refreshToken: userSession.getRefreshToken().getToken(),\n deviceKey: userSession.getAccessToken().decodePayload().device_key,\n };\n return res;\n }\n return null;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin","Amplify","Auth"],"mappings":";;;;;;;AACK,MAAC,UAAU,GAAGA,mBAAc,CAAC,YAAY,EAAE;AAChD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;AAC/D,CAAC;;ACDM,MAAM,aAAa,SAASC,cAAS,CAAC;AAC7C,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;AACxB,QAAQ,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;AACnD,QAAQC,kBAAO,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;AACpE,KAAK;AACL,IAAI,MAAM,MAAM,CAAC,OAAO,EAAE;AAC1B;AACA,QAAQ,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;AACjC,YAAY,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;AAC/C,SAAS;AACT,QAAQ,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;AAChD,YAAYC,eAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK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oB,EAAE,CAAC;AACxD,QAAQ,IAAI,WAAW,EAAE;AACzB,YAAY,MAAM,GAAG,GAAG;AACxB,gBAAgB,WAAW,EAAE,WAAW,CAAC,cAAc,EAAE,CAAC,WAAW,EAAE;AACvE,gBAAgB,OAAO,EAAE,WAAW,CAAC,UAAU,EAAE,CAAC,WAAW,EAAE;AAC/D,gBAAgB,UAAU,EAAE,UAAU;AACtC,gBAAgB,YAAY,EAAE,WAAW,CAAC,eAAe,EAAE,CAAC,QAAQ,EAAE;AACtE,gBAAgB,SAAS,EAAE,WAAW,CAAC,cAAc,EAAE,CAAC,aAAa,EAAE,CAAC,UAAU;AAClF,aAAa,CAAC;AACd,YAAY,OAAO,GAAG,CAAC;AACvB,SAAS;AACT,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var CognitoHostedUIIdentityProvider;\n(function (CognitoHostedUIIdentityProvider) {\n CognitoHostedUIIdentityProvider[\"Cognito\"] = \"COGNITO\";\n CognitoHostedUIIdentityProvider[\"Google\"] = \"Google\";\n CognitoHostedUIIdentityProvider[\"Facebook\"] = \"Facebook\";\n CognitoHostedUIIdentityProvider[\"Amazon\"] = \"LoginWithAmazon\";\n CognitoHostedUIIdentityProvider[\"Apple\"] = \"SignInWithApple\";\n})(CognitoHostedUIIdentityProvider || (CognitoHostedUIIdentityProvider = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst AwsAmplify = registerPlugin('AwsAmplify', {\n web: () => import('./web').then(m => new m.AwsAmplifyWeb()),\n});\nexport * from './definitions';\nexport { AwsAmplify };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nimport { Amplify, Auth } from 'aws-amplify';\nexport class AwsAmplifyWeb extends WebPlugin {\n async load(options) {\n this.cognitoConfig = options.cognitoConfig;\n Amplify.configure(Object.assign({}, options.cognitoConfig));\n }\n async signIn(options) {\n // console.log(LOG_PREFIX, options);\n if (!this.cognitoConfig) {\n throw new Error('call load first');\n }\n return new Promise((resolve, reject) => {\n Auth.signIn(options.email, options.password).then((user) => {\n const cognitoAuthSession = this.getCognitoAuthSession(user, \n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.cognitoConfig.aws_cognito_identity_pool_id);\n cognitoAuthSession ? resolve(cognitoAuthSession) : reject();\n });\n });\n }\n async federatedSignIn(options) {\n // console.log(LOG_PREFIX, options);\n if (!this.cognitoConfig) {\n throw new Error('call load first');\n }\n return new Promise((resolve, reject) => {\n Auth.federatedSignIn(options)\n .then(_ => {\n // console.log(LOG_PREFIX + \" credential\", cred);\n Auth.currentAuthenticatedUser().then(user => {\n // console.log(LOG_PREFIX + \" user\", user);\n const cognitoAuthSession = this.getCognitoAuthSession(user, \n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.cognitoConfig.aws_cognito_identity_pool_id);\n cognitoAuthSession ? resolve(cognitoAuthSession) : reject();\n });\n })\n .catch(err => reject(err));\n });\n }\n async signOut() {\n return Auth.signOut();\n }\n getCognitoAuthSession(user, identityId) {\n const userSession = user.getSignInUserSession();\n if (userSession) {\n const res = {\n accessToken: userSession.getAccessToken().getJwtToken(),\n idToken: userSession.getIdToken().getJwtToken(),\n identityId: identityId,\n refreshToken: userSession.getRefreshToken().getToken(),\n deviceKey: userSession.getAccessToken().decodePayload().device_key,\n };\n return res;\n }\n return null;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["CognitoHostedUIIdentityProvider","registerPlugin","WebPlugin","Amplify","Auth"],"mappings":";;;;;;;AAAWA,iDAAgC;AAC3C,CAAC,UAAU,+BAA+B,EAAE;AAC5C,IAAI,+BAA+B,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;AAC3D,IAAI,+BAA+B,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;AACzD,IAAI,+BAA+B,CAAC,UAAU,CAAC,GAA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UAAU;AACtC,gBAAgB,YAAY,EAAE,WAAW,CAAC,eAAe,EAAE,CAAC,QAAQ,EAAE;AACtE,gBAAgB,SAAS,EAAE,WAAW,CAAC,cAAc,EAAE,CAAC,aAAa,EAAE,CAAC,UAAU;AAClF,aAAa,CAAC;AACd,YAAY,OAAO,GAAG,CAAC;AACvB,SAAS;AACT,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -1,6 +1,15 @@
1
1
  var capacitorAwsAmplify = (function (exports, core, awsAmplify) {
2
2
  'use strict';
3
3
 
4
+ exports.CognitoHostedUIIdentityProvider = void 0;
5
+ (function (CognitoHostedUIIdentityProvider) {
6
+ CognitoHostedUIIdentityProvider["Cognito"] = "COGNITO";
7
+ CognitoHostedUIIdentityProvider["Google"] = "Google";
8
+ CognitoHostedUIIdentityProvider["Facebook"] = "Facebook";
9
+ CognitoHostedUIIdentityProvider["Amazon"] = "LoginWithAmazon";
10
+ CognitoHostedUIIdentityProvider["Apple"] = "SignInWithApple";
11
+ })(exports.CognitoHostedUIIdentityProvider || (exports.CognitoHostedUIIdentityProvider = {}));
12
+
4
13
  const AwsAmplify = core.registerPlugin('AwsAmplify', {
5
14
  web: () => Promise.resolve().then(function () { return web; }).then(m => new m.AwsAmplifyWeb()),
6
15
  });
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst AwsAmplify = registerPlugin('AwsAmplify', {\n web: () => import('./web').then(m => new m.AwsAmplifyWeb()),\n});\nexport * from './definitions';\nexport { AwsAmplify };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nimport { Amplify, Auth } from 'aws-amplify';\nexport class AwsAmplifyWeb extends WebPlugin {\n async load(options) {\n this.cognitoConfig = options.cognitoConfig;\n Amplify.configure(Object.assign({}, options.cognitoConfig));\n }\n async signIn(options) {\n // console.log(LOG_PREFIX, options);\n if (!this.cognitoConfig) {\n throw new Error('call load first');\n }\n return new Promise((resolve, reject) => {\n Auth.signIn(options.email, options.password).then((user) => {\n const cognitoAuthSession = this.getCognitoAuthSession(user, \n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.cognitoConfig.aws_cognito_identity_pool_id);\n cognitoAuthSession ? resolve(cognitoAuthSession) : reject();\n });\n });\n }\n async federatedSignIn(options) {\n // console.log(LOG_PREFIX, options);\n if (!this.cognitoConfig) {\n throw new Error('call load first');\n }\n return new Promise((resolve, reject) => {\n Auth.federatedSignIn(options)\n .then(_ => {\n // console.log(LOG_PREFIX + \" credential\", cred);\n Auth.currentAuthenticatedUser().then(user => {\n // console.log(LOG_PREFIX + \" user\", user);\n const cognitoAuthSession = this.getCognitoAuthSession(user, \n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.cognitoConfig.aws_cognito_identity_pool_id);\n cognitoAuthSession ? resolve(cognitoAuthSession) : reject();\n });\n })\n .catch(err => reject(err));\n });\n }\n async signOut() {\n return Auth.signOut();\n }\n getCognitoAuthSession(user, identityId) {\n const userSession = user.getSignInUserSession();\n if (userSession) {\n const res = {\n accessToken: userSession.getAccessToken().getJwtToken(),\n idToken: userSession.getIdToken().getJwtToken(),\n identityId: identityId,\n refreshToken: userSession.getRefreshToken().getToken(),\n deviceKey: userSession.getAccessToken().decodePayload().device_key,\n };\n return res;\n }\n return null;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin","Amplify","Auth"],"mappings":";;;AACK,UAAC,UAAU,GAAGA,mBAAc,CAAC,YAAY,EAAE;IAChD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;IAC/D,CAAC;;ICDM,MAAM,aAAa,SAASC,cAAS,CAAC;IAC7C,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;IACxB,QAAQ,IAAI,CAAC,aAAa,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AqB,CAAC,IAAI;IAC9E;IACA,oBAAoB,IAAI,CAAC,aAAa,CAAC,4BAA4B,CAAC,CAAC;IACrE,oBAAoB,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,GAAG,MAAM,EAAE,CAAC;IAChF,iBAAiB,CAAC,CAAC;IACnB,aAAa,CAAC;IACd,iBAAiB,KAAK,CAAC,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3C,SAAS,CAAC,CAAC;IACX,KAAK;IACL,IAAI,MAAM,OAAO,GAAG;IACpB,QAAQ,OAAOA,eAAI,CAAC,OAAO,EAAE,CAAC;IAC9B,KAAK;IACL,IAAI,qBAAqB,CAAC,IAAI,EAAE,UAAU,EAAE;IAC5C,QAAQ,MAAM,WAAW,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;IACxD,QAAQ,IAAI,WAAW,EAAE;IACzB,YAAY,MAAM,GAAG,GAAG;IACxB,gBAAgB,WAAW,EAAE,WAAW,CAAC,cAAc,EAAE,CAAC,WAAW,EAAE;IACvE,gBAAgB,OAAO,EAAE,WAAW,CAAC,UAAU,EAAE,CAAC,WAAW,EAAE;IAC/D,gBAAgB,UAAU,EAAE,UAAU;IACtC,gBAAgB,YAAY,EAAE,WAAW,CAAC,eAAe,EAAE,CAAC,QAAQ,EAAE;IACtE,gBAAgB,SAAS,EAAE,WAAW,CAAC,cAAc,EAAE,CAAC,aAAa,EAAE,CAAC,UAAU;IAClF,aAAa,CAAC;IACd,YAAY,OAAO,GAAG,CAAC;IACvB,SAAS;IACT,QAAQ,OAAO,IAAI,CAAC;IACpB,KAAK;IACL;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var CognitoHostedUIIdentityProvider;\n(function (CognitoHostedUIIdentityProvider) {\n CognitoHostedUIIdentityProvider[\"Cognito\"] = \"COGNITO\";\n CognitoHostedUIIdentityProvider[\"Google\"] = \"Google\";\n CognitoHostedUIIdentityProvider[\"Facebook\"] = \"Facebook\";\n CognitoHostedUIIdentityProvider[\"Amazon\"] = \"LoginWithAmazon\";\n CognitoHostedUIIdentityProvider[\"Apple\"] = \"SignInWithApple\";\n})(CognitoHostedUIIdentityProvider || (CognitoHostedUIIdentityProvider = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst AwsAmplify = registerPlugin('AwsAmplify', {\n web: () => import('./web').then(m => new m.AwsAmplifyWeb()),\n});\nexport * from './definitions';\nexport { AwsAmplify };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nimport { Amplify, Auth } from 'aws-amplify';\nexport class AwsAmplifyWeb extends WebPlugin {\n async load(options) {\n this.cognitoConfig = options.cognitoConfig;\n Amplify.configure(Object.assign({}, options.cognitoConfig));\n }\n async signIn(options) {\n // console.log(LOG_PREFIX, options);\n if (!this.cognitoConfig) {\n throw new Error('call load first');\n }\n return new Promise((resolve, reject) => {\n Auth.signIn(options.email, options.password).then((user) => {\n const cognitoAuthSession = this.getCognitoAuthSession(user, \n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.cognitoConfig.aws_cognito_identity_pool_id);\n cognitoAuthSession ? resolve(cognitoAuthSession) : reject();\n });\n });\n }\n async federatedSignIn(options) {\n // console.log(LOG_PREFIX, options);\n if (!this.cognitoConfig) {\n throw new Error('call load first');\n }\n return new Promise((resolve, reject) => {\n Auth.federatedSignIn(options)\n .then(_ => {\n // console.log(LOG_PREFIX + \" credential\", cred);\n Auth.currentAuthenticatedUser().then(user => {\n // console.log(LOG_PREFIX + \" user\", user);\n const cognitoAuthSession = this.getCognitoAuthSession(user, \n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.cognitoConfig.aws_cognito_identity_pool_id);\n cognitoAuthSession ? resolve(cognitoAuthSession) : reject();\n });\n })\n .catch(err => reject(err));\n });\n }\n async signOut() {\n return Auth.signOut();\n }\n getCognitoAuthSession(user, identityId) {\n const userSession = user.getSignInUserSession();\n if (userSession) {\n const res = {\n accessToken: userSession.getAccessToken().getJwtToken(),\n idToken: userSession.getIdToken().getJwtToken(),\n identityId: identityId,\n refreshToken: userSession.getRefreshToken().getToken(),\n deviceKey: userSession.getAccessToken().decodePayload().device_key,\n };\n return res;\n }\n return null;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["CognitoHostedUIIdentityProvider","registerPlugin","WebPlugin","Amplify","Auth"],"mappings":";;;AAAWA,qDAAgC;IAC3C,CAAC,UAAU,+BAA+B,EAAE;IAC5C,IAAI,+BAA+B,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;IAC3D,IAAI,+BAA+B,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;IACzD,IAAI,+BAA+B,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;IAC7D,IAAI,+BAA+B,CAAC,QAAQ,CAAC,GAAG,iBAAiB,CAAC;IAClE,IAAI,+BAA+B,CAAC,OAAO,CAAC,GAAG,iBAAiB,CAAC;IACjE,CAAC,EAAEA,uCAA+B,KAAKA,uCAA+B,GAAG,EAAE,CAAC,CAAC;;ACNxE,UAAC,UAAU,GAAGC,mBAAc,CAAC,YAAY,EAAE;IAChD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;IAC/D,CAAC;;ICDM,MAAM,aAAa,SAASC,cAAS,CAAC;IAC7C,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;IACxB,QAAQ,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IACnD,QAAQC,kBAAO,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;IACpE,KAAK;IACL,IAAI,MAAM,MAAM,CAAC,OAAO,EAAE;IAC1B;IACA,QAAQ,IAAI,CAAC,IAAI,CAAC,aAAa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,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3C,SAAS,CAAC,CAAC;IACX,KAAK;IACL,IAAI,MAAM,OAAO,GAAG;IACpB,QAAQ,OAAOA,eAAI,CAAC,OAAO,EAAE,CAAC;IAC9B,KAAK;IACL,IAAI,qBAAqB,CAAC,IAAI,EAAE,UAAU,EAAE;IAC5C,QAAQ,MAAM,WAAW,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;IACxD,QAAQ,IAAI,WAAW,EAAE;IACzB,YAAY,MAAM,GAAG,GAAG;IACxB,gBAAgB,WAAW,EAAE,WAAW,CAAC,cAAc,EAAE,CAAC,WAAW,EAAE;IACvE,gBAAgB,OAAO,EAAE,WAAW,CAAC,UAAU,EAAE,CAAC,WAAW,EAAE;IAC/D,gBAAgB,UAAU,EAAE,UAAU;IACtC,gBAAgB,YAAY,EAAE,WAAW,CAAC,eAAe,EAAE,CAAC,QAAQ,EAAE;IACtE,gBAAgB,SAAS,EAAE,WAAW,CAAC,cAAc,EAAE,CAAC,aAAa,EAAE,CAAC,UAAU;IAClF,aAAa,CAAC;IACd,YAAY,OAAO,GAAG,CAAC;IACvB,SAAS;IACT,QAAQ,OAAO,IAAI,CAAC;IACpB,KAAK;IACL;;;;;;;;;;;;;;;;;"}
@@ -70,7 +70,8 @@ import AWSMobileClient
70
70
  print ("\(self.TAG) federatedSignIn \(authProvider)")
71
71
 
72
72
  DispatchQueue.main.async {
73
- Amplify.Auth.signInWithWebUI(for: authProvider, presentationAnchor: UIApplication.shared.windows.first!) { result in
73
+ Amplify.Auth.signInWithWebUI(for: authProvider,
74
+ presentationAnchor: UIApplication.shared.windows.first!, options: .preferPrivateSession()) { result in
74
75
  switch result {
75
76
  case .success(let result):
76
77
  print("\(self.TAG) federatedSignIn effettuato con successo: \(result)")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@falconeta/capacitor-aws-amplify",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "plugin that handle amplify features",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",