@falconeta/capacitor-aws-amplify 0.0.3 → 0.0.4
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 +26 -0
- package/dist/docs.json +69 -0
- package/dist/esm/definitions.d.ts +17 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +4 -1
- package/dist/esm/web.js +4 -1
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +3 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +3 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/AwsAmplify.swift +61 -18
- package/ios/Plugin/AwsAmplifyPlugin.m +1 -0
- package/ios/Plugin/AwsAmplifyPlugin.swift +27 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ npx cap sync
|
|
|
13
13
|
|
|
14
14
|
<docgen-index>
|
|
15
15
|
|
|
16
|
+
* [`load(...)`](#load)
|
|
16
17
|
* [`signIn(...)`](#signin)
|
|
17
18
|
* [`federatedSignIn(...)`](#federatedsignin)
|
|
18
19
|
* [`signOut()`](#signout)
|
|
@@ -23,6 +24,19 @@ npx cap sync
|
|
|
23
24
|
<docgen-api>
|
|
24
25
|
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
25
26
|
|
|
27
|
+
### load(...)
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
load(options: { cognitoConfig: AWSCognitoConfig; }) => Promise<void>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
| Param | Type |
|
|
34
|
+
| ------------- | --------------------------------------------------------------------------------- |
|
|
35
|
+
| **`options`** | <code>{ cognitoConfig: <a href="#awscognitoconfig">AWSCognitoConfig</a>; }</code> |
|
|
36
|
+
|
|
37
|
+
--------------------
|
|
38
|
+
|
|
39
|
+
|
|
26
40
|
### signIn(...)
|
|
27
41
|
|
|
28
42
|
```typescript
|
|
@@ -67,6 +81,18 @@ signOut() => Promise<any>
|
|
|
67
81
|
### Interfaces
|
|
68
82
|
|
|
69
83
|
|
|
84
|
+
#### AWSCognitoConfig
|
|
85
|
+
|
|
86
|
+
| Prop | Type |
|
|
87
|
+
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
88
|
+
| **`aws_cognito_region`** | <code>string</code> |
|
|
89
|
+
| **`aws_user_pools_id`** | <code>string</code> |
|
|
90
|
+
| **`aws_user_pools_web_client_id`** | <code>string</code> |
|
|
91
|
+
| **`aws_cognito_identity_pool_id`** | <code>string</code> |
|
|
92
|
+
| **`aws_mandatory_sign_in`** | <code>string</code> |
|
|
93
|
+
| **`oauth`** | <code>{ domain: string; scope: string[]; redirectSignIn: string; redirectSignOut: string; responseType: 'code'; }</code> |
|
|
94
|
+
|
|
95
|
+
|
|
70
96
|
#### CognitoAuthSession
|
|
71
97
|
|
|
72
98
|
| Prop | Type |
|
package/dist/docs.json
CHANGED
|
@@ -5,6 +5,24 @@
|
|
|
5
5
|
"docs": "",
|
|
6
6
|
"tags": [],
|
|
7
7
|
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "load",
|
|
10
|
+
"signature": "(options: { cognitoConfig: AWSCognitoConfig; }) => Promise<void>",
|
|
11
|
+
"parameters": [
|
|
12
|
+
{
|
|
13
|
+
"name": "options",
|
|
14
|
+
"docs": "",
|
|
15
|
+
"type": "{ cognitoConfig: AWSCognitoConfig; }"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"returns": "Promise<void>",
|
|
19
|
+
"tags": [],
|
|
20
|
+
"docs": "",
|
|
21
|
+
"complexTypes": [
|
|
22
|
+
"AWSCognitoConfig"
|
|
23
|
+
],
|
|
24
|
+
"slug": "load"
|
|
25
|
+
},
|
|
8
26
|
{
|
|
9
27
|
"name": "signIn",
|
|
10
28
|
"signature": "(options: { email: string; password: string; identityId: string; }) => Promise<CognitoAuthSession>",
|
|
@@ -55,6 +73,57 @@
|
|
|
55
73
|
"properties": []
|
|
56
74
|
},
|
|
57
75
|
"interfaces": [
|
|
76
|
+
{
|
|
77
|
+
"name": "AWSCognitoConfig",
|
|
78
|
+
"slug": "awscognitoconfig",
|
|
79
|
+
"docs": "",
|
|
80
|
+
"tags": [],
|
|
81
|
+
"methods": [],
|
|
82
|
+
"properties": [
|
|
83
|
+
{
|
|
84
|
+
"name": "aws_cognito_region",
|
|
85
|
+
"tags": [],
|
|
86
|
+
"docs": "",
|
|
87
|
+
"complexTypes": [],
|
|
88
|
+
"type": "string"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"name": "aws_user_pools_id",
|
|
92
|
+
"tags": [],
|
|
93
|
+
"docs": "",
|
|
94
|
+
"complexTypes": [],
|
|
95
|
+
"type": "string"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"name": "aws_user_pools_web_client_id",
|
|
99
|
+
"tags": [],
|
|
100
|
+
"docs": "",
|
|
101
|
+
"complexTypes": [],
|
|
102
|
+
"type": "string"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"name": "aws_cognito_identity_pool_id",
|
|
106
|
+
"tags": [],
|
|
107
|
+
"docs": "",
|
|
108
|
+
"complexTypes": [],
|
|
109
|
+
"type": "string"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"name": "aws_mandatory_sign_in",
|
|
113
|
+
"tags": [],
|
|
114
|
+
"docs": "",
|
|
115
|
+
"complexTypes": [],
|
|
116
|
+
"type": "string"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"name": "oauth",
|
|
120
|
+
"tags": [],
|
|
121
|
+
"docs": "",
|
|
122
|
+
"complexTypes": [],
|
|
123
|
+
"type": "{ domain: string; scope: string[]; redirectSignIn: string; redirectSignOut: string; responseType: 'code'; }"
|
|
124
|
+
}
|
|
125
|
+
]
|
|
126
|
+
},
|
|
58
127
|
{
|
|
59
128
|
"name": "CognitoAuthSession",
|
|
60
129
|
"slug": "cognitoauthsession",
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export interface AwsAmplifyPlugin {
|
|
2
|
+
load(options: {
|
|
3
|
+
cognitoConfig: AWSCognitoConfig;
|
|
4
|
+
}): Promise<void>;
|
|
2
5
|
signIn(options: {
|
|
3
6
|
email: string;
|
|
4
7
|
password: string;
|
|
@@ -17,3 +20,17 @@ export interface CognitoAuthSession {
|
|
|
17
20
|
refreshToken: string;
|
|
18
21
|
deviceKey: string | null;
|
|
19
22
|
}
|
|
23
|
+
export interface AWSCognitoConfig {
|
|
24
|
+
aws_cognito_region: string;
|
|
25
|
+
aws_user_pools_id: string;
|
|
26
|
+
aws_user_pools_web_client_id: string;
|
|
27
|
+
aws_cognito_identity_pool_id: string;
|
|
28
|
+
aws_mandatory_sign_in: string;
|
|
29
|
+
oauth: {
|
|
30
|
+
domain: string;
|
|
31
|
+
scope: string[];
|
|
32
|
+
redirectSignIn: string;
|
|
33
|
+
redirectSignOut: string;
|
|
34
|
+
responseType: 'code';
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface AwsAmplifyPlugin {\n signIn(options: {\n email: string;\n password: string;\n identityId: string;\n }): Promise<CognitoAuthSession>;\n federatedSignIn(options: {\n provider: string;\n identityId: 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"]}
|
|
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 identityId: string;\n }): Promise<CognitoAuthSession>;\n federatedSignIn(options: {\n provider: string;\n identityId: 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"]}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
|
-
import type { AwsAmplifyPlugin, CognitoAuthSession } from './definitions';
|
|
2
|
+
import type { AWSCognitoConfig, AwsAmplifyPlugin, CognitoAuthSession } from './definitions';
|
|
3
3
|
export declare class AwsAmplifyWeb extends WebPlugin implements AwsAmplifyPlugin {
|
|
4
|
+
load(options: {
|
|
5
|
+
cognitoConfig: AWSCognitoConfig;
|
|
6
|
+
}): Promise<void>;
|
|
4
7
|
signIn(options: {
|
|
5
8
|
email: string;
|
|
6
9
|
password: string;
|
package/dist/esm/web.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
|
-
import { Auth } from 'aws-amplify';
|
|
2
|
+
import { Amplify, Auth } from 'aws-amplify';
|
|
3
3
|
export class AwsAmplifyWeb extends WebPlugin {
|
|
4
|
+
async load(options) {
|
|
5
|
+
Amplify.configure(Object.assign({}, options.cognitoConfig));
|
|
6
|
+
}
|
|
4
7
|
async signIn(options) {
|
|
5
8
|
// console.log(LOG_PREFIX, options);
|
|
6
9
|
return new Promise((resolve, reject) => {
|
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,i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ACnD,IAAI,EACJ,OAAO,CAAC,UAAU,CACnB,CAAC;oBACF,kBAAkB,CAAC,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC9D,CAAC,CAAC,CAAC;YACL,CAAC,CAAC;iBACD,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,OAAO;QACX,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IAEO,qBAAqB,CAAC,IAAiB,EAAE,UAAkB;QACjE,MAAM,WAAW,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAEhD,IAAI,WAAW,EAAE;YACf,MAAM,GAAG,GAAuB;gBAC9B,WAAW,EAAE,WAAW,CAAC,cAAc,EAAE,CAAC,WAAW,EAAE;gBACvD,OAAO,EAAE,WAAW,CAAC,UAAU,EAAE,CAAC,WAAW,EAAE;gBAC/C,UAAU,EAAE,UAAU;gBACtB,YAAY,EAAE,WAAW,CAAC,eAAe,EAAE,CAAC,QAAQ,EAAE;gBACtD,SAAS,EAAE,WAAW,CAAC,cAAc,EAAE,CAAC,aAAa,EAAE,CAAC,UAAU;aACnE,CAAC;YACF,OAAO,GAAG,CAAC;SACZ;QAED,OAAO,IAAI,CAAC;IACd,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 AWSCognitoConfig,\n AwsAmplifyPlugin,\n CognitoAuthSession,\n} from './definitions';\n\nexport class AwsAmplifyWeb extends WebPlugin implements AwsAmplifyPlugin {\n async load(options: { cognitoConfig: AWSCognitoConfig }): Promise<void> {\n Amplify.configure({ ...options.cognitoConfig });\n }\n async signIn(options: {\n email: string;\n password: string;\n identityId: string;\n }): Promise<CognitoAuthSession> {\n // console.log(LOG_PREFIX, options);\n return new Promise((resolve, reject) => {\n Auth.signIn(options.email, options.password).then((user: CognitoUser) => {\n const cognitoAuthSession = this.getCognitoAuthSession(\n user,\n options.identityId,\n );\n cognitoAuthSession ? resolve(cognitoAuthSession) : reject();\n });\n });\n }\n\n async federatedSignIn(options: {\n provider: string;\n identityId: string;\n }): Promise<CognitoAuthSession> {\n // console.log(LOG_PREFIX, options);\n return new Promise((resolve, reject) => {\n Auth.federatedSignIn(options as FederatedSignInOptions)\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(\n user,\n options.identityId,\n );\n cognitoAuthSession ? resolve(cognitoAuthSession) : reject();\n });\n })\n .catch(err => reject(err));\n });\n }\n\n async signOut(): Promise<any> {\n return Auth.signOut();\n }\n\n private getCognitoAuthSession(user: CognitoUser, identityId: string) {\n const userSession = user.getSignInUserSession();\n\n if (userSession) {\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 };\n return res;\n }\n\n return null;\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -10,6 +10,9 @@ const AwsAmplify = core.registerPlugin('AwsAmplify', {
|
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
class AwsAmplifyWeb extends core.WebPlugin {
|
|
13
|
+
async load(options) {
|
|
14
|
+
awsAmplify.Amplify.configure(Object.assign({}, options.cognitoConfig));
|
|
15
|
+
}
|
|
13
16
|
async signIn(options) {
|
|
14
17
|
// console.log(LOG_PREFIX, options);
|
|
15
18
|
return new Promise((resolve, reject) => {
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -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 { Auth } from 'aws-amplify';\nexport class AwsAmplifyWeb extends WebPlugin {\n async signIn(options) {\n // console.log(LOG_PREFIX, options);\n return new Promise((resolve, reject) => {\n Auth.signIn(options.email, options.password).then((user) => {\n const cognitoAuthSession = this.getCognitoAuthSession(user, options.identityId);\n cognitoAuthSession ? resolve(cognitoAuthSession) : reject();\n });\n });\n }\n async federatedSignIn(options) {\n // console.log(LOG_PREFIX, options);\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, options.identityId);\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","Auth"],"mappings":";;;;;;;AACK,MAAC,UAAU,GAAGA,mBAAc,CAAC,YAAY,EAAE;AAChD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,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,OAAO,EAAE,CAAC;AAC9B,KAAK;AACL,IAAI,qBAAqB,CAAC,IAAI,EAAE,UAAU,EAAE;AAC5C,QAAQ,MAAM,WAAW,GAAG,IAAI,CAAC,oBAAoB,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/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 Amplify.configure(Object.assign({}, options.cognitoConfig));\n }\n async signIn(options) {\n // console.log(LOG_PREFIX, options);\n return new Promise((resolve, reject) => {\n Auth.signIn(options.email, options.password).then((user) => {\n const cognitoAuthSession = this.getCognitoAuthSession(user, options.identityId);\n cognitoAuthSession ? resolve(cognitoAuthSession) : reject();\n });\n });\n }\n async federatedSignIn(options) {\n // console.log(LOG_PREFIX, options);\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, options.identityId);\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,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,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;AACxE,gBAAgB,MAAM,kBAAkB,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,EAAE,OA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,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
|
@@ -6,6 +6,9 @@ var capacitorAwsAmplify = (function (exports, core, awsAmplify) {
|
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
class AwsAmplifyWeb extends core.WebPlugin {
|
|
9
|
+
async load(options) {
|
|
10
|
+
awsAmplify.Amplify.configure(Object.assign({}, options.cognitoConfig));
|
|
11
|
+
}
|
|
9
12
|
async signIn(options) {
|
|
10
13
|
// console.log(LOG_PREFIX, options);
|
|
11
14
|
return new Promise((resolve, reject) => {
|
package/dist/plugin.js.map
CHANGED
|
@@ -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 { Auth } from 'aws-amplify';\nexport class AwsAmplifyWeb extends WebPlugin {\n async signIn(options) {\n // console.log(LOG_PREFIX, options);\n return new Promise((resolve, reject) => {\n Auth.signIn(options.email, options.password).then((user) => {\n const cognitoAuthSession = this.getCognitoAuthSession(user, options.identityId);\n cognitoAuthSession ? resolve(cognitoAuthSession) : reject();\n });\n });\n }\n async federatedSignIn(options) {\n // console.log(LOG_PREFIX, options);\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, options.identityId);\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","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,MAAM,CAAC,OAAO,EAAE;IAC1B;IACA,QAAQ,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;IAChD,YAAYC,eAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK;IACxE,gBAAgB,MAAM,kBAAkB,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAChG,gBAAgB,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,GAAG,MAAM,EAAE,CAAC;IAC5E,aAAa,CAAC,CAAC;IACf,SAAS,CAAC,CAAC;IACX,KAAK;IACL,IAAI,MAAM,eAAe,CAAC,OAAO,EAAE;IACnC;IACA,QAAQ,OAAO,IAAI,OAAO,CA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;IACL;;;;;;;;;;;;;;;;;"}
|
|
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 Amplify.configure(Object.assign({}, options.cognitoConfig));\n }\n async signIn(options) {\n // console.log(LOG_PREFIX, options);\n return new Promise((resolve, reject) => {\n Auth.signIn(options.email, options.password).then((user) => {\n const cognitoAuthSession = this.getCognitoAuthSession(user, options.identityId);\n cognitoAuthSession ? resolve(cognitoAuthSession) : reject();\n });\n });\n }\n async federatedSignIn(options) {\n // console.log(LOG_PREFIX, options);\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, options.identityId);\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,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AAC;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,4 +1,5 @@
|
|
|
1
1
|
import Foundation
|
|
2
|
+
import Capacitor
|
|
2
3
|
import Amplify
|
|
3
4
|
import AmplifyPlugins
|
|
4
5
|
import AWSPluginsCore
|
|
@@ -6,14 +7,14 @@ import AWSMobileClient
|
|
|
6
7
|
|
|
7
8
|
@objc public class AwsAmplify: NSObject {
|
|
8
9
|
private let TAG = "[Capacitor AwsAmplify]"
|
|
9
|
-
static public let instance =
|
|
10
|
+
// static public let instance = AwsAmplify()
|
|
10
11
|
|
|
11
|
-
private let sessionSubject = BehaviorSubject<Optional<AuthSession>>(value: nil)
|
|
12
|
-
public var isLoggedIn$: Observable<Bool> {
|
|
13
|
-
sessionSubject.map { session in
|
|
14
|
-
session != nil
|
|
15
|
-
}
|
|
16
|
-
}
|
|
12
|
+
// private let sessionSubject = BehaviorSubject<Optional<AuthSession>>(value: nil)
|
|
13
|
+
// public var isLoggedIn$: Observable<Bool> {
|
|
14
|
+
// sessionSubject.map { session in
|
|
15
|
+
// session != nil
|
|
16
|
+
// }
|
|
17
|
+
// }
|
|
17
18
|
|
|
18
19
|
struct AccessTokenPayload: Decodable {
|
|
19
20
|
var device_key:String
|
|
@@ -23,7 +24,10 @@ import AWSMobileClient
|
|
|
23
24
|
super.init()
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
public func load(
|
|
27
|
+
public func load(email: String,
|
|
28
|
+
password: String,
|
|
29
|
+
onSuccess: @escaping (AuthSignInResult) -> (),
|
|
30
|
+
onError: @escaping (any Error) -> ()) {
|
|
27
31
|
initAwsService()
|
|
28
32
|
}
|
|
29
33
|
|
|
@@ -149,7 +153,7 @@ import AWSMobileClient
|
|
|
149
153
|
ret["deviceKey"] = deviceKey
|
|
150
154
|
}
|
|
151
155
|
|
|
152
|
-
self.sessionSubject.onNext(session)
|
|
156
|
+
// self.sessionSubject.onNext(session)
|
|
153
157
|
|
|
154
158
|
print("\(self.TAG) - Fetch Auth Session successfully")
|
|
155
159
|
// print("\(self.TAG) - \(ret)")
|
|
@@ -184,9 +188,48 @@ import AWSMobileClient
|
|
|
184
188
|
}
|
|
185
189
|
|
|
186
190
|
private func initAwsService() {
|
|
191
|
+
let auth: AuthCategoryConfiguration = AuthCategoryConfiguration.init(plugins: [
|
|
192
|
+
"awsCognitoAuthPlugin" : JSONValue.object([
|
|
193
|
+
"CredentialsProvider" : JSONValue.object([
|
|
194
|
+
"CognitoIdentity" : JSONValue.object([
|
|
195
|
+
"Default" : JSONValue.object([
|
|
196
|
+
"PoolId" : JSONValue.string("eu-central-1:a6bf0e4d-a6da-46e9-9002-8caef1e2f13a"),
|
|
197
|
+
"Region" : JSONValue.string("eu-central-1"),
|
|
198
|
+
])
|
|
199
|
+
])
|
|
200
|
+
]),
|
|
201
|
+
"CognitoUserPool" : JSONValue.object([
|
|
202
|
+
"Default" : JSONValue.object([
|
|
203
|
+
"PoolId" : JSONValue.string("eu-central-1_Khi2tppV3"),
|
|
204
|
+
"AppClientId" : JSONValue.string("2sidb0hc7h45en6iorg2p4idng"),
|
|
205
|
+
"Region" : JSONValue.string("eu-central-1"),
|
|
206
|
+
])
|
|
207
|
+
]),
|
|
208
|
+
"Auth" : JSONValue.object([
|
|
209
|
+
"Default" : JSONValue.object([
|
|
210
|
+
"authenticationFlowType" : JSONValue.string("USER_SRP_AUTH"),
|
|
211
|
+
"OAuth" : JSONValue.object([
|
|
212
|
+
"WebDomain" : JSONValue.string("fantaracing-apple.auth.eu-central-1.amazoncognito.com"),
|
|
213
|
+
"AppClientId" : JSONValue.string("2sidb0hc7h45en6iorg2p4idng"),
|
|
214
|
+
"SignInRedirectURI" : JSONValue.string("fantaracing-app://"),
|
|
215
|
+
"SignOutRedirectURI" : JSONValue.string("fantaracing-app://"),
|
|
216
|
+
"Scopes" : JSONValue.array([
|
|
217
|
+
JSONValue.string("phone"),
|
|
218
|
+
JSONValue.string("email"),
|
|
219
|
+
JSONValue.string("profile"),
|
|
220
|
+
JSONValue.string("openid"),
|
|
221
|
+
JSONValue.string("aws.cognito.signin.user.admin"),
|
|
222
|
+
])
|
|
223
|
+
]),
|
|
224
|
+
])
|
|
225
|
+
]),
|
|
226
|
+
])
|
|
227
|
+
])
|
|
228
|
+
|
|
229
|
+
let ampConfig: AmplifyConfiguration = AmplifyConfiguration.init(auth:auth)
|
|
187
230
|
do {
|
|
188
231
|
try Amplify.add(plugin: AWSCognitoAuthPlugin())
|
|
189
|
-
try Amplify.configure()
|
|
232
|
+
try Amplify.configure(ampConfig)
|
|
190
233
|
print("\(self.TAG) Amplify configured with auth plugin")
|
|
191
234
|
|
|
192
235
|
Amplify.Hub.listen(to: .auth) { payload in
|
|
@@ -203,7 +246,7 @@ import AWSMobileClient
|
|
|
203
246
|
break
|
|
204
247
|
|
|
205
248
|
case HubPayload.EventName.Auth.signedOut:
|
|
206
|
-
self.sessionSubject.onNext(nil)
|
|
249
|
+
// self.sessionSubject.onNext(nil)
|
|
207
250
|
print("\(self.TAG) User signed out")
|
|
208
251
|
// Update UI
|
|
209
252
|
break
|
|
@@ -230,13 +273,13 @@ import AWSMobileClient
|
|
|
230
273
|
}
|
|
231
274
|
}
|
|
232
275
|
|
|
233
|
-
public func getSession() -> Optional<AuthSession> {
|
|
234
|
-
do {
|
|
235
|
-
return try self.sessionSubject.value()
|
|
236
|
-
} catch {
|
|
237
|
-
return nil
|
|
238
|
-
}
|
|
239
|
-
}
|
|
276
|
+
// public func getSession() -> Optional<AuthSession> {
|
|
277
|
+
// do {
|
|
278
|
+
// return try self.sessionSubject.value()
|
|
279
|
+
// } catch {
|
|
280
|
+
// return nil
|
|
281
|
+
// }
|
|
282
|
+
// }
|
|
240
283
|
|
|
241
284
|
// public func hasFullRegistration() -> Observable<Bool> {
|
|
242
285
|
// return Observable.create { observer in
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// Define the plugin using the CAP_PLUGIN Macro, and
|
|
5
5
|
// each method the plugin supports using the CAP_PLUGIN_METHOD macro.
|
|
6
6
|
CAP_PLUGIN(AwsAmplifyPlugin, "AwsAmplify",
|
|
7
|
+
CAP_PLUGIN_METHOD(load, CAPPluginReturnPromise);
|
|
7
8
|
CAP_PLUGIN_METHOD(signIn, CAPPluginReturnPromise);
|
|
8
9
|
CAP_PLUGIN_METHOD(signOut, CAPPluginReturnPromise);
|
|
9
10
|
CAP_PLUGIN_METHOD(federatedSignIn, CAPPluginReturnPromise);
|
|
@@ -9,15 +9,37 @@ import Capacitor
|
|
|
9
9
|
public class AwsAmplifyPlugin: CAPPlugin {
|
|
10
10
|
private let implementation = AwsAmplify()
|
|
11
11
|
|
|
12
|
+
@objc func load(_ call: CAPPluginCall) {
|
|
13
|
+
let email = call.getString("email") ?? ""
|
|
14
|
+
let password = call.getString("password") ?? ""
|
|
15
|
+
|
|
16
|
+
implementation.load(
|
|
17
|
+
email: email,
|
|
18
|
+
password: password,
|
|
19
|
+
onSuccess: {data in
|
|
20
|
+
self.implementation.fetchAuthSession(
|
|
21
|
+
onSuccess: {session in
|
|
22
|
+
call.resolve(session)
|
|
23
|
+
},
|
|
24
|
+
onError: {error in
|
|
25
|
+
call.reject(error.localizedDescription)
|
|
26
|
+
})
|
|
27
|
+
},
|
|
28
|
+
onError: {error in
|
|
29
|
+
print(error)
|
|
30
|
+
call.reject(error.localizedDescription)
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
|
|
12
34
|
@objc func signIn(_ call: CAPPluginCall) {
|
|
13
35
|
let email = call.getString("email") ?? ""
|
|
14
36
|
let password = call.getString("password") ?? ""
|
|
15
37
|
|
|
16
|
-
|
|
38
|
+
implementation.signIn(
|
|
17
39
|
email: email,
|
|
18
40
|
password: password,
|
|
19
41
|
onSuccess: {data in
|
|
20
|
-
self.
|
|
42
|
+
self.implementation.fetchAuthSession(
|
|
21
43
|
onSuccess: {session in
|
|
22
44
|
call.resolve(session)
|
|
23
45
|
},
|
|
@@ -32,7 +54,7 @@ public class AwsAmplifyPlugin: CAPPlugin {
|
|
|
32
54
|
}
|
|
33
55
|
|
|
34
56
|
@objc func signOut(_ call: CAPPluginCall) {
|
|
35
|
-
self.
|
|
57
|
+
self.implementation.signOut(
|
|
36
58
|
onSuccess: { success in
|
|
37
59
|
call.resolve([
|
|
38
60
|
"logout": success
|
|
@@ -45,11 +67,11 @@ public class AwsAmplifyPlugin: CAPPlugin {
|
|
|
45
67
|
@objc func federatedSignIn(_ call: CAPPluginCall) {
|
|
46
68
|
let provider = call.getString("provider") ?? ""
|
|
47
69
|
|
|
48
|
-
self.
|
|
70
|
+
self.implementation.federatedSignIn(
|
|
49
71
|
provider: provider,
|
|
50
72
|
onSuccess: { data in
|
|
51
73
|
print("federatedSignIn onSuccess \(data)")
|
|
52
|
-
self.
|
|
74
|
+
self.implementation.fetchAuthSession(
|
|
53
75
|
onSuccess: {session in
|
|
54
76
|
call.resolve(session)
|
|
55
77
|
},
|