@falconeta/capacitor-aws-amplify 0.0.1

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.
@@ -0,0 +1,20 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'FalconetaCapacitorAwsAmplify'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.license = package['license']
10
+ s.homepage = package['repository']['url']
11
+ s.author = package['author']
12
+ s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
+ s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
14
+ s.ios.deployment_target = '13.0'
15
+ s.dependency 'Capacitor'
16
+ s.swift_version = '5.1'
17
+ # Amplify dependency
18
+ s.dependency 'Amplify'
19
+ s.dependency 'AmplifyPlugins/AWSCognitoAuthPlugin'
20
+ end
package/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # @falconeta/capacitor-aws-amplify
2
+
3
+ plugin that handle amplify features
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @falconeta/capacitor-aws-amplify
9
+ npx cap sync
10
+ ```
11
+
12
+ ## API
13
+
14
+ <docgen-index>
15
+
16
+ * [`signIn(...)`](#signin)
17
+ * [`federatedSignIn(...)`](#federatedsignin)
18
+ * [`signOut()`](#signout)
19
+ * [Interfaces](#interfaces)
20
+
21
+ </docgen-index>
22
+
23
+ <docgen-api>
24
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
25
+
26
+ ### signIn(...)
27
+
28
+ ```typescript
29
+ signIn(options: { email: string; password: string; identityId: string; }) => Promise<CognitoAuthSession>
30
+ ```
31
+
32
+ | Param | Type |
33
+ | ------------- | --------------------------------------------------------------------- |
34
+ | **`options`** | <code>{ email: string; password: string; identityId: string; }</code> |
35
+
36
+ **Returns:** <code>Promise&lt;<a href="#cognitoauthsession">CognitoAuthSession</a>&gt;</code>
37
+
38
+ --------------------
39
+
40
+
41
+ ### federatedSignIn(...)
42
+
43
+ ```typescript
44
+ federatedSignIn(options: { provider: string; identityId: string; }) => Promise<CognitoAuthSession>
45
+ ```
46
+
47
+ | Param | Type |
48
+ | ------------- | ------------------------------------------------------ |
49
+ | **`options`** | <code>{ provider: string; identityId: string; }</code> |
50
+
51
+ **Returns:** <code>Promise&lt;<a href="#cognitoauthsession">CognitoAuthSession</a>&gt;</code>
52
+
53
+ --------------------
54
+
55
+
56
+ ### signOut()
57
+
58
+ ```typescript
59
+ signOut() => Promise<any>
60
+ ```
61
+
62
+ **Returns:** <code>Promise&lt;any&gt;</code>
63
+
64
+ --------------------
65
+
66
+
67
+ ### Interfaces
68
+
69
+
70
+ #### CognitoAuthSession
71
+
72
+ | Prop | Type |
73
+ | ------------------ | --------------------------- |
74
+ | **`accessToken`** | <code>string</code> |
75
+ | **`idToken`** | <code>string</code> |
76
+ | **`identityId`** | <code>string</code> |
77
+ | **`refreshToken`** | <code>string</code> |
78
+ | **`deviceKey`** | <code>string \| null</code> |
79
+
80
+ </docgen-api>
@@ -0,0 +1,58 @@
1
+ ext {
2
+ junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
4
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
5
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
6
+ }
7
+
8
+ buildscript {
9
+ repositories {
10
+ google()
11
+ mavenCentral()
12
+ }
13
+ dependencies {
14
+ classpath 'com.android.tools.build:gradle:8.0.0'
15
+ }
16
+ }
17
+
18
+ apply plugin: 'com.android.library'
19
+
20
+ android {
21
+ namespace "com.capacitor.aws.amplify"
22
+ compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 33
23
+ defaultConfig {
24
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
25
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 33
26
+ versionCode 1
27
+ versionName "1.0"
28
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
29
+ }
30
+ buildTypes {
31
+ release {
32
+ minifyEnabled false
33
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
34
+ }
35
+ }
36
+ lintOptions {
37
+ abortOnError false
38
+ }
39
+ compileOptions {
40
+ sourceCompatibility JavaVersion.VERSION_17
41
+ targetCompatibility JavaVersion.VERSION_17
42
+ }
43
+ }
44
+
45
+ repositories {
46
+ google()
47
+ mavenCentral()
48
+ }
49
+
50
+
51
+ dependencies {
52
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
53
+ implementation project(':capacitor-android')
54
+ implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
55
+ testImplementation "junit:junit:$junitVersion"
56
+ androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
57
+ androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
58
+ }
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -0,0 +1,11 @@
1
+ package com.capacitor.aws.amplify;
2
+
3
+ import android.util.Log;
4
+
5
+ public class AwsAmplify {
6
+
7
+ public String echo(String value) {
8
+ Log.i("Echo", value);
9
+ return value;
10
+ }
11
+ }
@@ -0,0 +1,22 @@
1
+ package com.capacitor.aws.amplify;
2
+
3
+ import com.getcapacitor.JSObject;
4
+ import com.getcapacitor.Plugin;
5
+ import com.getcapacitor.PluginCall;
6
+ import com.getcapacitor.PluginMethod;
7
+ import com.getcapacitor.annotation.CapacitorPlugin;
8
+
9
+ @CapacitorPlugin(name = "AwsAmplify")
10
+ public class AwsAmplifyPlugin extends Plugin {
11
+
12
+ private AwsAmplify implementation = new AwsAmplify();
13
+
14
+ @PluginMethod
15
+ public void echo(PluginCall call) {
16
+ String value = call.getString("value");
17
+
18
+ JSObject ret = new JSObject();
19
+ ret.put("value", implementation.echo(value));
20
+ call.resolve(ret);
21
+ }
22
+ }
File without changes
package/dist/docs.json ADDED
@@ -0,0 +1,106 @@
1
+ {
2
+ "api": {
3
+ "name": "AwsAmplifyPlugin",
4
+ "slug": "awsamplifyplugin",
5
+ "docs": "",
6
+ "tags": [],
7
+ "methods": [
8
+ {
9
+ "name": "signIn",
10
+ "signature": "(options: { email: string; password: string; identityId: string; }) => Promise<CognitoAuthSession>",
11
+ "parameters": [
12
+ {
13
+ "name": "options",
14
+ "docs": "",
15
+ "type": "{ email: string; password: string; identityId: string; }"
16
+ }
17
+ ],
18
+ "returns": "Promise<CognitoAuthSession>",
19
+ "tags": [],
20
+ "docs": "",
21
+ "complexTypes": [
22
+ "CognitoAuthSession"
23
+ ],
24
+ "slug": "signin"
25
+ },
26
+ {
27
+ "name": "federatedSignIn",
28
+ "signature": "(options: { provider: string; identityId: string; }) => Promise<CognitoAuthSession>",
29
+ "parameters": [
30
+ {
31
+ "name": "options",
32
+ "docs": "",
33
+ "type": "{ provider: string; identityId: string; }"
34
+ }
35
+ ],
36
+ "returns": "Promise<CognitoAuthSession>",
37
+ "tags": [],
38
+ "docs": "",
39
+ "complexTypes": [
40
+ "CognitoAuthSession"
41
+ ],
42
+ "slug": "federatedsignin"
43
+ },
44
+ {
45
+ "name": "signOut",
46
+ "signature": "() => Promise<any>",
47
+ "parameters": [],
48
+ "returns": "Promise<any>",
49
+ "tags": [],
50
+ "docs": "",
51
+ "complexTypes": [],
52
+ "slug": "signout"
53
+ }
54
+ ],
55
+ "properties": []
56
+ },
57
+ "interfaces": [
58
+ {
59
+ "name": "CognitoAuthSession",
60
+ "slug": "cognitoauthsession",
61
+ "docs": "",
62
+ "tags": [],
63
+ "methods": [],
64
+ "properties": [
65
+ {
66
+ "name": "accessToken",
67
+ "tags": [],
68
+ "docs": "",
69
+ "complexTypes": [],
70
+ "type": "string"
71
+ },
72
+ {
73
+ "name": "idToken",
74
+ "tags": [],
75
+ "docs": "",
76
+ "complexTypes": [],
77
+ "type": "string"
78
+ },
79
+ {
80
+ "name": "identityId",
81
+ "tags": [],
82
+ "docs": "",
83
+ "complexTypes": [],
84
+ "type": "string"
85
+ },
86
+ {
87
+ "name": "refreshToken",
88
+ "tags": [],
89
+ "docs": "",
90
+ "complexTypes": [],
91
+ "type": "string"
92
+ },
93
+ {
94
+ "name": "deviceKey",
95
+ "tags": [],
96
+ "docs": "",
97
+ "complexTypes": [],
98
+ "type": "string | null"
99
+ }
100
+ ]
101
+ }
102
+ ],
103
+ "enums": [],
104
+ "typeAliases": [],
105
+ "pluginConfigs": []
106
+ }
@@ -0,0 +1,19 @@
1
+ export interface AwsAmplifyPlugin {
2
+ signIn(options: {
3
+ email: string;
4
+ password: string;
5
+ identityId: string;
6
+ }): Promise<CognitoAuthSession>;
7
+ federatedSignIn(options: {
8
+ provider: string;
9
+ identityId: string;
10
+ }): Promise<CognitoAuthSession>;
11
+ signOut(): Promise<any>;
12
+ }
13
+ export interface CognitoAuthSession {
14
+ accessToken: string;
15
+ idToken: string;
16
+ identityId: string;
17
+ refreshToken: string;
18
+ deviceKey: string | null;
19
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +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"]}
@@ -0,0 +1,4 @@
1
+ import type { AwsAmplifyPlugin } from './definitions';
2
+ declare const AwsAmplify: AwsAmplifyPlugin;
3
+ export * from './definitions';
4
+ export { AwsAmplify };
@@ -0,0 +1,7 @@
1
+ import { registerPlugin } from '@capacitor/core';
2
+ const AwsAmplify = registerPlugin('AwsAmplify', {
3
+ web: () => import('./web').then(m => new m.AwsAmplifyWeb()),
4
+ });
5
+ export * from './definitions';
6
+ export { AwsAmplify };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,UAAU,GAAG,cAAc,CAAmB,YAAY,EAAE;IAChE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;CAC5D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { AwsAmplifyPlugin } from './definitions';\n\nconst AwsAmplify = registerPlugin<AwsAmplifyPlugin>('AwsAmplify', {\n web: () => import('./web').then(m => new m.AwsAmplifyWeb()),\n});\n\nexport * from './definitions';\nexport { AwsAmplify };\n"]}
@@ -0,0 +1,15 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import type { AwsAmplifyPlugin, CognitoAuthSession } from './definitions';
3
+ export declare class AwsAmplifyWeb extends WebPlugin implements AwsAmplifyPlugin {
4
+ signIn(options: {
5
+ email: string;
6
+ password: string;
7
+ identityId: string;
8
+ }): Promise<CognitoAuthSession>;
9
+ federatedSignIn(options: {
10
+ provider: string;
11
+ identityId: string;
12
+ }): Promise<CognitoAuthSession>;
13
+ signOut(): Promise<any>;
14
+ private getCognitoAuthSession;
15
+ }
@@ -0,0 +1,46 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import { Auth } from 'aws-amplify';
3
+ export class AwsAmplifyWeb extends WebPlugin {
4
+ async signIn(options) {
5
+ // console.log(LOG_PREFIX, options);
6
+ return new Promise((resolve, reject) => {
7
+ Auth.signIn(options.email, options.password).then((user) => {
8
+ const cognitoAuthSession = this.getCognitoAuthSession(user, options.identityId);
9
+ cognitoAuthSession ? resolve(cognitoAuthSession) : reject();
10
+ });
11
+ });
12
+ }
13
+ async federatedSignIn(options) {
14
+ // console.log(LOG_PREFIX, options);
15
+ return new Promise((resolve, reject) => {
16
+ Auth.federatedSignIn(options)
17
+ .then(_ => {
18
+ // console.log(LOG_PREFIX + " credential", cred);
19
+ Auth.currentAuthenticatedUser().then(user => {
20
+ // console.log(LOG_PREFIX + " user", user);
21
+ const cognitoAuthSession = this.getCognitoAuthSession(user, options.identityId);
22
+ cognitoAuthSession ? resolve(cognitoAuthSession) : reject();
23
+ });
24
+ })
25
+ .catch(err => reject(err));
26
+ });
27
+ }
28
+ async signOut() {
29
+ return Auth.signOut();
30
+ }
31
+ getCognitoAuthSession(user, identityId) {
32
+ const userSession = user.getSignInUserSession();
33
+ if (userSession) {
34
+ const res = {
35
+ accessToken: userSession.getAccessToken().getJwtToken(),
36
+ idToken: userSession.getIdToken().getJwtToken(),
37
+ identityId: identityId,
38
+ refreshToken: userSession.getRefreshToken().getToken(),
39
+ deviceKey: userSession.getAccessToken().decodePayload().device_key,
40
+ };
41
+ return res;
42
+ }
43
+ return null;
44
+ }
45
+ }
46
+ //# sourceMappingURL=web.js.map
@@ -0,0 +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,IAAI,EAAE,MAAM,aAAa,CAAC;AAInC,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC1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AiB,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 { Auth } from 'aws-amplify';\n\nimport type { AwsAmplifyPlugin, CognitoAuthSession } from './definitions';\n\nexport class AwsAmplifyWeb extends WebPlugin implements AwsAmplifyPlugin {\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"]}
@@ -0,0 +1,62 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var core = require('@capacitor/core');
6
+ var awsAmplify = require('aws-amplify');
7
+
8
+ const AwsAmplify = core.registerPlugin('AwsAmplify', {
9
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.AwsAmplifyWeb()),
10
+ });
11
+
12
+ class AwsAmplifyWeb extends core.WebPlugin {
13
+ async signIn(options) {
14
+ // console.log(LOG_PREFIX, options);
15
+ return new Promise((resolve, reject) => {
16
+ awsAmplify.Auth.signIn(options.email, options.password).then((user) => {
17
+ const cognitoAuthSession = this.getCognitoAuthSession(user, options.identityId);
18
+ cognitoAuthSession ? resolve(cognitoAuthSession) : reject();
19
+ });
20
+ });
21
+ }
22
+ async federatedSignIn(options) {
23
+ // console.log(LOG_PREFIX, options);
24
+ return new Promise((resolve, reject) => {
25
+ awsAmplify.Auth.federatedSignIn(options)
26
+ .then(_ => {
27
+ // console.log(LOG_PREFIX + " credential", cred);
28
+ awsAmplify.Auth.currentAuthenticatedUser().then(user => {
29
+ // console.log(LOG_PREFIX + " user", user);
30
+ const cognitoAuthSession = this.getCognitoAuthSession(user, options.identityId);
31
+ cognitoAuthSession ? resolve(cognitoAuthSession) : reject();
32
+ });
33
+ })
34
+ .catch(err => reject(err));
35
+ });
36
+ }
37
+ async signOut() {
38
+ return awsAmplify.Auth.signOut();
39
+ }
40
+ getCognitoAuthSession(user, identityId) {
41
+ const userSession = user.getSignInUserSession();
42
+ if (userSession) {
43
+ const res = {
44
+ accessToken: userSession.getAccessToken().getJwtToken(),
45
+ idToken: userSession.getIdToken().getJwtToken(),
46
+ identityId: identityId,
47
+ refreshToken: userSession.getRefreshToken().getToken(),
48
+ deviceKey: userSession.getAccessToken().decodePayload().device_key,
49
+ };
50
+ return res;
51
+ }
52
+ return null;
53
+ }
54
+ }
55
+
56
+ var web = /*#__PURE__*/Object.freeze({
57
+ __proto__: null,
58
+ AwsAmplifyWeb: AwsAmplifyWeb
59
+ });
60
+
61
+ exports.AwsAmplify = AwsAmplify;
62
+ //# sourceMappingURL=plugin.cjs.js.map
@@ -0,0 +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,aAAa,EAAE,CAAC;AAC/D,CAAC;;ACDM,MAAM,aAAa,SAASC,cAAS,CAAC;AAC7C,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,OAAO,CAAC,UAAU,CAAC,CAAC;AAChG,gBAAgB,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,GAAG,MAAM,EAAE,CAAC;AAC5E,aAAa,CAAC,CAAC;AACf,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,MAAM,eAAe,CAAC,OAAO,EAAE;AACnC;AACA,QAAQ,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;AAChD,YAAYA,eAAI,CAAC,eAAe,CAAC,OAAO,CAAC;AACzC,iBAAiB,IAAI,CAAC,CAAC,IAAI;AAC3B;AACA,gBAAgBA,eAAI,CAA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
5
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.AwsAmplifyWeb()),
6
+ });
7
+
8
+ class AwsAmplifyWeb extends core.WebPlugin {
9
+ async signIn(options) {
10
+ // console.log(LOG_PREFIX, options);
11
+ return new Promise((resolve, reject) => {
12
+ awsAmplify.Auth.signIn(options.email, options.password).then((user) => {
13
+ const cognitoAuthSession = this.getCognitoAuthSession(user, options.identityId);
14
+ cognitoAuthSession ? resolve(cognitoAuthSession) : reject();
15
+ });
16
+ });
17
+ }
18
+ async federatedSignIn(options) {
19
+ // console.log(LOG_PREFIX, options);
20
+ return new Promise((resolve, reject) => {
21
+ awsAmplify.Auth.federatedSignIn(options)
22
+ .then(_ => {
23
+ // console.log(LOG_PREFIX + " credential", cred);
24
+ awsAmplify.Auth.currentAuthenticatedUser().then(user => {
25
+ // console.log(LOG_PREFIX + " user", user);
26
+ const cognitoAuthSession = this.getCognitoAuthSession(user, options.identityId);
27
+ cognitoAuthSession ? resolve(cognitoAuthSession) : reject();
28
+ });
29
+ })
30
+ .catch(err => reject(err));
31
+ });
32
+ }
33
+ async signOut() {
34
+ return awsAmplify.Auth.signOut();
35
+ }
36
+ getCognitoAuthSession(user, identityId) {
37
+ const userSession = user.getSignInUserSession();
38
+ if (userSession) {
39
+ const res = {
40
+ accessToken: userSession.getAccessToken().getJwtToken(),
41
+ idToken: userSession.getIdToken().getJwtToken(),
42
+ identityId: identityId,
43
+ refreshToken: userSession.getRefreshToken().getToken(),
44
+ deviceKey: userSession.getAccessToken().decodePayload().device_key,
45
+ };
46
+ return res;
47
+ }
48
+ return null;
49
+ }
50
+ }
51
+
52
+ var web = /*#__PURE__*/Object.freeze({
53
+ __proto__: null,
54
+ AwsAmplifyWeb: AwsAmplifyWeb
55
+ });
56
+
57
+ exports.AwsAmplify = AwsAmplify;
58
+
59
+ Object.defineProperty(exports, '__esModule', { value: true });
60
+
61
+ return exports;
62
+
63
+ })({}, capacitorExports, awsAmplify);
64
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +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;I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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;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,8 @@
1
+ import Foundation
2
+
3
+ @objc public class AwsAmplify: NSObject {
4
+ @objc public func echo(_ value: String) -> String {
5
+ print(value)
6
+ return value
7
+ }
8
+ }
@@ -0,0 +1,10 @@
1
+ #import <UIKit/UIKit.h>
2
+
3
+ //! Project version number for Plugin.
4
+ FOUNDATION_EXPORT double PluginVersionNumber;
5
+
6
+ //! Project version string for Plugin.
7
+ FOUNDATION_EXPORT const unsigned char PluginVersionString[];
8
+
9
+ // In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
10
+
@@ -0,0 +1,8 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <Capacitor/Capacitor.h>
3
+
4
+ // Define the plugin using the CAP_PLUGIN Macro, and
5
+ // each method the plugin supports using the CAP_PLUGIN_METHOD macro.
6
+ CAP_PLUGIN(AwsAmplifyPlugin, "AwsAmplify",
7
+ CAP_PLUGIN_METHOD(echo, CAPPluginReturnPromise);
8
+ )
@@ -0,0 +1,18 @@
1
+ import Foundation
2
+ import Capacitor
3
+
4
+ /**
5
+ * Please read the Capacitor iOS Plugin Development Guide
6
+ * here: https://capacitorjs.com/docs/plugins/ios
7
+ */
8
+ @objc(AwsAmplifyPlugin)
9
+ public class AwsAmplifyPlugin: CAPPlugin {
10
+ private let implementation = AwsAmplify()
11
+
12
+ @objc func echo(_ call: CAPPluginCall) {
13
+ let value = call.getString("value") ?? ""
14
+ call.resolve([
15
+ "value": implementation.echo(value)
16
+ ])
17
+ }
18
+ }
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key>
6
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
7
+ <key>CFBundleExecutable</key>
8
+ <string>$(EXECUTABLE_NAME)</string>
9
+ <key>CFBundleIdentifier</key>
10
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11
+ <key>CFBundleInfoDictionaryVersion</key>
12
+ <string>6.0</string>
13
+ <key>CFBundleName</key>
14
+ <string>$(PRODUCT_NAME)</string>
15
+ <key>CFBundlePackageType</key>
16
+ <string>FMWK</string>
17
+ <key>CFBundleShortVersionString</key>
18
+ <string>1.0</string>
19
+ <key>CFBundleVersion</key>
20
+ <string>$(CURRENT_PROJECT_VERSION)</string>
21
+ <key>NSPrincipalClass</key>
22
+ <string></string>
23
+ </dict>
24
+ </plist>
package/package.json ADDED
@@ -0,0 +1,83 @@
1
+ {
2
+ "name": "@falconeta/capacitor-aws-amplify",
3
+ "version": "0.0.1",
4
+ "description": "plugin that handle amplify features",
5
+ "main": "dist/plugin.cjs.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/esm/index.d.ts",
8
+ "unpkg": "dist/plugin.js",
9
+ "files": [
10
+ "android/src/main/",
11
+ "android/build.gradle",
12
+ "dist/",
13
+ "ios/Plugin/",
14
+ "FalconetaCapacitorAwsAmplify.podspec"
15
+ ],
16
+ "author": "falconeta",
17
+ "license": "MIT",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/falconeta/capacitor-aws-amplify.git"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/falconeta/capacitor-aws-amplify/issues"
24
+ },
25
+ "keywords": [
26
+ "capacitor",
27
+ "plugin",
28
+ "native"
29
+ ],
30
+ "scripts": {
31
+ "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
32
+ "verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS && cd ..",
33
+ "verify:android": "cd android && ./gradlew clean build test && cd ..",
34
+ "verify:web": "npm run build",
35
+ "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
36
+ "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
37
+ "eslint": "eslint . --ext ts",
38
+ "prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
39
+ "swiftlint": "node-swiftlint",
40
+ "docgen": "docgen --api AwsAmplifyPlugin --output-readme README.md --output-json dist/docs.json",
41
+ "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.js",
42
+ "clean": "rimraf ./dist",
43
+ "watch": "tsc --watch",
44
+ "prepublishOnly": "npm run build"
45
+ },
46
+ "devDependencies": {
47
+ "@aws-amplify/auth": "^5.6.5",
48
+ "@capacitor/android": "^5.0.0",
49
+ "@capacitor/core": "^5.0.0",
50
+ "@capacitor/docgen": "^0.0.18",
51
+ "@capacitor/ios": "^5.0.0",
52
+ "@ionic/eslint-config": "^0.3.0",
53
+ "@ionic/prettier-config": "^1.0.1",
54
+ "@ionic/swiftlint-config": "^1.1.2",
55
+ "aws-amplify": "^5.3.11",
56
+ "eslint": "^7.11.0",
57
+ "prettier": "~2.3.0",
58
+ "prettier-plugin-java": "~1.0.2",
59
+ "rimraf": "^3.0.2",
60
+ "rollup": "^2.32.0",
61
+ "swiftlint": "^1.0.1",
62
+ "typescript": "~4.1.5"
63
+ },
64
+ "peerDependencies": {
65
+ "@capacitor/core": "^5.0.0"
66
+ },
67
+ "prettier": "@ionic/prettier-config",
68
+ "swiftlint": "@ionic/swiftlint-config",
69
+ "eslintConfig": {
70
+ "extends": "@ionic/eslint-config/recommended"
71
+ },
72
+ "capacitor": {
73
+ "ios": {
74
+ "src": "ios"
75
+ },
76
+ "android": {
77
+ "src": "android"
78
+ }
79
+ },
80
+ "publishConfig": {
81
+ "access": "public"
82
+ }
83
+ }