@falconeta/capacitor-aws-amplify 0.0.7 → 0.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.
- package/README.md +28 -7
- package/dist/docs.json +42 -3
- package/dist/esm/definitions.d.ts +9 -3
- package/dist/esm/definitions.js +5 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +2 -1
- package/dist/esm/web.js +28 -34
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +32 -34
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +32 -34
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/AwsAmplify.swift +3 -0
- package/ios/Plugin/AwsAmplifyPlugin.m +1 -0
- package/ios/Plugin/AwsAmplifyPlugin.swift +10 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@ npx cap sync
|
|
|
16
16
|
* [`load(...)`](#load)
|
|
17
17
|
* [`signIn(...)`](#signin)
|
|
18
18
|
* [`federatedSignIn(...)`](#federatedsignin)
|
|
19
|
+
* [`fetchAuthSession()`](#fetchauthsession)
|
|
19
20
|
* [`signOut()`](#signout)
|
|
20
21
|
* [Interfaces](#interfaces)
|
|
21
22
|
* [Enums](#enums)
|
|
@@ -68,6 +69,17 @@ federatedSignIn(options: { provider: CognitoHostedUIIdentityProvider; }) => Prom
|
|
|
68
69
|
--------------------
|
|
69
70
|
|
|
70
71
|
|
|
72
|
+
### fetchAuthSession()
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
fetchAuthSession() => Promise<CognitoAuthSession>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**Returns:** <code>Promise<<a href="#cognitoauthsession">CognitoAuthSession</a>></code>
|
|
79
|
+
|
|
80
|
+
--------------------
|
|
81
|
+
|
|
82
|
+
|
|
71
83
|
### signOut()
|
|
72
84
|
|
|
73
85
|
```typescript
|
|
@@ -96,18 +108,27 @@ signOut() => Promise<any>
|
|
|
96
108
|
|
|
97
109
|
#### CognitoAuthSession
|
|
98
110
|
|
|
99
|
-
| Prop | Type
|
|
100
|
-
| ------------------ |
|
|
101
|
-
| **`accessToken`** | <code>string</code>
|
|
102
|
-
| **`idToken`** | <code>string</code>
|
|
103
|
-
| **`identityId`** | <code>string</code>
|
|
104
|
-
| **`refreshToken`** | <code>string</code>
|
|
105
|
-
| **`deviceKey`** | <code>string \| null</code>
|
|
111
|
+
| Prop | Type |
|
|
112
|
+
| ------------------ | ----------------------------------------------------------------------------------------- |
|
|
113
|
+
| **`accessToken`** | <code>string</code> |
|
|
114
|
+
| **`idToken`** | <code>string</code> |
|
|
115
|
+
| **`identityId`** | <code>string</code> |
|
|
116
|
+
| **`refreshToken`** | <code>string</code> |
|
|
117
|
+
| **`deviceKey`** | <code>string \| null</code> |
|
|
118
|
+
| **`status`** | <code><a href="#awsamplifypluginresponsestatus">AwsAmplifyPluginResponseStatus</a></code> |
|
|
106
119
|
|
|
107
120
|
|
|
108
121
|
### Enums
|
|
109
122
|
|
|
110
123
|
|
|
124
|
+
#### AwsAmplifyPluginResponseStatus
|
|
125
|
+
|
|
126
|
+
| Members | Value |
|
|
127
|
+
| -------- | --------------- |
|
|
128
|
+
| **`Ok`** | <code>0</code> |
|
|
129
|
+
| **`Ko`** | <code>-1</code> |
|
|
130
|
+
|
|
131
|
+
|
|
111
132
|
#### CognitoHostedUIIdentityProvider
|
|
112
133
|
|
|
113
134
|
| Members | Value |
|
package/dist/docs.json
CHANGED
|
@@ -60,6 +60,18 @@
|
|
|
60
60
|
],
|
|
61
61
|
"slug": "federatedsignin"
|
|
62
62
|
},
|
|
63
|
+
{
|
|
64
|
+
"name": "fetchAuthSession",
|
|
65
|
+
"signature": "() => Promise<CognitoAuthSession>",
|
|
66
|
+
"parameters": [],
|
|
67
|
+
"returns": "Promise<CognitoAuthSession>",
|
|
68
|
+
"tags": [],
|
|
69
|
+
"docs": "",
|
|
70
|
+
"complexTypes": [
|
|
71
|
+
"CognitoAuthSession"
|
|
72
|
+
],
|
|
73
|
+
"slug": "fetchauthsession"
|
|
74
|
+
},
|
|
63
75
|
{
|
|
64
76
|
"name": "signOut",
|
|
65
77
|
"signature": "() => Promise<any>",
|
|
@@ -137,14 +149,14 @@
|
|
|
137
149
|
"tags": [],
|
|
138
150
|
"docs": "",
|
|
139
151
|
"complexTypes": [],
|
|
140
|
-
"type": "string"
|
|
152
|
+
"type": "string | undefined"
|
|
141
153
|
},
|
|
142
154
|
{
|
|
143
155
|
"name": "idToken",
|
|
144
156
|
"tags": [],
|
|
145
157
|
"docs": "",
|
|
146
158
|
"complexTypes": [],
|
|
147
|
-
"type": "string"
|
|
159
|
+
"type": "string | undefined"
|
|
148
160
|
},
|
|
149
161
|
{
|
|
150
162
|
"name": "identityId",
|
|
@@ -158,7 +170,7 @@
|
|
|
158
170
|
"tags": [],
|
|
159
171
|
"docs": "",
|
|
160
172
|
"complexTypes": [],
|
|
161
|
-
"type": "string"
|
|
173
|
+
"type": "string | undefined"
|
|
162
174
|
},
|
|
163
175
|
{
|
|
164
176
|
"name": "deviceKey",
|
|
@@ -166,11 +178,38 @@
|
|
|
166
178
|
"docs": "",
|
|
167
179
|
"complexTypes": [],
|
|
168
180
|
"type": "string | null"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"name": "status",
|
|
184
|
+
"tags": [],
|
|
185
|
+
"docs": "",
|
|
186
|
+
"complexTypes": [
|
|
187
|
+
"AwsAmplifyPluginResponseStatus"
|
|
188
|
+
],
|
|
189
|
+
"type": "AwsAmplifyPluginResponseStatus"
|
|
169
190
|
}
|
|
170
191
|
]
|
|
171
192
|
}
|
|
172
193
|
],
|
|
173
194
|
"enums": [
|
|
195
|
+
{
|
|
196
|
+
"name": "AwsAmplifyPluginResponseStatus",
|
|
197
|
+
"slug": "awsamplifypluginresponsestatus",
|
|
198
|
+
"members": [
|
|
199
|
+
{
|
|
200
|
+
"name": "Ok",
|
|
201
|
+
"value": "0",
|
|
202
|
+
"tags": [],
|
|
203
|
+
"docs": ""
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"name": "Ko",
|
|
207
|
+
"value": "-1",
|
|
208
|
+
"tags": [],
|
|
209
|
+
"docs": ""
|
|
210
|
+
}
|
|
211
|
+
]
|
|
212
|
+
},
|
|
174
213
|
{
|
|
175
214
|
"name": "CognitoHostedUIIdentityProvider",
|
|
176
215
|
"slug": "cognitohosteduiidentityprovider",
|
|
@@ -9,14 +9,16 @@ export interface AwsAmplifyPlugin {
|
|
|
9
9
|
federatedSignIn(options: {
|
|
10
10
|
provider: CognitoHostedUIIdentityProvider;
|
|
11
11
|
}): Promise<CognitoAuthSession>;
|
|
12
|
+
fetchAuthSession(): Promise<CognitoAuthSession>;
|
|
12
13
|
signOut(): Promise<any>;
|
|
13
14
|
}
|
|
14
15
|
export interface CognitoAuthSession {
|
|
15
|
-
accessToken
|
|
16
|
-
idToken
|
|
16
|
+
accessToken?: string;
|
|
17
|
+
idToken?: string;
|
|
17
18
|
identityId: string;
|
|
18
|
-
refreshToken
|
|
19
|
+
refreshToken?: string;
|
|
19
20
|
deviceKey: string | null;
|
|
21
|
+
status: AwsAmplifyPluginResponseStatus;
|
|
20
22
|
}
|
|
21
23
|
export interface AWSCognitoConfig {
|
|
22
24
|
aws_cognito_region: string;
|
|
@@ -32,6 +34,10 @@ export interface AWSCognitoConfig {
|
|
|
32
34
|
responseType: 'code';
|
|
33
35
|
};
|
|
34
36
|
}
|
|
37
|
+
export declare enum AwsAmplifyPluginResponseStatus {
|
|
38
|
+
Ok = 0,
|
|
39
|
+
Ko = -1
|
|
40
|
+
}
|
|
35
41
|
export declare enum CognitoHostedUIIdentityProvider {
|
|
36
42
|
Cognito = "COGNITO",
|
|
37
43
|
Google = "Google",
|
package/dist/esm/definitions.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
export var AwsAmplifyPluginResponseStatus;
|
|
2
|
+
(function (AwsAmplifyPluginResponseStatus) {
|
|
3
|
+
AwsAmplifyPluginResponseStatus[AwsAmplifyPluginResponseStatus["Ok"] = 0] = "Ok";
|
|
4
|
+
AwsAmplifyPluginResponseStatus[AwsAmplifyPluginResponseStatus["Ko"] = -1] = "Ko";
|
|
5
|
+
})(AwsAmplifyPluginResponseStatus || (AwsAmplifyPluginResponseStatus = {}));
|
|
1
6
|
export var CognitoHostedUIIdentityProvider;
|
|
2
7
|
(function (CognitoHostedUIIdentityProvider) {
|
|
3
8
|
CognitoHostedUIIdentityProvider["Cognito"] = "COGNITO";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAqCA,MAAM,CAAN,IAAY,8BAGX;AAHD,WAAY,8BAA8B;IACxC,+EAAM,CAAA;IACN,gFAAO,CAAA;AACT,CAAC,EAHW,8BAA8B,KAA9B,8BAA8B,QAGzC;AAED,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 fetchAuthSession(): 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 status: AwsAmplifyPluginResponseStatus\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\nexport enum AwsAmplifyPluginResponseStatus {\n Ok = 0,\n Ko = -1\n}\n\nexport enum CognitoHostedUIIdentityProvider {\n Cognito = \"COGNITO\",\n Google = \"Google\",\n Facebook = \"Facebook\",\n Amazon = \"LoginWithAmazon\",\n Apple = \"SignInWithApple\"\n}\n"]}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AwsAmplifyPlugin, AWSCognitoConfig, CognitoAuthSession } from './definitions';
|
|
3
3
|
export declare class AwsAmplifyWeb extends WebPlugin implements AwsAmplifyPlugin {
|
|
4
4
|
private cognitoConfig?;
|
|
5
5
|
load(options: {
|
|
@@ -12,6 +12,7 @@ export declare class AwsAmplifyWeb extends WebPlugin implements AwsAmplifyPlugin
|
|
|
12
12
|
federatedSignIn(options: {
|
|
13
13
|
provider: string;
|
|
14
14
|
}): Promise<CognitoAuthSession>;
|
|
15
|
+
fetchAuthSession(): Promise<CognitoAuthSession>;
|
|
15
16
|
signOut(): Promise<any>;
|
|
16
17
|
private getCognitoAuthSession;
|
|
17
18
|
}
|
package/dist/esm/web.js
CHANGED
|
@@ -1,60 +1,54 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
2
|
import { Amplify, Auth } from 'aws-amplify';
|
|
3
|
+
import { AwsAmplifyPluginResponseStatus } from './definitions';
|
|
3
4
|
export class AwsAmplifyWeb extends WebPlugin {
|
|
4
5
|
async load(options) {
|
|
5
6
|
this.cognitoConfig = options.cognitoConfig;
|
|
6
7
|
Amplify.configure(Object.assign({}, options.cognitoConfig));
|
|
7
8
|
}
|
|
8
9
|
async signIn(options) {
|
|
9
|
-
// console.log(LOG_PREFIX, options);
|
|
10
10
|
if (!this.cognitoConfig) {
|
|
11
11
|
throw new Error('call load first');
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const cognitoAuthSession = this.getCognitoAuthSession(user,
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
17
|
-
this.cognitoConfig.aws_cognito_identity_pool_id);
|
|
18
|
-
cognitoAuthSession ? resolve(cognitoAuthSession) : reject();
|
|
19
|
-
});
|
|
20
|
-
});
|
|
13
|
+
const user = (await Auth.signIn(options.email, options.password));
|
|
14
|
+
return this.getCognitoAuthSession(user, this.cognitoConfig.aws_cognito_identity_pool_id);
|
|
21
15
|
}
|
|
22
16
|
async federatedSignIn(options) {
|
|
23
17
|
// console.log(LOG_PREFIX, options);
|
|
24
18
|
if (!this.cognitoConfig) {
|
|
25
19
|
throw new Error('call load first');
|
|
26
20
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
})
|
|
39
|
-
.catch(err => reject(err));
|
|
40
|
-
});
|
|
21
|
+
await Auth.federatedSignIn(options);
|
|
22
|
+
return this.fetchAuthSession();
|
|
23
|
+
}
|
|
24
|
+
async fetchAuthSession() {
|
|
25
|
+
if (!this.cognitoConfig) {
|
|
26
|
+
throw new Error('call load first');
|
|
27
|
+
}
|
|
28
|
+
const user = await Auth.currentAuthenticatedUser();
|
|
29
|
+
// console.log(LOG_PREFIX + " user", user);
|
|
30
|
+
const cognitoAuthSession = this.getCognitoAuthSession(user, this.cognitoConfig.aws_cognito_identity_pool_id);
|
|
31
|
+
return cognitoAuthSession;
|
|
41
32
|
}
|
|
42
33
|
async signOut() {
|
|
34
|
+
if (!this.cognitoConfig) {
|
|
35
|
+
throw new Error('call load first');
|
|
36
|
+
}
|
|
43
37
|
return Auth.signOut();
|
|
44
38
|
}
|
|
45
39
|
getCognitoAuthSession(user, identityId) {
|
|
46
40
|
const userSession = user.getSignInUserSession();
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
return
|
|
41
|
+
const res = {
|
|
42
|
+
accessToken: userSession === null || userSession === void 0 ? void 0 : userSession.getAccessToken().getJwtToken(),
|
|
43
|
+
idToken: userSession === null || userSession === void 0 ? void 0 : userSession.getIdToken().getJwtToken(),
|
|
44
|
+
identityId: identityId,
|
|
45
|
+
refreshToken: userSession === null || userSession === void 0 ? void 0 : userSession.getRefreshToken().getToken(),
|
|
46
|
+
deviceKey: userSession === null || userSession === void 0 ? void 0 : userSession.getAccessToken().decodePayload().device_key,
|
|
47
|
+
status: userSession
|
|
48
|
+
? AwsAmplifyPluginResponseStatus.Ok
|
|
49
|
+
: AwsAmplifyPluginResponseStatus.Ko,
|
|
50
|
+
};
|
|
51
|
+
return res;
|
|
58
52
|
}
|
|
59
53
|
}
|
|
60
54
|
//# sourceMappingURL=web.js.map
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAO5C,OAAO,EAAE,8BAA8B,EAAE,MAAM,eAAe,CAAC;AAE/D,MAAM,OAAO,aAAc,SAAQ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AAK,CAAC,iBAAiB,CAAC,CAAC;SACpC;QACD,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IAEO,qBAAqB,CAAC,IAAiB,EAAE,UAAkB;QACjE,MAAM,WAAW,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAEhD,MAAM,GAAG,GAAuB;YAC9B,WAAW,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,GAAG,WAAW,EAAE;YACxD,OAAO,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,UAAU,GAAG,WAAW,EAAE;YAChD,UAAU,EAAE,UAAU;YACtB,YAAY,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,eAAe,GAAG,QAAQ,EAAE;YACvD,SAAS,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,GAAG,aAAa,GAAG,UAAU;YACnE,MAAM,EAAE,WAAW;gBACjB,CAAC,CAAC,8BAA8B,CAAC,EAAE;gBACnC,CAAC,CAAC,8BAA8B,CAAC,EAAE;SACtC,CAAC;QACF,OAAO,GAAG,CAAC;IACb,CAAC;CACF","sourcesContent":["import type { FederatedSignInOptions } from '@aws-amplify/auth/lib/types';\nimport { WebPlugin } from '@capacitor/core';\nimport type { CognitoUser } from 'amazon-cognito-identity-js';\nimport { Amplify, Auth } from 'aws-amplify';\n\nimport type {\n AwsAmplifyPlugin,\n AWSCognitoConfig,\n CognitoAuthSession,\n} from './definitions';\nimport { AwsAmplifyPluginResponseStatus } from './definitions';\n\nexport class AwsAmplifyWeb extends WebPlugin implements AwsAmplifyPlugin {\n private cognitoConfig?: AWSCognitoConfig;\n\n async load(options: { cognitoConfig: AWSCognitoConfig }): Promise<void> {\n this.cognitoConfig = options.cognitoConfig;\n Amplify.configure({ ...options.cognitoConfig });\n }\n async signIn(options: {\n email: string;\n password: string;\n }): Promise<CognitoAuthSession> {\n if (!this.cognitoConfig) {\n throw new Error('call load first');\n }\n\n const user = (await Auth.signIn(\n options.email,\n options.password,\n )) as CognitoUser;\n\n return this.getCognitoAuthSession(\n user,\n this.cognitoConfig.aws_cognito_identity_pool_id,\n );\n }\n\n async federatedSignIn(options: {\n provider: string;\n }): Promise<CognitoAuthSession> {\n // console.log(LOG_PREFIX, options);\n if (!this.cognitoConfig) {\n throw new Error('call load first');\n }\n await Auth.federatedSignIn(options as FederatedSignInOptions);\n return this.fetchAuthSession();\n }\n\n async fetchAuthSession(): Promise<CognitoAuthSession> {\n if (!this.cognitoConfig) {\n throw new Error('call load first');\n }\n const user = await Auth.currentAuthenticatedUser();\n // console.log(LOG_PREFIX + \" user\", user);\n const cognitoAuthSession: CognitoAuthSession = this.getCognitoAuthSession(\n user,\n this.cognitoConfig.aws_cognito_identity_pool_id,\n );\n\n return cognitoAuthSession;\n }\n\n async signOut(): Promise<any> {\n if (!this.cognitoConfig) {\n throw new Error('call load first');\n }\n return Auth.signOut();\n }\n\n private getCognitoAuthSession(user: CognitoUser, identityId: string) {\n const userSession = user.getSignInUserSession();\n\n const res: CognitoAuthSession = {\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 status: userSession\n ? AwsAmplifyPluginResponseStatus.Ok\n : AwsAmplifyPluginResponseStatus.Ko,\n };\n return res;\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -5,6 +5,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var core = require('@capacitor/core');
|
|
6
6
|
var awsAmplify = require('aws-amplify');
|
|
7
7
|
|
|
8
|
+
exports.AwsAmplifyPluginResponseStatus = void 0;
|
|
9
|
+
(function (AwsAmplifyPluginResponseStatus) {
|
|
10
|
+
AwsAmplifyPluginResponseStatus[AwsAmplifyPluginResponseStatus["Ok"] = 0] = "Ok";
|
|
11
|
+
AwsAmplifyPluginResponseStatus[AwsAmplifyPluginResponseStatus["Ko"] = -1] = "Ko";
|
|
12
|
+
})(exports.AwsAmplifyPluginResponseStatus || (exports.AwsAmplifyPluginResponseStatus = {}));
|
|
8
13
|
exports.CognitoHostedUIIdentityProvider = void 0;
|
|
9
14
|
(function (CognitoHostedUIIdentityProvider) {
|
|
10
15
|
CognitoHostedUIIdentityProvider["Cognito"] = "COGNITO";
|
|
@@ -24,55 +29,48 @@ class AwsAmplifyWeb extends core.WebPlugin {
|
|
|
24
29
|
awsAmplify.Amplify.configure(Object.assign({}, options.cognitoConfig));
|
|
25
30
|
}
|
|
26
31
|
async signIn(options) {
|
|
27
|
-
// console.log(LOG_PREFIX, options);
|
|
28
32
|
if (!this.cognitoConfig) {
|
|
29
33
|
throw new Error('call load first');
|
|
30
34
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const cognitoAuthSession = this.getCognitoAuthSession(user,
|
|
34
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
35
|
-
this.cognitoConfig.aws_cognito_identity_pool_id);
|
|
36
|
-
cognitoAuthSession ? resolve(cognitoAuthSession) : reject();
|
|
37
|
-
});
|
|
38
|
-
});
|
|
35
|
+
const user = (await awsAmplify.Auth.signIn(options.email, options.password));
|
|
36
|
+
return this.getCognitoAuthSession(user, this.cognitoConfig.aws_cognito_identity_pool_id);
|
|
39
37
|
}
|
|
40
38
|
async federatedSignIn(options) {
|
|
41
39
|
// console.log(LOG_PREFIX, options);
|
|
42
40
|
if (!this.cognitoConfig) {
|
|
43
41
|
throw new Error('call load first');
|
|
44
42
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
})
|
|
57
|
-
.catch(err => reject(err));
|
|
58
|
-
});
|
|
43
|
+
await awsAmplify.Auth.federatedSignIn(options);
|
|
44
|
+
return this.fetchAuthSession();
|
|
45
|
+
}
|
|
46
|
+
async fetchAuthSession() {
|
|
47
|
+
if (!this.cognitoConfig) {
|
|
48
|
+
throw new Error('call load first');
|
|
49
|
+
}
|
|
50
|
+
const user = await awsAmplify.Auth.currentAuthenticatedUser();
|
|
51
|
+
// console.log(LOG_PREFIX + " user", user);
|
|
52
|
+
const cognitoAuthSession = this.getCognitoAuthSession(user, this.cognitoConfig.aws_cognito_identity_pool_id);
|
|
53
|
+
return cognitoAuthSession;
|
|
59
54
|
}
|
|
60
55
|
async signOut() {
|
|
56
|
+
if (!this.cognitoConfig) {
|
|
57
|
+
throw new Error('call load first');
|
|
58
|
+
}
|
|
61
59
|
return awsAmplify.Auth.signOut();
|
|
62
60
|
}
|
|
63
61
|
getCognitoAuthSession(user, identityId) {
|
|
64
62
|
const userSession = user.getSignInUserSession();
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
return
|
|
63
|
+
const res = {
|
|
64
|
+
accessToken: userSession === null || userSession === void 0 ? void 0 : userSession.getAccessToken().getJwtToken(),
|
|
65
|
+
idToken: userSession === null || userSession === void 0 ? void 0 : userSession.getIdToken().getJwtToken(),
|
|
66
|
+
identityId: identityId,
|
|
67
|
+
refreshToken: userSession === null || userSession === void 0 ? void 0 : userSession.getRefreshToken().getToken(),
|
|
68
|
+
deviceKey: userSession === null || userSession === void 0 ? void 0 : userSession.getAccessToken().decodePayload().device_key,
|
|
69
|
+
status: userSession
|
|
70
|
+
? exports.AwsAmplifyPluginResponseStatus.Ok
|
|
71
|
+
: exports.AwsAmplifyPluginResponseStatus.Ko,
|
|
72
|
+
};
|
|
73
|
+
return res;
|
|
76
74
|
}
|
|
77
75
|
}
|
|
78
76
|
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var AwsAmplifyPluginResponseStatus;\n(function (AwsAmplifyPluginResponseStatus) {\n AwsAmplifyPluginResponseStatus[AwsAmplifyPluginResponseStatus[\"Ok\"] = 0] = \"Ok\";\n AwsAmplifyPluginResponseStatus[AwsAmplifyPluginResponseStatus[\"Ko\"] = -1] = \"Ko\";\n})(AwsAmplifyPluginResponseStatus || (AwsAmplifyPluginResponseStatus = {}));\nexport 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';\nimport { AwsAmplifyPluginResponseStatus } from './definitions';\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 if (!this.cognitoConfig) {\n throw new Error('call load first');\n }\n const user = (await Auth.signIn(options.email, options.password));\n return this.getCognitoAuthSession(user, this.cognitoConfig.aws_cognito_identity_pool_id);\n }\n async federatedSignIn(options) {\n // console.log(LOG_PREFIX, options);\n if (!this.cognitoConfig) {\n throw new Error('call load first');\n }\n await Auth.federatedSignIn(options);\n return this.fetchAuthSession();\n }\n async fetchAuthSession() {\n if (!this.cognitoConfig) {\n throw new Error('call load first');\n }\n const user = await Auth.currentAuthenticatedUser();\n // console.log(LOG_PREFIX + \" user\", user);\n const cognitoAuthSession = this.getCognitoAuthSession(user, this.cognitoConfig.aws_cognito_identity_pool_id);\n return cognitoAuthSession;\n }\n async signOut() {\n if (!this.cognitoConfig) {\n throw new Error('call load first');\n }\n return Auth.signOut();\n }\n getCognitoAuthSession(user, identityId) {\n const userSession = user.getSignInUserSession();\n const res = {\n accessToken: userSession === null || userSession === void 0 ? void 0 : userSession.getAccessToken().getJwtToken(),\n idToken: userSession === null || userSession === void 0 ? void 0 : userSession.getIdToken().getJwtToken(),\n identityId: identityId,\n refreshToken: userSession === null || userSession === void 0 ? void 0 : userSession.getRefreshToken().getToken(),\n deviceKey: userSession === null || userSession === void 0 ? void 0 : userSession.getAccessToken().decodePayload().device_key,\n status: userSession\n ? AwsAmplifyPluginResponseStatus.Ok\n : AwsAmplifyPluginResponseStatus.Ko,\n };\n return res;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["AwsAmplifyPluginResponseStatus","CognitoHostedUIIdentityProvider","registerPlugin","WebPlugin","Amplify","Auth"],"mappings":";;;;;;;AAAWA,gDAA+B;AAC1C,CAAC,UAAU,8BAA8B,EAAE;AAC3C,IAAI,8BAA8B,CAAC,8BAA8B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;AACpF,IAAI,8BAA8B,CAAC,8BAA8B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;AACrF,CAAC,EAAEA,sCAA8B,KAAKA,sCAA8B,GAAG,EAAE,CAAC,CAAC,CAAC;AACjEC,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,GAAG,UAAU,CAAC;AAC7D,IAAI,+BAA+B,CAAC,QAAQ,CAAC,GAAG,iBAAiB,CAAC;AAClE,IAAI,+BAA+B,CAAC,OAAO,CAAC,GAAG,iBAAiB,CAAC;AACjE,CAAC,EAAEA,uCAA+B,KAAKA,uCAA+B,GAAG,EAAE,CAAC,CAAC;;ACXxE,MAAC,UAAU,GAAGC,mBAAc,CAAC,YAAY,EAAE;AAChD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;AAC/D,CAAC;;ACAM,MAAM,aAAa,SAASC,cAAS,CAAC;AAC7C,IAAI,MAA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1,11 @@
|
|
|
1
1
|
var capacitorAwsAmplify = (function (exports, core, awsAmplify) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
exports.AwsAmplifyPluginResponseStatus = void 0;
|
|
5
|
+
(function (AwsAmplifyPluginResponseStatus) {
|
|
6
|
+
AwsAmplifyPluginResponseStatus[AwsAmplifyPluginResponseStatus["Ok"] = 0] = "Ok";
|
|
7
|
+
AwsAmplifyPluginResponseStatus[AwsAmplifyPluginResponseStatus["Ko"] = -1] = "Ko";
|
|
8
|
+
})(exports.AwsAmplifyPluginResponseStatus || (exports.AwsAmplifyPluginResponseStatus = {}));
|
|
4
9
|
exports.CognitoHostedUIIdentityProvider = void 0;
|
|
5
10
|
(function (CognitoHostedUIIdentityProvider) {
|
|
6
11
|
CognitoHostedUIIdentityProvider["Cognito"] = "COGNITO";
|
|
@@ -20,55 +25,48 @@ var capacitorAwsAmplify = (function (exports, core, awsAmplify) {
|
|
|
20
25
|
awsAmplify.Amplify.configure(Object.assign({}, options.cognitoConfig));
|
|
21
26
|
}
|
|
22
27
|
async signIn(options) {
|
|
23
|
-
// console.log(LOG_PREFIX, options);
|
|
24
28
|
if (!this.cognitoConfig) {
|
|
25
29
|
throw new Error('call load first');
|
|
26
30
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const cognitoAuthSession = this.getCognitoAuthSession(user,
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
31
|
-
this.cognitoConfig.aws_cognito_identity_pool_id);
|
|
32
|
-
cognitoAuthSession ? resolve(cognitoAuthSession) : reject();
|
|
33
|
-
});
|
|
34
|
-
});
|
|
31
|
+
const user = (await awsAmplify.Auth.signIn(options.email, options.password));
|
|
32
|
+
return this.getCognitoAuthSession(user, this.cognitoConfig.aws_cognito_identity_pool_id);
|
|
35
33
|
}
|
|
36
34
|
async federatedSignIn(options) {
|
|
37
35
|
// console.log(LOG_PREFIX, options);
|
|
38
36
|
if (!this.cognitoConfig) {
|
|
39
37
|
throw new Error('call load first');
|
|
40
38
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
})
|
|
53
|
-
.catch(err => reject(err));
|
|
54
|
-
});
|
|
39
|
+
await awsAmplify.Auth.federatedSignIn(options);
|
|
40
|
+
return this.fetchAuthSession();
|
|
41
|
+
}
|
|
42
|
+
async fetchAuthSession() {
|
|
43
|
+
if (!this.cognitoConfig) {
|
|
44
|
+
throw new Error('call load first');
|
|
45
|
+
}
|
|
46
|
+
const user = await awsAmplify.Auth.currentAuthenticatedUser();
|
|
47
|
+
// console.log(LOG_PREFIX + " user", user);
|
|
48
|
+
const cognitoAuthSession = this.getCognitoAuthSession(user, this.cognitoConfig.aws_cognito_identity_pool_id);
|
|
49
|
+
return cognitoAuthSession;
|
|
55
50
|
}
|
|
56
51
|
async signOut() {
|
|
52
|
+
if (!this.cognitoConfig) {
|
|
53
|
+
throw new Error('call load first');
|
|
54
|
+
}
|
|
57
55
|
return awsAmplify.Auth.signOut();
|
|
58
56
|
}
|
|
59
57
|
getCognitoAuthSession(user, identityId) {
|
|
60
58
|
const userSession = user.getSignInUserSession();
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
return
|
|
59
|
+
const res = {
|
|
60
|
+
accessToken: userSession === null || userSession === void 0 ? void 0 : userSession.getAccessToken().getJwtToken(),
|
|
61
|
+
idToken: userSession === null || userSession === void 0 ? void 0 : userSession.getIdToken().getJwtToken(),
|
|
62
|
+
identityId: identityId,
|
|
63
|
+
refreshToken: userSession === null || userSession === void 0 ? void 0 : userSession.getRefreshToken().getToken(),
|
|
64
|
+
deviceKey: userSession === null || userSession === void 0 ? void 0 : userSession.getAccessToken().decodePayload().device_key,
|
|
65
|
+
status: userSession
|
|
66
|
+
? exports.AwsAmplifyPluginResponseStatus.Ok
|
|
67
|
+
: exports.AwsAmplifyPluginResponseStatus.Ko,
|
|
68
|
+
};
|
|
69
|
+
return res;
|
|
72
70
|
}
|
|
73
71
|
}
|
|
74
72
|
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var AwsAmplifyPluginResponseStatus;\n(function (AwsAmplifyPluginResponseStatus) {\n AwsAmplifyPluginResponseStatus[AwsAmplifyPluginResponseStatus[\"Ok\"] = 0] = \"Ok\";\n AwsAmplifyPluginResponseStatus[AwsAmplifyPluginResponseStatus[\"Ko\"] = -1] = \"Ko\";\n})(AwsAmplifyPluginResponseStatus || (AwsAmplifyPluginResponseStatus = {}));\nexport 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';\nimport { AwsAmplifyPluginResponseStatus } from './definitions';\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 if (!this.cognitoConfig) {\n throw new Error('call load first');\n }\n const user = (await Auth.signIn(options.email, options.password));\n return this.getCognitoAuthSession(user, this.cognitoConfig.aws_cognito_identity_pool_id);\n }\n async federatedSignIn(options) {\n // console.log(LOG_PREFIX, options);\n if (!this.cognitoConfig) {\n throw new Error('call load first');\n }\n await Auth.federatedSignIn(options);\n return this.fetchAuthSession();\n }\n async fetchAuthSession() {\n if (!this.cognitoConfig) {\n throw new Error('call load first');\n }\n const user = await Auth.currentAuthenticatedUser();\n // console.log(LOG_PREFIX + \" user\", user);\n const cognitoAuthSession = this.getCognitoAuthSession(user, this.cognitoConfig.aws_cognito_identity_pool_id);\n return cognitoAuthSession;\n }\n async signOut() {\n if (!this.cognitoConfig) {\n throw new Error('call load first');\n }\n return Auth.signOut();\n }\n getCognitoAuthSession(user, identityId) {\n const userSession = user.getSignInUserSession();\n const res = {\n accessToken: userSession === null || userSession === void 0 ? void 0 : userSession.getAccessToken().getJwtToken(),\n idToken: userSession === null || userSession === void 0 ? void 0 : userSession.getIdToken().getJwtToken(),\n identityId: identityId,\n refreshToken: userSession === null || userSession === void 0 ? void 0 : userSession.getRefreshToken().getToken(),\n deviceKey: userSession === null || userSession === void 0 ? void 0 : userSession.getAccessToken().decodePayload().device_key,\n status: userSession\n ? AwsAmplifyPluginResponseStatus.Ok\n : AwsAmplifyPluginResponseStatus.Ko,\n };\n return res;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["AwsAmplifyPluginResponseStatus","CognitoHostedUIIdentityProvider","registerPlugin","WebPlugin","Amplify","Auth"],"mappings":";;;AAAWA,oDAA+B;IAC1C,CAAC,UAAU,8BAA8B,EAAE;IAC3C,IAAI,8BAA8B,CAAC,8BAA8B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;IACpF,IAAI,8BAA8B,CAAC,8BAA8B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACrF,CAAC,EAAEA,sCAA8B,KAAKA,sCAA8B,GAAG,EAAE,CAAC,CAAC,CAAC;AACjEC,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,u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,EAAE,CAAC,aAAa,EAAE,CAAC,UAAU;IACxI,YAAY,MAAM,EAAE,WAAW;IAC/B,kBAAkBL,sCAA8B,CAAC,EAAE;IACnD,kBAAkBA,sCAA8B,CAAC,EAAE;IACnD,SAAS,CAAC;IACV,QAAQ,OAAO,GAAG,CAAC;IACnB,KAAK;IACL;;;;;;;;;;;;;;;;;"}
|
|
@@ -8,4 +8,5 @@ CAP_PLUGIN(AwsAmplifyPlugin, "AwsAmplify",
|
|
|
8
8
|
CAP_PLUGIN_METHOD(signIn, CAPPluginReturnPromise);
|
|
9
9
|
CAP_PLUGIN_METHOD(signOut, CAPPluginReturnPromise);
|
|
10
10
|
CAP_PLUGIN_METHOD(federatedSignIn, CAPPluginReturnPromise);
|
|
11
|
+
CAP_PLUGIN_METHOD(fetchAuthSession, CAPPluginReturnPromise);
|
|
11
12
|
)
|
|
@@ -76,6 +76,16 @@ public class AwsAmplifyPlugin: CAPPlugin {
|
|
|
76
76
|
call.reject(error.localizedDescription)
|
|
77
77
|
})
|
|
78
78
|
}
|
|
79
|
+
@objc func fetchAuthSession(_ call: CAPPluginCall) {
|
|
80
|
+
|
|
81
|
+
self.implementation.fetchAuthSession(
|
|
82
|
+
onSuccess: {session in
|
|
83
|
+
call.resolve(session)
|
|
84
|
+
},
|
|
85
|
+
onError: {error in
|
|
86
|
+
call.reject(error.localizedDescription)
|
|
87
|
+
})
|
|
88
|
+
}
|
|
79
89
|
|
|
80
90
|
// var permissionCallID: String?
|
|
81
91
|
// var locationManager: CLLocationManager?
|