@plusscommunities/pluss-core-web 1.6.9 → 1.6.10-auth.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +5252 -7712
- package/dist/index.esm.js +5111 -7562
- package/dist/index.umd.js +5242 -7692
- package/package.json +50 -47
- package/src/apis/fileActions.js +28 -7
- package/src/components/MakerPopup.js +15 -5
- package/src/config.js +5 -0
- package/src/session.js +5 -8
package/package.json
CHANGED
|
@@ -1,49 +1,52 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
2
|
+
"name": "@plusscommunities/pluss-core-web",
|
|
3
|
+
"version": "1.6.10-auth.0",
|
|
4
|
+
"description": "Core extension package for Pluss Communities platform",
|
|
5
|
+
"main": "dist/index.cjs.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "npm i && rollup -c",
|
|
8
|
+
"betapatch": "npm version prepatch --preid=beta",
|
|
9
|
+
"patch": "npm version patch",
|
|
10
|
+
"betaupload": "npm run build && npm publish --access public --tag beta && rm -rf node_modules",
|
|
11
|
+
"betaupload:p": "npm run betapatch && npm run betaupload",
|
|
12
|
+
"authpatch": "npm version prepatch --preid=auth",
|
|
13
|
+
"authupload": "npm run build && npm publish --access public --tag auth && rm -rf node_modules",
|
|
14
|
+
"authupload:p": "npm run authpatch && npm run authupload",
|
|
15
|
+
"upload": "npm run build && npm publish --access public && rm -rf node_modules",
|
|
16
|
+
"upload:p": "npm run patch && npm run upload"
|
|
17
|
+
},
|
|
18
|
+
"author": "Phillip Suh",
|
|
19
|
+
"license": "ISC",
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@babel/cli": "^7.14.3",
|
|
22
|
+
"@babel/core": "^7.14.3",
|
|
23
|
+
"@babel/plugin-transform-runtime": "^7.14.3",
|
|
24
|
+
"@babel/preset-env": "^7.14.2",
|
|
25
|
+
"@babel/preset-react": "^7.13.13",
|
|
26
|
+
"@rollup/plugin-babel": "^5.3.0",
|
|
27
|
+
"@rollup/plugin-json": "^4.1.0",
|
|
28
|
+
"autoprefixer": "^10.2.6",
|
|
29
|
+
"rollup": "^2.50.1",
|
|
30
|
+
"rollup-plugin-local-resolve": "^1.0.7",
|
|
31
|
+
"rollup-plugin-styles": "^3.14.1"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@babel/runtime": "^7.14.0"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@fortawesome/fontawesome-svg-core": "^6.4.0",
|
|
38
|
+
"@fortawesome/free-solid-svg-icons": "^6.4.0",
|
|
39
|
+
"@fortawesome/react-fontawesome": "^0.2.0",
|
|
40
|
+
"jquery": "^3.2.1",
|
|
41
|
+
"js-cookie": "^2.2.0",
|
|
42
|
+
"lodash": "^4.17.4",
|
|
43
|
+
"moment": "^2.30.1",
|
|
44
|
+
"react": "^16.14.0",
|
|
45
|
+
"react-dropzone": "^14.2.3",
|
|
46
|
+
"react-fontawesome": "^1.6.1",
|
|
47
|
+
"react-redux": "^7.2.9",
|
|
48
|
+
"react-router-dom": "^4.2.2",
|
|
49
|
+
"react-textarea-autosize": "^7.1.0-1"
|
|
50
|
+
},
|
|
51
|
+
"keywords": []
|
|
49
52
|
}
|
package/src/apis/fileActions.js
CHANGED
|
@@ -4,18 +4,33 @@ import { Storage } from 'aws-amplify';
|
|
|
4
4
|
import CanvasImageUploader from '../helper/files/canvasImageUploader';
|
|
5
5
|
import $ from 'jquery';
|
|
6
6
|
import { generateImageName, randomString, getUrl } from '../helper';
|
|
7
|
+
import Axios from 'axios';
|
|
7
8
|
|
|
8
9
|
export const fileActions = {
|
|
9
10
|
uploadMediaAsync: async (file, filename) => {
|
|
10
11
|
const newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
await
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
const signedUrlRes = await authedFunction({
|
|
13
|
+
method: 'GET',
|
|
14
|
+
url: getUrl('media', 'get/presignedurl', { filename: newFilename, contentType: file.type }),
|
|
15
|
+
});
|
|
16
|
+
await Axios.put(signedUrlRes.data.url, file, {
|
|
17
|
+
headers: {
|
|
18
|
+
'Content-Type': file.type,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
const { baseUploadsUrl } = Config.env;
|
|
22
|
+
return `${baseUploadsUrl}${signedUrlRes.data.key}`;
|
|
18
23
|
},
|
|
24
|
+
// uploadMediaAsync: async (file, filename) => {
|
|
25
|
+
// const newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
26
|
+
// const userId = await getCurrentUserSub();
|
|
27
|
+
// const url = `uploads/users/${userId}/public/${randomString()}/${newFilename}`;
|
|
28
|
+
|
|
29
|
+
// const { baseUploadsUrl, uploadBucket } = Config.env;
|
|
30
|
+
// await Storage.put(url, file, { level: 'public', bucket: uploadBucket });
|
|
31
|
+
// console.log('uploaded file', `${baseUploadsUrl}${url}`);
|
|
32
|
+
// return `${baseUploadsUrl}${url}`;
|
|
33
|
+
// },
|
|
19
34
|
|
|
20
35
|
// readBase64: async (file) => {
|
|
21
36
|
// return new Promise((resolve, reject) => {
|
|
@@ -30,6 +45,12 @@ export const fileActions = {
|
|
|
30
45
|
// };
|
|
31
46
|
// });
|
|
32
47
|
// },
|
|
48
|
+
getPresignedUrl: (filename) => {
|
|
49
|
+
return authedFunction({
|
|
50
|
+
method: 'GET',
|
|
51
|
+
url: getUrl('media', 'get/presignedurl', { filename }),
|
|
52
|
+
});
|
|
53
|
+
},
|
|
33
54
|
compressImage: (file, maxSize, quality, noCompress) => {
|
|
34
55
|
return new Promise((resolve, reject) => {
|
|
35
56
|
if (noCompress) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
2
|
import { connect } from 'react-redux';
|
|
3
|
-
import
|
|
3
|
+
import Lottie from 'react-lottie';
|
|
4
4
|
import _ from 'lodash';
|
|
5
5
|
import { unauthedFunction } from '../session';
|
|
6
6
|
import { Popup } from './Popup';
|
|
@@ -28,6 +28,9 @@ class MakerPopup extends Component {
|
|
|
28
28
|
{ Key: 'jpg', Title: 'JPEG' },
|
|
29
29
|
];
|
|
30
30
|
|
|
31
|
+
this.lottieAnimationUrl =
|
|
32
|
+
'https://pluss-prd-media.s3-ap-southeast-2.amazonaws.com/assets/lottie-layout.json';
|
|
33
|
+
|
|
31
34
|
this.state = {
|
|
32
35
|
...this.props.initialData,
|
|
33
36
|
logo: null,
|
|
@@ -38,8 +41,8 @@ class MakerPopup extends Component {
|
|
|
38
41
|
selectedSize: 'A4',
|
|
39
42
|
selectedFormat: 'pdf',
|
|
40
43
|
lottieConfig: {
|
|
41
|
-
path: 'https://pluss-prd-media.s3-ap-southeast-2.amazonaws.com/assets/lottie-layout.json',
|
|
42
44
|
loop: true,
|
|
45
|
+
autoplay: true,
|
|
43
46
|
name: 'lottie-layout',
|
|
44
47
|
},
|
|
45
48
|
};
|
|
@@ -66,12 +69,11 @@ class MakerPopup extends Component {
|
|
|
66
69
|
getLottieConfig() {
|
|
67
70
|
unauthedFunction({
|
|
68
71
|
method: 'GET',
|
|
69
|
-
url: this.
|
|
72
|
+
url: this.lottieAnimationUrl,
|
|
70
73
|
}).then((res) => {
|
|
71
74
|
this.setState({
|
|
72
75
|
lottieConfig: {
|
|
73
76
|
...this.state.lottieConfig,
|
|
74
|
-
path: undefined,
|
|
75
77
|
animationData: res.data,
|
|
76
78
|
},
|
|
77
79
|
});
|
|
@@ -227,7 +229,15 @@ class MakerPopup extends Component {
|
|
|
227
229
|
if (this.state.submitting) {
|
|
228
230
|
return (
|
|
229
231
|
<div className="flex flex-column flex-center">
|
|
230
|
-
|
|
232
|
+
{this.state.lottieConfig.animationData && (
|
|
233
|
+
<Lottie
|
|
234
|
+
key="lottie-layout"
|
|
235
|
+
height={260}
|
|
236
|
+
width={260}
|
|
237
|
+
options={this.state.lottieConfig}
|
|
238
|
+
isClickToPauseDisabled
|
|
239
|
+
/>
|
|
240
|
+
)}
|
|
231
241
|
<Text type="h3" className="marginTop-16">
|
|
232
242
|
Generating
|
|
233
243
|
</Text>
|
package/src/config.js
CHANGED
|
@@ -17,6 +17,11 @@ const CoreConfig = {
|
|
|
17
17
|
makeApiKey: '',
|
|
18
18
|
logo: '',
|
|
19
19
|
clientName: '',
|
|
20
|
+
AuthStrategy: {
|
|
21
|
+
getAccessToken: async () => null,
|
|
22
|
+
getCurrentUserId: async () => null,
|
|
23
|
+
hasActiveSession: async () => false,
|
|
24
|
+
},
|
|
20
25
|
},
|
|
21
26
|
init: (environment) => {
|
|
22
27
|
CoreConfig.env = environment;
|
package/src/session.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import axios from 'axios';
|
|
3
|
-
import
|
|
3
|
+
import Config from './config';
|
|
4
4
|
|
|
5
5
|
export const getSessionTokenAWS = async (prefix) => {
|
|
6
|
-
const
|
|
7
|
-
const token = data.getAccessToken().getJwtToken();
|
|
6
|
+
const token = await Config.env.AuthStrategy.getAccessToken();
|
|
8
7
|
if (_.isUndefined(prefix)) return token;
|
|
9
8
|
return `${prefix} ${token}`;
|
|
10
9
|
};
|
|
11
|
-
|
|
12
10
|
// export const getRefreshTokenAWS = async () => {
|
|
13
11
|
// const data = await Auth.currentSession();
|
|
14
12
|
// return data.getRefreshToken().token;
|
|
@@ -34,8 +32,7 @@ export const unauthedFunction = (request) => {
|
|
|
34
32
|
|
|
35
33
|
export const getCurrentUserSub = async () => {
|
|
36
34
|
try {
|
|
37
|
-
|
|
38
|
-
return user.id;
|
|
35
|
+
return await Config.env.AuthStrategy.getCurrentUserId();
|
|
39
36
|
} catch (error) {
|
|
40
37
|
return null;
|
|
41
38
|
}
|
|
@@ -43,8 +40,8 @@ export const getCurrentUserSub = async () => {
|
|
|
43
40
|
|
|
44
41
|
export const checkLoggedIn = async (self) => {
|
|
45
42
|
try {
|
|
46
|
-
const
|
|
47
|
-
if (
|
|
43
|
+
const isLoggedIn = await Config.env.AuthStrategy.hasActiveSession();
|
|
44
|
+
if (!isLoggedIn) {
|
|
48
45
|
console.log('redirecting to login');
|
|
49
46
|
self.props.history.push('/login');
|
|
50
47
|
}
|