@plusscommunities/pluss-core-web 1.4.32-auth.0 → 1.4.33-beta.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 +44 -124
- package/dist/index.esm.js +44 -124
- package/dist/index.umd.js +47 -127
- package/package.json +5 -8
- package/src/apis/fileActions.js +7 -28
- package/src/components/AudienceSelector.js +1 -1
- package/src/components/FileInput.js +1 -1
- package/src/components/ImageInput.js +1 -2
- package/src/config.js +0 -5
- package/src/session.js +8 -5
package/dist/index.cjs.js
CHANGED
|
@@ -6,12 +6,12 @@ var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
|
|
|
6
6
|
var _regeneratorRuntime = require('@babel/runtime/regenerator');
|
|
7
7
|
var _ = require('lodash');
|
|
8
8
|
var axios = require('axios');
|
|
9
|
+
var awsAmplify = require('aws-amplify');
|
|
9
10
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
10
11
|
var moment = require('moment');
|
|
11
12
|
var React = require('react');
|
|
12
13
|
var $ = require('jquery');
|
|
13
14
|
var Cookies = require('js-cookie');
|
|
14
|
-
var awsAmplify = require('aws-amplify');
|
|
15
15
|
var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
|
|
16
16
|
var _createClass = require('@babel/runtime/helpers/createClass');
|
|
17
17
|
var _inherits = require('@babel/runtime/helpers/inherits');
|
|
@@ -79,75 +79,7 @@ var CoreConfig = {
|
|
|
79
79
|
defaultAllowComments: true,
|
|
80
80
|
makeApiKey: '',
|
|
81
81
|
logo: '',
|
|
82
|
-
clientName: ''
|
|
83
|
-
AuthStrategy: {
|
|
84
|
-
getAccessToken: function () {
|
|
85
|
-
var _getAccessToken = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
|
|
86
|
-
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
87
|
-
while (1) {
|
|
88
|
-
switch (_context.prev = _context.next) {
|
|
89
|
-
case 0:
|
|
90
|
-
return _context.abrupt("return", null);
|
|
91
|
-
|
|
92
|
-
case 1:
|
|
93
|
-
case "end":
|
|
94
|
-
return _context.stop();
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}, _callee);
|
|
98
|
-
}));
|
|
99
|
-
|
|
100
|
-
function getAccessToken() {
|
|
101
|
-
return _getAccessToken.apply(this, arguments);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return getAccessToken;
|
|
105
|
-
}(),
|
|
106
|
-
getCurrentUserId: function () {
|
|
107
|
-
var _getCurrentUserId = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2() {
|
|
108
|
-
return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
|
|
109
|
-
while (1) {
|
|
110
|
-
switch (_context2.prev = _context2.next) {
|
|
111
|
-
case 0:
|
|
112
|
-
return _context2.abrupt("return", null);
|
|
113
|
-
|
|
114
|
-
case 1:
|
|
115
|
-
case "end":
|
|
116
|
-
return _context2.stop();
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}, _callee2);
|
|
120
|
-
}));
|
|
121
|
-
|
|
122
|
-
function getCurrentUserId() {
|
|
123
|
-
return _getCurrentUserId.apply(this, arguments);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return getCurrentUserId;
|
|
127
|
-
}(),
|
|
128
|
-
hasActiveSession: function () {
|
|
129
|
-
var _hasActiveSession = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3() {
|
|
130
|
-
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
|
131
|
-
while (1) {
|
|
132
|
-
switch (_context3.prev = _context3.next) {
|
|
133
|
-
case 0:
|
|
134
|
-
return _context3.abrupt("return", false);
|
|
135
|
-
|
|
136
|
-
case 1:
|
|
137
|
-
case "end":
|
|
138
|
-
return _context3.stop();
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}, _callee3);
|
|
142
|
-
}));
|
|
143
|
-
|
|
144
|
-
function hasActiveSession() {
|
|
145
|
-
return _hasActiveSession.apply(this, arguments);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return hasActiveSession;
|
|
149
|
-
}()
|
|
150
|
-
}
|
|
82
|
+
clientName: ''
|
|
151
83
|
},
|
|
152
84
|
init: function init(environment) {
|
|
153
85
|
CoreConfig.env = environment;
|
|
@@ -156,28 +88,29 @@ var CoreConfig = {
|
|
|
156
88
|
|
|
157
89
|
var getSessionTokenAWS = /*#__PURE__*/function () {
|
|
158
90
|
var _ref = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(prefix) {
|
|
159
|
-
var token;
|
|
91
|
+
var data, token;
|
|
160
92
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
161
93
|
while (1) {
|
|
162
94
|
switch (_context.prev = _context.next) {
|
|
163
95
|
case 0:
|
|
164
96
|
_context.next = 2;
|
|
165
|
-
return
|
|
97
|
+
return awsAmplify.Auth.currentSession();
|
|
166
98
|
|
|
167
99
|
case 2:
|
|
168
|
-
|
|
100
|
+
data = _context.sent;
|
|
101
|
+
token = data.getAccessToken().getJwtToken();
|
|
169
102
|
|
|
170
103
|
if (!___default['default'].isUndefined(prefix)) {
|
|
171
|
-
_context.next =
|
|
104
|
+
_context.next = 6;
|
|
172
105
|
break;
|
|
173
106
|
}
|
|
174
107
|
|
|
175
108
|
return _context.abrupt("return", token);
|
|
176
109
|
|
|
177
|
-
case
|
|
110
|
+
case 6:
|
|
178
111
|
return _context.abrupt("return", "".concat(prefix, " ").concat(token));
|
|
179
112
|
|
|
180
|
-
case
|
|
113
|
+
case 7:
|
|
181
114
|
case "end":
|
|
182
115
|
return _context.stop();
|
|
183
116
|
}
|
|
@@ -237,28 +170,30 @@ var unauthedFunction = function unauthedFunction(request) {
|
|
|
237
170
|
};
|
|
238
171
|
var getCurrentUserSub = /*#__PURE__*/function () {
|
|
239
172
|
var _ref3 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3() {
|
|
173
|
+
var user;
|
|
240
174
|
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
|
241
175
|
while (1) {
|
|
242
176
|
switch (_context3.prev = _context3.next) {
|
|
243
177
|
case 0:
|
|
244
178
|
_context3.prev = 0;
|
|
245
179
|
_context3.next = 3;
|
|
246
|
-
return
|
|
180
|
+
return awsAmplify.Auth.currentUserInfo();
|
|
247
181
|
|
|
248
182
|
case 3:
|
|
249
|
-
|
|
183
|
+
user = _context3.sent;
|
|
184
|
+
return _context3.abrupt("return", user.id);
|
|
250
185
|
|
|
251
|
-
case
|
|
252
|
-
_context3.prev =
|
|
186
|
+
case 7:
|
|
187
|
+
_context3.prev = 7;
|
|
253
188
|
_context3.t0 = _context3["catch"](0);
|
|
254
189
|
return _context3.abrupt("return", null);
|
|
255
190
|
|
|
256
|
-
case
|
|
191
|
+
case 10:
|
|
257
192
|
case "end":
|
|
258
193
|
return _context3.stop();
|
|
259
194
|
}
|
|
260
195
|
}
|
|
261
|
-
}, _callee3, null, [[0,
|
|
196
|
+
}, _callee3, null, [[0, 7]]);
|
|
262
197
|
}));
|
|
263
198
|
|
|
264
199
|
return function getCurrentUserSub() {
|
|
@@ -267,19 +202,19 @@ var getCurrentUserSub = /*#__PURE__*/function () {
|
|
|
267
202
|
}();
|
|
268
203
|
var checkLoggedIn = /*#__PURE__*/function () {
|
|
269
204
|
var _ref4 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4(self) {
|
|
270
|
-
var
|
|
205
|
+
var user;
|
|
271
206
|
return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
|
|
272
207
|
while (1) {
|
|
273
208
|
switch (_context4.prev = _context4.next) {
|
|
274
209
|
case 0:
|
|
275
210
|
_context4.prev = 0;
|
|
276
211
|
_context4.next = 3;
|
|
277
|
-
return
|
|
212
|
+
return awsAmplify.Auth.currentAuthenticatedUser();
|
|
278
213
|
|
|
279
214
|
case 3:
|
|
280
|
-
|
|
215
|
+
user = _context4.sent;
|
|
281
216
|
|
|
282
|
-
if (
|
|
217
|
+
if (___default['default'].isUndefined(user) || user == null || user.username == null) {
|
|
283
218
|
console.log('redirecting to login');
|
|
284
219
|
self.props.history.push('/login');
|
|
285
220
|
}
|
|
@@ -1711,34 +1646,31 @@ function CanvasImageUploader(options) {
|
|
|
1711
1646
|
var fileActions = {
|
|
1712
1647
|
uploadMediaAsync: function () {
|
|
1713
1648
|
var _uploadMediaAsync = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(file, filename) {
|
|
1714
|
-
var newFilename,
|
|
1649
|
+
var newFilename, userId, url, _Config$env, baseUploadsUrl, uploadBucket;
|
|
1650
|
+
|
|
1715
1651
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
1716
1652
|
while (1) {
|
|
1717
1653
|
switch (_context.prev = _context.next) {
|
|
1718
1654
|
case 0:
|
|
1719
1655
|
newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
1720
1656
|
_context.next = 3;
|
|
1721
|
-
return
|
|
1722
|
-
method: 'GET',
|
|
1723
|
-
url: getUrl('media', 'get/presignedurl', {
|
|
1724
|
-
filename: newFilename
|
|
1725
|
-
})
|
|
1726
|
-
});
|
|
1657
|
+
return getCurrentUserSub();
|
|
1727
1658
|
|
|
1728
1659
|
case 3:
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1660
|
+
userId = _context.sent;
|
|
1661
|
+
url = "uploads/users/".concat(userId, "/public/").concat(randomString(), "/").concat(newFilename);
|
|
1662
|
+
_Config$env = CoreConfig.env, baseUploadsUrl = _Config$env.baseUploadsUrl, uploadBucket = _Config$env.uploadBucket;
|
|
1663
|
+
_context.next = 8;
|
|
1664
|
+
return awsAmplify.Storage.put(url, file, {
|
|
1665
|
+
level: 'public',
|
|
1666
|
+
bucket: uploadBucket
|
|
1735
1667
|
});
|
|
1736
1668
|
|
|
1737
|
-
case 6:
|
|
1738
|
-
baseUploadsUrl = CoreConfig.env.baseUploadsUrl;
|
|
1739
|
-
return _context.abrupt("return", "".concat(baseUploadsUrl).concat(signedUrlRes.data.key));
|
|
1740
|
-
|
|
1741
1669
|
case 8:
|
|
1670
|
+
console.log('uploaded file', "".concat(baseUploadsUrl).concat(url));
|
|
1671
|
+
return _context.abrupt("return", "".concat(baseUploadsUrl).concat(url));
|
|
1672
|
+
|
|
1673
|
+
case 10:
|
|
1742
1674
|
case "end":
|
|
1743
1675
|
return _context.stop();
|
|
1744
1676
|
}
|
|
@@ -1752,15 +1684,6 @@ var fileActions = {
|
|
|
1752
1684
|
|
|
1753
1685
|
return uploadMediaAsync;
|
|
1754
1686
|
}(),
|
|
1755
|
-
// uploadMediaAsync: async (file, filename) => {
|
|
1756
|
-
// const newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
1757
|
-
// const userId = await getCurrentUserSub();
|
|
1758
|
-
// const url = `uploads/users/${userId}/public/${randomString()}/${newFilename}`;
|
|
1759
|
-
// const { baseUploadsUrl, uploadBucket } = Config.env;
|
|
1760
|
-
// await Storage.put(url, file, { level: 'public', bucket: uploadBucket });
|
|
1761
|
-
// console.log('uploaded file', `${baseUploadsUrl}${url}`);
|
|
1762
|
-
// return `${baseUploadsUrl}${url}`;
|
|
1763
|
-
// },
|
|
1764
1687
|
// readBase64: async (file) => {
|
|
1765
1688
|
// return new Promise((resolve, reject) => {
|
|
1766
1689
|
// var reader = new FileReader();
|
|
@@ -1774,14 +1697,6 @@ var fileActions = {
|
|
|
1774
1697
|
// };
|
|
1775
1698
|
// });
|
|
1776
1699
|
// },
|
|
1777
|
-
getPresignedUrl: function getPresignedUrl(filename) {
|
|
1778
|
-
return authedFunction({
|
|
1779
|
-
method: 'GET',
|
|
1780
|
-
url: getUrl('media', 'get/presignedurl', {
|
|
1781
|
-
filename: filename
|
|
1782
|
-
})
|
|
1783
|
-
});
|
|
1784
|
-
},
|
|
1785
1700
|
compressImage: function compressImage(file, maxSize, quality, noCompress) {
|
|
1786
1701
|
return new Promise(function (resolve, reject) {
|
|
1787
1702
|
if (noCompress) {
|
|
@@ -5275,7 +5190,9 @@ var mapStateToProps$5 = function mapStateToProps() {
|
|
|
5275
5190
|
return {};
|
|
5276
5191
|
};
|
|
5277
5192
|
|
|
5278
|
-
var FileInput = reactRedux.connect(mapStateToProps$5, {}, null, {
|
|
5193
|
+
var FileInput = reactRedux.connect(mapStateToProps$5, {}, null, {
|
|
5194
|
+
forwardRef: true
|
|
5195
|
+
})(FileInputComponent);
|
|
5279
5196
|
|
|
5280
5197
|
function ownKeys$e(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
5281
5198
|
|
|
@@ -6983,7 +6900,6 @@ var ImageInputComponent = /*#__PURE__*/function (_Component) {
|
|
|
6983
6900
|
value: function renderLibraryImage(image, index, allowDelete) {
|
|
6984
6901
|
var _this7 = this;
|
|
6985
6902
|
|
|
6986
|
-
console.log(image);
|
|
6987
6903
|
var classes = 'imageInput imageInput-hasImage imageInput-libraryImage';
|
|
6988
6904
|
|
|
6989
6905
|
if (image.Selected) {
|
|
@@ -7381,7 +7297,9 @@ var mapStateToProps$2 = function mapStateToProps(state) {
|
|
|
7381
7297
|
};
|
|
7382
7298
|
};
|
|
7383
7299
|
|
|
7384
|
-
var ImageInput = reactRedux.connect(mapStateToProps$2, {}, null, {
|
|
7300
|
+
var ImageInput = reactRedux.connect(mapStateToProps$2, {}, null, {
|
|
7301
|
+
forwardRef: true
|
|
7302
|
+
})(ImageInputComponent);
|
|
7385
7303
|
|
|
7386
7304
|
function _createSuper$m(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$m(); return function _createSuperInternal() { var Super = _getPrototypeOf__default['default'](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default['default'](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default['default'](this, result); }; }
|
|
7387
7305
|
|
|
@@ -9984,7 +9902,9 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9984
9902
|
|
|
9985
9903
|
var toExport = reactRedux.connect(null, {
|
|
9986
9904
|
setAuth: setAuth
|
|
9987
|
-
}, null, {
|
|
9905
|
+
}, null, {
|
|
9906
|
+
forwardRef: true
|
|
9907
|
+
})(AudienceSelector);
|
|
9988
9908
|
|
|
9989
9909
|
function _createSuper$5(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$5(); return function _createSuperInternal() { var Super = _getPrototypeOf__default['default'](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default['default'](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default['default'](this, result); }; }
|
|
9990
9910
|
|
package/dist/index.esm.js
CHANGED
|
@@ -2,12 +2,12 @@ import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
|
2
2
|
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
3
3
|
import _ from 'lodash';
|
|
4
4
|
import axios from 'axios';
|
|
5
|
+
import { Auth, Storage } from 'aws-amplify';
|
|
5
6
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
6
7
|
import moment from 'moment';
|
|
7
8
|
import React, { Component, PureComponent } from 'react';
|
|
8
9
|
import $ from 'jquery';
|
|
9
10
|
import Cookies from 'js-cookie';
|
|
10
|
-
import { Storage } from 'aws-amplify';
|
|
11
11
|
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
12
12
|
import _createClass from '@babel/runtime/helpers/createClass';
|
|
13
13
|
import _inherits from '@babel/runtime/helpers/inherits';
|
|
@@ -49,75 +49,7 @@ var CoreConfig = {
|
|
|
49
49
|
defaultAllowComments: true,
|
|
50
50
|
makeApiKey: '',
|
|
51
51
|
logo: '',
|
|
52
|
-
clientName: ''
|
|
53
|
-
AuthStrategy: {
|
|
54
|
-
getAccessToken: function () {
|
|
55
|
-
var _getAccessToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
56
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
57
|
-
while (1) {
|
|
58
|
-
switch (_context.prev = _context.next) {
|
|
59
|
-
case 0:
|
|
60
|
-
return _context.abrupt("return", null);
|
|
61
|
-
|
|
62
|
-
case 1:
|
|
63
|
-
case "end":
|
|
64
|
-
return _context.stop();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}, _callee);
|
|
68
|
-
}));
|
|
69
|
-
|
|
70
|
-
function getAccessToken() {
|
|
71
|
-
return _getAccessToken.apply(this, arguments);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return getAccessToken;
|
|
75
|
-
}(),
|
|
76
|
-
getCurrentUserId: function () {
|
|
77
|
-
var _getCurrentUserId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
78
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
79
|
-
while (1) {
|
|
80
|
-
switch (_context2.prev = _context2.next) {
|
|
81
|
-
case 0:
|
|
82
|
-
return _context2.abrupt("return", null);
|
|
83
|
-
|
|
84
|
-
case 1:
|
|
85
|
-
case "end":
|
|
86
|
-
return _context2.stop();
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}, _callee2);
|
|
90
|
-
}));
|
|
91
|
-
|
|
92
|
-
function getCurrentUserId() {
|
|
93
|
-
return _getCurrentUserId.apply(this, arguments);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return getCurrentUserId;
|
|
97
|
-
}(),
|
|
98
|
-
hasActiveSession: function () {
|
|
99
|
-
var _hasActiveSession = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
100
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
101
|
-
while (1) {
|
|
102
|
-
switch (_context3.prev = _context3.next) {
|
|
103
|
-
case 0:
|
|
104
|
-
return _context3.abrupt("return", false);
|
|
105
|
-
|
|
106
|
-
case 1:
|
|
107
|
-
case "end":
|
|
108
|
-
return _context3.stop();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}, _callee3);
|
|
112
|
-
}));
|
|
113
|
-
|
|
114
|
-
function hasActiveSession() {
|
|
115
|
-
return _hasActiveSession.apply(this, arguments);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return hasActiveSession;
|
|
119
|
-
}()
|
|
120
|
-
}
|
|
52
|
+
clientName: ''
|
|
121
53
|
},
|
|
122
54
|
init: function init(environment) {
|
|
123
55
|
CoreConfig.env = environment;
|
|
@@ -126,28 +58,29 @@ var CoreConfig = {
|
|
|
126
58
|
|
|
127
59
|
var getSessionTokenAWS = /*#__PURE__*/function () {
|
|
128
60
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(prefix) {
|
|
129
|
-
var token;
|
|
61
|
+
var data, token;
|
|
130
62
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
131
63
|
while (1) {
|
|
132
64
|
switch (_context.prev = _context.next) {
|
|
133
65
|
case 0:
|
|
134
66
|
_context.next = 2;
|
|
135
|
-
return
|
|
67
|
+
return Auth.currentSession();
|
|
136
68
|
|
|
137
69
|
case 2:
|
|
138
|
-
|
|
70
|
+
data = _context.sent;
|
|
71
|
+
token = data.getAccessToken().getJwtToken();
|
|
139
72
|
|
|
140
73
|
if (!_.isUndefined(prefix)) {
|
|
141
|
-
_context.next =
|
|
74
|
+
_context.next = 6;
|
|
142
75
|
break;
|
|
143
76
|
}
|
|
144
77
|
|
|
145
78
|
return _context.abrupt("return", token);
|
|
146
79
|
|
|
147
|
-
case
|
|
80
|
+
case 6:
|
|
148
81
|
return _context.abrupt("return", "".concat(prefix, " ").concat(token));
|
|
149
82
|
|
|
150
|
-
case
|
|
83
|
+
case 7:
|
|
151
84
|
case "end":
|
|
152
85
|
return _context.stop();
|
|
153
86
|
}
|
|
@@ -207,28 +140,30 @@ var unauthedFunction = function unauthedFunction(request) {
|
|
|
207
140
|
};
|
|
208
141
|
var getCurrentUserSub = /*#__PURE__*/function () {
|
|
209
142
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
143
|
+
var user;
|
|
210
144
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
211
145
|
while (1) {
|
|
212
146
|
switch (_context3.prev = _context3.next) {
|
|
213
147
|
case 0:
|
|
214
148
|
_context3.prev = 0;
|
|
215
149
|
_context3.next = 3;
|
|
216
|
-
return
|
|
150
|
+
return Auth.currentUserInfo();
|
|
217
151
|
|
|
218
152
|
case 3:
|
|
219
|
-
|
|
153
|
+
user = _context3.sent;
|
|
154
|
+
return _context3.abrupt("return", user.id);
|
|
220
155
|
|
|
221
|
-
case
|
|
222
|
-
_context3.prev =
|
|
156
|
+
case 7:
|
|
157
|
+
_context3.prev = 7;
|
|
223
158
|
_context3.t0 = _context3["catch"](0);
|
|
224
159
|
return _context3.abrupt("return", null);
|
|
225
160
|
|
|
226
|
-
case
|
|
161
|
+
case 10:
|
|
227
162
|
case "end":
|
|
228
163
|
return _context3.stop();
|
|
229
164
|
}
|
|
230
165
|
}
|
|
231
|
-
}, _callee3, null, [[0,
|
|
166
|
+
}, _callee3, null, [[0, 7]]);
|
|
232
167
|
}));
|
|
233
168
|
|
|
234
169
|
return function getCurrentUserSub() {
|
|
@@ -237,19 +172,19 @@ var getCurrentUserSub = /*#__PURE__*/function () {
|
|
|
237
172
|
}();
|
|
238
173
|
var checkLoggedIn = /*#__PURE__*/function () {
|
|
239
174
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(self) {
|
|
240
|
-
var
|
|
175
|
+
var user;
|
|
241
176
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
242
177
|
while (1) {
|
|
243
178
|
switch (_context4.prev = _context4.next) {
|
|
244
179
|
case 0:
|
|
245
180
|
_context4.prev = 0;
|
|
246
181
|
_context4.next = 3;
|
|
247
|
-
return
|
|
182
|
+
return Auth.currentAuthenticatedUser();
|
|
248
183
|
|
|
249
184
|
case 3:
|
|
250
|
-
|
|
185
|
+
user = _context4.sent;
|
|
251
186
|
|
|
252
|
-
if (
|
|
187
|
+
if (_.isUndefined(user) || user == null || user.username == null) {
|
|
253
188
|
console.log('redirecting to login');
|
|
254
189
|
self.props.history.push('/login');
|
|
255
190
|
}
|
|
@@ -1681,34 +1616,31 @@ function CanvasImageUploader(options) {
|
|
|
1681
1616
|
var fileActions = {
|
|
1682
1617
|
uploadMediaAsync: function () {
|
|
1683
1618
|
var _uploadMediaAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(file, filename) {
|
|
1684
|
-
var newFilename,
|
|
1619
|
+
var newFilename, userId, url, _Config$env, baseUploadsUrl, uploadBucket;
|
|
1620
|
+
|
|
1685
1621
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
1686
1622
|
while (1) {
|
|
1687
1623
|
switch (_context.prev = _context.next) {
|
|
1688
1624
|
case 0:
|
|
1689
1625
|
newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
1690
1626
|
_context.next = 3;
|
|
1691
|
-
return
|
|
1692
|
-
method: 'GET',
|
|
1693
|
-
url: getUrl('media', 'get/presignedurl', {
|
|
1694
|
-
filename: newFilename
|
|
1695
|
-
})
|
|
1696
|
-
});
|
|
1627
|
+
return getCurrentUserSub();
|
|
1697
1628
|
|
|
1698
1629
|
case 3:
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1630
|
+
userId = _context.sent;
|
|
1631
|
+
url = "uploads/users/".concat(userId, "/public/").concat(randomString(), "/").concat(newFilename);
|
|
1632
|
+
_Config$env = CoreConfig.env, baseUploadsUrl = _Config$env.baseUploadsUrl, uploadBucket = _Config$env.uploadBucket;
|
|
1633
|
+
_context.next = 8;
|
|
1634
|
+
return Storage.put(url, file, {
|
|
1635
|
+
level: 'public',
|
|
1636
|
+
bucket: uploadBucket
|
|
1705
1637
|
});
|
|
1706
1638
|
|
|
1707
|
-
case 6:
|
|
1708
|
-
baseUploadsUrl = CoreConfig.env.baseUploadsUrl;
|
|
1709
|
-
return _context.abrupt("return", "".concat(baseUploadsUrl).concat(signedUrlRes.data.key));
|
|
1710
|
-
|
|
1711
1639
|
case 8:
|
|
1640
|
+
console.log('uploaded file', "".concat(baseUploadsUrl).concat(url));
|
|
1641
|
+
return _context.abrupt("return", "".concat(baseUploadsUrl).concat(url));
|
|
1642
|
+
|
|
1643
|
+
case 10:
|
|
1712
1644
|
case "end":
|
|
1713
1645
|
return _context.stop();
|
|
1714
1646
|
}
|
|
@@ -1722,15 +1654,6 @@ var fileActions = {
|
|
|
1722
1654
|
|
|
1723
1655
|
return uploadMediaAsync;
|
|
1724
1656
|
}(),
|
|
1725
|
-
// uploadMediaAsync: async (file, filename) => {
|
|
1726
|
-
// const newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
1727
|
-
// const userId = await getCurrentUserSub();
|
|
1728
|
-
// const url = `uploads/users/${userId}/public/${randomString()}/${newFilename}`;
|
|
1729
|
-
// const { baseUploadsUrl, uploadBucket } = Config.env;
|
|
1730
|
-
// await Storage.put(url, file, { level: 'public', bucket: uploadBucket });
|
|
1731
|
-
// console.log('uploaded file', `${baseUploadsUrl}${url}`);
|
|
1732
|
-
// return `${baseUploadsUrl}${url}`;
|
|
1733
|
-
// },
|
|
1734
1657
|
// readBase64: async (file) => {
|
|
1735
1658
|
// return new Promise((resolve, reject) => {
|
|
1736
1659
|
// var reader = new FileReader();
|
|
@@ -1744,14 +1667,6 @@ var fileActions = {
|
|
|
1744
1667
|
// };
|
|
1745
1668
|
// });
|
|
1746
1669
|
// },
|
|
1747
|
-
getPresignedUrl: function getPresignedUrl(filename) {
|
|
1748
|
-
return authedFunction({
|
|
1749
|
-
method: 'GET',
|
|
1750
|
-
url: getUrl('media', 'get/presignedurl', {
|
|
1751
|
-
filename: filename
|
|
1752
|
-
})
|
|
1753
|
-
});
|
|
1754
|
-
},
|
|
1755
1670
|
compressImage: function compressImage(file, maxSize, quality, noCompress) {
|
|
1756
1671
|
return new Promise(function (resolve, reject) {
|
|
1757
1672
|
if (noCompress) {
|
|
@@ -5245,7 +5160,9 @@ var mapStateToProps$5 = function mapStateToProps() {
|
|
|
5245
5160
|
return {};
|
|
5246
5161
|
};
|
|
5247
5162
|
|
|
5248
|
-
var FileInput = connect(mapStateToProps$5, {}, null, {
|
|
5163
|
+
var FileInput = connect(mapStateToProps$5, {}, null, {
|
|
5164
|
+
forwardRef: true
|
|
5165
|
+
})(FileInputComponent);
|
|
5249
5166
|
|
|
5250
5167
|
function ownKeys$e(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
5251
5168
|
|
|
@@ -6953,7 +6870,6 @@ var ImageInputComponent = /*#__PURE__*/function (_Component) {
|
|
|
6953
6870
|
value: function renderLibraryImage(image, index, allowDelete) {
|
|
6954
6871
|
var _this7 = this;
|
|
6955
6872
|
|
|
6956
|
-
console.log(image);
|
|
6957
6873
|
var classes = 'imageInput imageInput-hasImage imageInput-libraryImage';
|
|
6958
6874
|
|
|
6959
6875
|
if (image.Selected) {
|
|
@@ -7351,7 +7267,9 @@ var mapStateToProps$2 = function mapStateToProps(state) {
|
|
|
7351
7267
|
};
|
|
7352
7268
|
};
|
|
7353
7269
|
|
|
7354
|
-
var ImageInput = connect(mapStateToProps$2, {}, null, {
|
|
7270
|
+
var ImageInput = connect(mapStateToProps$2, {}, null, {
|
|
7271
|
+
forwardRef: true
|
|
7272
|
+
})(ImageInputComponent);
|
|
7355
7273
|
|
|
7356
7274
|
function _createSuper$m(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$m(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
7357
7275
|
|
|
@@ -9954,7 +9872,9 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9954
9872
|
|
|
9955
9873
|
var toExport = connect(null, {
|
|
9956
9874
|
setAuth: setAuth
|
|
9957
|
-
}, null, {
|
|
9875
|
+
}, null, {
|
|
9876
|
+
forwardRef: true
|
|
9877
|
+
})(AudienceSelector);
|
|
9958
9878
|
|
|
9959
9879
|
function _createSuper$5(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$5(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9960
9880
|
|
package/dist/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@babel/runtime/helpers/asyncToGenerator'), require('@babel/runtime/regenerator'), require('lodash'), require('axios'), require('@babel/runtime/helpers/defineProperty'), require('moment'), require('react'), require('jquery'), require('js-cookie'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '@babel/runtime/helpers/asyncToGenerator', '@babel/runtime/regenerator', 'lodash', 'axios', '@babel/runtime/helpers/defineProperty', 'moment', 'react', 'jquery', 'js-cookie', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['@plusscommunities/pluss-core-web'] = {}, global._asyncToGenerator, global._regeneratorRuntime, global._, global.axios, global._defineProperty, global.moment, global.React, global.$, global.Cookies, global.
|
|
5
|
-
}(this, (function (exports, _asyncToGenerator, _regeneratorRuntime, _, axios, _defineProperty, moment, React, $, Cookies,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@babel/runtime/helpers/asyncToGenerator'), require('@babel/runtime/regenerator'), require('lodash'), require('axios'), require('aws-amplify'), require('@babel/runtime/helpers/defineProperty'), require('moment'), require('react'), require('jquery'), require('js-cookie'), require('@babel/runtime/helpers/classCallCheck'), require('@babel/runtime/helpers/createClass'), require('@babel/runtime/helpers/inherits'), require('@babel/runtime/helpers/possibleConstructorReturn'), require('@babel/runtime/helpers/getPrototypeOf'), require('react-fontawesome'), require('@babel/runtime/helpers/extends'), require('@babel/runtime/helpers/assertThisInitialized'), require('react-redux'), require('react-textarea-autosize'), require('@babel/runtime/helpers/toConsumableArray'), require('@babel/runtime/helpers/typeof'), require('react-dropzone'), require('react-router'), require('react-bootstrap'), require('@fortawesome/react-fontawesome'), require('@crello/react-lottie'), require('react-csv'), require('@babel/runtime/helpers/objectWithoutProperties'), require('react-color'), require('tinycolor2'), require('react-router-dom'), require('@fortawesome/free-solid-svg-icons')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@babel/runtime/helpers/asyncToGenerator', '@babel/runtime/regenerator', 'lodash', 'axios', 'aws-amplify', '@babel/runtime/helpers/defineProperty', 'moment', 'react', 'jquery', 'js-cookie', '@babel/runtime/helpers/classCallCheck', '@babel/runtime/helpers/createClass', '@babel/runtime/helpers/inherits', '@babel/runtime/helpers/possibleConstructorReturn', '@babel/runtime/helpers/getPrototypeOf', 'react-fontawesome', '@babel/runtime/helpers/extends', '@babel/runtime/helpers/assertThisInitialized', 'react-redux', 'react-textarea-autosize', '@babel/runtime/helpers/toConsumableArray', '@babel/runtime/helpers/typeof', 'react-dropzone', 'react-router', 'react-bootstrap', '@fortawesome/react-fontawesome', '@crello/react-lottie', 'react-csv', '@babel/runtime/helpers/objectWithoutProperties', 'react-color', 'tinycolor2', 'react-router-dom', '@fortawesome/free-solid-svg-icons'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['@plusscommunities/pluss-core-web'] = {}, global._asyncToGenerator, global._regeneratorRuntime, global._, global.axios, global.awsAmplify, global._defineProperty, global.moment, global.React, global.$, global.Cookies, global._classCallCheck, global._createClass, global._inherits, global._possibleConstructorReturn, global._getPrototypeOf, global.FontAwesome, global._extends, global._assertThisInitialized, global.reactRedux, global.Textarea, global._toConsumableArray, global._typeof, global.Dropzone, global.reactRouter, global.reactBootstrap, global.reactFontawesome, global.reactLottie, global.reactCsv, global._objectWithoutProperties, global.reactColor, global.tinycolor, global.reactRouterDom, global.freeSolidSvgIcons));
|
|
5
|
+
}(this, (function (exports, _asyncToGenerator, _regeneratorRuntime, _, axios, awsAmplify, _defineProperty, moment, React, $, Cookies, _classCallCheck, _createClass, _inherits, _possibleConstructorReturn, _getPrototypeOf, FontAwesome, _extends, _assertThisInitialized, reactRedux, Textarea, _toConsumableArray, _typeof, Dropzone, reactRouter, reactBootstrap, reactFontawesome, reactLottie, reactCsv, _objectWithoutProperties, reactColor, tinycolor, reactRouterDom, freeSolidSvgIcons) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -47,75 +47,7 @@
|
|
|
47
47
|
defaultAllowComments: true,
|
|
48
48
|
makeApiKey: '',
|
|
49
49
|
logo: '',
|
|
50
|
-
clientName: ''
|
|
51
|
-
AuthStrategy: {
|
|
52
|
-
getAccessToken: function () {
|
|
53
|
-
var _getAccessToken = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
|
|
54
|
-
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
55
|
-
while (1) {
|
|
56
|
-
switch (_context.prev = _context.next) {
|
|
57
|
-
case 0:
|
|
58
|
-
return _context.abrupt("return", null);
|
|
59
|
-
|
|
60
|
-
case 1:
|
|
61
|
-
case "end":
|
|
62
|
-
return _context.stop();
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}, _callee);
|
|
66
|
-
}));
|
|
67
|
-
|
|
68
|
-
function getAccessToken() {
|
|
69
|
-
return _getAccessToken.apply(this, arguments);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return getAccessToken;
|
|
73
|
-
}(),
|
|
74
|
-
getCurrentUserId: function () {
|
|
75
|
-
var _getCurrentUserId = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2() {
|
|
76
|
-
return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
|
|
77
|
-
while (1) {
|
|
78
|
-
switch (_context2.prev = _context2.next) {
|
|
79
|
-
case 0:
|
|
80
|
-
return _context2.abrupt("return", null);
|
|
81
|
-
|
|
82
|
-
case 1:
|
|
83
|
-
case "end":
|
|
84
|
-
return _context2.stop();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}, _callee2);
|
|
88
|
-
}));
|
|
89
|
-
|
|
90
|
-
function getCurrentUserId() {
|
|
91
|
-
return _getCurrentUserId.apply(this, arguments);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return getCurrentUserId;
|
|
95
|
-
}(),
|
|
96
|
-
hasActiveSession: function () {
|
|
97
|
-
var _hasActiveSession = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3() {
|
|
98
|
-
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
|
99
|
-
while (1) {
|
|
100
|
-
switch (_context3.prev = _context3.next) {
|
|
101
|
-
case 0:
|
|
102
|
-
return _context3.abrupt("return", false);
|
|
103
|
-
|
|
104
|
-
case 1:
|
|
105
|
-
case "end":
|
|
106
|
-
return _context3.stop();
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}, _callee3);
|
|
110
|
-
}));
|
|
111
|
-
|
|
112
|
-
function hasActiveSession() {
|
|
113
|
-
return _hasActiveSession.apply(this, arguments);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return hasActiveSession;
|
|
117
|
-
}()
|
|
118
|
-
}
|
|
50
|
+
clientName: ''
|
|
119
51
|
},
|
|
120
52
|
init: function init(environment) {
|
|
121
53
|
CoreConfig.env = environment;
|
|
@@ -124,28 +56,29 @@
|
|
|
124
56
|
|
|
125
57
|
var getSessionTokenAWS = /*#__PURE__*/function () {
|
|
126
58
|
var _ref = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(prefix) {
|
|
127
|
-
var token;
|
|
59
|
+
var data, token;
|
|
128
60
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
129
61
|
while (1) {
|
|
130
62
|
switch (_context.prev = _context.next) {
|
|
131
63
|
case 0:
|
|
132
64
|
_context.next = 2;
|
|
133
|
-
return
|
|
65
|
+
return awsAmplify.Auth.currentSession();
|
|
134
66
|
|
|
135
67
|
case 2:
|
|
136
|
-
|
|
68
|
+
data = _context.sent;
|
|
69
|
+
token = data.getAccessToken().getJwtToken();
|
|
137
70
|
|
|
138
71
|
if (!___default['default'].isUndefined(prefix)) {
|
|
139
|
-
_context.next =
|
|
72
|
+
_context.next = 6;
|
|
140
73
|
break;
|
|
141
74
|
}
|
|
142
75
|
|
|
143
76
|
return _context.abrupt("return", token);
|
|
144
77
|
|
|
145
|
-
case
|
|
78
|
+
case 6:
|
|
146
79
|
return _context.abrupt("return", "".concat(prefix, " ").concat(token));
|
|
147
80
|
|
|
148
|
-
case
|
|
81
|
+
case 7:
|
|
149
82
|
case "end":
|
|
150
83
|
return _context.stop();
|
|
151
84
|
}
|
|
@@ -205,28 +138,30 @@
|
|
|
205
138
|
};
|
|
206
139
|
var getCurrentUserSub = /*#__PURE__*/function () {
|
|
207
140
|
var _ref3 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3() {
|
|
141
|
+
var user;
|
|
208
142
|
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
|
209
143
|
while (1) {
|
|
210
144
|
switch (_context3.prev = _context3.next) {
|
|
211
145
|
case 0:
|
|
212
146
|
_context3.prev = 0;
|
|
213
147
|
_context3.next = 3;
|
|
214
|
-
return
|
|
148
|
+
return awsAmplify.Auth.currentUserInfo();
|
|
215
149
|
|
|
216
150
|
case 3:
|
|
217
|
-
|
|
151
|
+
user = _context3.sent;
|
|
152
|
+
return _context3.abrupt("return", user.id);
|
|
218
153
|
|
|
219
|
-
case
|
|
220
|
-
_context3.prev =
|
|
154
|
+
case 7:
|
|
155
|
+
_context3.prev = 7;
|
|
221
156
|
_context3.t0 = _context3["catch"](0);
|
|
222
157
|
return _context3.abrupt("return", null);
|
|
223
158
|
|
|
224
|
-
case
|
|
159
|
+
case 10:
|
|
225
160
|
case "end":
|
|
226
161
|
return _context3.stop();
|
|
227
162
|
}
|
|
228
163
|
}
|
|
229
|
-
}, _callee3, null, [[0,
|
|
164
|
+
}, _callee3, null, [[0, 7]]);
|
|
230
165
|
}));
|
|
231
166
|
|
|
232
167
|
return function getCurrentUserSub() {
|
|
@@ -235,19 +170,19 @@
|
|
|
235
170
|
}();
|
|
236
171
|
var checkLoggedIn = /*#__PURE__*/function () {
|
|
237
172
|
var _ref4 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4(self) {
|
|
238
|
-
var
|
|
173
|
+
var user;
|
|
239
174
|
return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
|
|
240
175
|
while (1) {
|
|
241
176
|
switch (_context4.prev = _context4.next) {
|
|
242
177
|
case 0:
|
|
243
178
|
_context4.prev = 0;
|
|
244
179
|
_context4.next = 3;
|
|
245
|
-
return
|
|
180
|
+
return awsAmplify.Auth.currentAuthenticatedUser();
|
|
246
181
|
|
|
247
182
|
case 3:
|
|
248
|
-
|
|
183
|
+
user = _context4.sent;
|
|
249
184
|
|
|
250
|
-
if (
|
|
185
|
+
if (___default['default'].isUndefined(user) || user == null || user.username == null) {
|
|
251
186
|
console.log('redirecting to login');
|
|
252
187
|
self.props.history.push('/login');
|
|
253
188
|
}
|
|
@@ -1679,34 +1614,31 @@
|
|
|
1679
1614
|
var fileActions = {
|
|
1680
1615
|
uploadMediaAsync: function () {
|
|
1681
1616
|
var _uploadMediaAsync = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(file, filename) {
|
|
1682
|
-
var newFilename,
|
|
1617
|
+
var newFilename, userId, url, _Config$env, baseUploadsUrl, uploadBucket;
|
|
1618
|
+
|
|
1683
1619
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
1684
1620
|
while (1) {
|
|
1685
1621
|
switch (_context.prev = _context.next) {
|
|
1686
1622
|
case 0:
|
|
1687
1623
|
newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
1688
1624
|
_context.next = 3;
|
|
1689
|
-
return
|
|
1690
|
-
method: 'GET',
|
|
1691
|
-
url: getUrl('media', 'get/presignedurl', {
|
|
1692
|
-
filename: newFilename
|
|
1693
|
-
})
|
|
1694
|
-
});
|
|
1625
|
+
return getCurrentUserSub();
|
|
1695
1626
|
|
|
1696
1627
|
case 3:
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1628
|
+
userId = _context.sent;
|
|
1629
|
+
url = "uploads/users/".concat(userId, "/public/").concat(randomString(), "/").concat(newFilename);
|
|
1630
|
+
_Config$env = CoreConfig.env, baseUploadsUrl = _Config$env.baseUploadsUrl, uploadBucket = _Config$env.uploadBucket;
|
|
1631
|
+
_context.next = 8;
|
|
1632
|
+
return awsAmplify.Storage.put(url, file, {
|
|
1633
|
+
level: 'public',
|
|
1634
|
+
bucket: uploadBucket
|
|
1703
1635
|
});
|
|
1704
1636
|
|
|
1705
|
-
case 6:
|
|
1706
|
-
baseUploadsUrl = CoreConfig.env.baseUploadsUrl;
|
|
1707
|
-
return _context.abrupt("return", "".concat(baseUploadsUrl).concat(signedUrlRes.data.key));
|
|
1708
|
-
|
|
1709
1637
|
case 8:
|
|
1638
|
+
console.log('uploaded file', "".concat(baseUploadsUrl).concat(url));
|
|
1639
|
+
return _context.abrupt("return", "".concat(baseUploadsUrl).concat(url));
|
|
1640
|
+
|
|
1641
|
+
case 10:
|
|
1710
1642
|
case "end":
|
|
1711
1643
|
return _context.stop();
|
|
1712
1644
|
}
|
|
@@ -1720,15 +1652,6 @@
|
|
|
1720
1652
|
|
|
1721
1653
|
return uploadMediaAsync;
|
|
1722
1654
|
}(),
|
|
1723
|
-
// uploadMediaAsync: async (file, filename) => {
|
|
1724
|
-
// const newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
1725
|
-
// const userId = await getCurrentUserSub();
|
|
1726
|
-
// const url = `uploads/users/${userId}/public/${randomString()}/${newFilename}`;
|
|
1727
|
-
// const { baseUploadsUrl, uploadBucket } = Config.env;
|
|
1728
|
-
// await Storage.put(url, file, { level: 'public', bucket: uploadBucket });
|
|
1729
|
-
// console.log('uploaded file', `${baseUploadsUrl}${url}`);
|
|
1730
|
-
// return `${baseUploadsUrl}${url}`;
|
|
1731
|
-
// },
|
|
1732
1655
|
// readBase64: async (file) => {
|
|
1733
1656
|
// return new Promise((resolve, reject) => {
|
|
1734
1657
|
// var reader = new FileReader();
|
|
@@ -1742,14 +1665,6 @@
|
|
|
1742
1665
|
// };
|
|
1743
1666
|
// });
|
|
1744
1667
|
// },
|
|
1745
|
-
getPresignedUrl: function getPresignedUrl(filename) {
|
|
1746
|
-
return authedFunction({
|
|
1747
|
-
method: 'GET',
|
|
1748
|
-
url: getUrl('media', 'get/presignedurl', {
|
|
1749
|
-
filename: filename
|
|
1750
|
-
})
|
|
1751
|
-
});
|
|
1752
|
-
},
|
|
1753
1668
|
compressImage: function compressImage(file, maxSize, quality, noCompress) {
|
|
1754
1669
|
return new Promise(function (resolve, reject) {
|
|
1755
1670
|
if (noCompress) {
|
|
@@ -5243,7 +5158,9 @@
|
|
|
5243
5158
|
return {};
|
|
5244
5159
|
};
|
|
5245
5160
|
|
|
5246
|
-
var FileInput = reactRedux.connect(mapStateToProps$5, {}, null, {
|
|
5161
|
+
var FileInput = reactRedux.connect(mapStateToProps$5, {}, null, {
|
|
5162
|
+
forwardRef: true
|
|
5163
|
+
})(FileInputComponent);
|
|
5247
5164
|
|
|
5248
5165
|
function ownKeys$e(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
5249
5166
|
|
|
@@ -6951,7 +6868,6 @@
|
|
|
6951
6868
|
value: function renderLibraryImage(image, index, allowDelete) {
|
|
6952
6869
|
var _this7 = this;
|
|
6953
6870
|
|
|
6954
|
-
console.log(image);
|
|
6955
6871
|
var classes = 'imageInput imageInput-hasImage imageInput-libraryImage';
|
|
6956
6872
|
|
|
6957
6873
|
if (image.Selected) {
|
|
@@ -7349,7 +7265,9 @@
|
|
|
7349
7265
|
};
|
|
7350
7266
|
};
|
|
7351
7267
|
|
|
7352
|
-
var ImageInput = reactRedux.connect(mapStateToProps$2, {}, null, {
|
|
7268
|
+
var ImageInput = reactRedux.connect(mapStateToProps$2, {}, null, {
|
|
7269
|
+
forwardRef: true
|
|
7270
|
+
})(ImageInputComponent);
|
|
7353
7271
|
|
|
7354
7272
|
function _createSuper$m(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$m(); return function _createSuperInternal() { var Super = _getPrototypeOf__default['default'](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default['default'](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default['default'](this, result); }; }
|
|
7355
7273
|
|
|
@@ -9952,7 +9870,9 @@
|
|
|
9952
9870
|
|
|
9953
9871
|
var toExport = reactRedux.connect(null, {
|
|
9954
9872
|
setAuth: setAuth
|
|
9955
|
-
}, null, {
|
|
9873
|
+
}, null, {
|
|
9874
|
+
forwardRef: true
|
|
9875
|
+
})(AudienceSelector);
|
|
9956
9876
|
|
|
9957
9877
|
function _createSuper$5(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$5(); return function _createSuperInternal() { var Super = _getPrototypeOf__default['default'](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default['default'](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default['default'](this, result); }; }
|
|
9958
9878
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plusscommunities/pluss-core-web",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.33-beta.0",
|
|
4
4
|
"description": "Core extension package for Pluss Communities platform",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"scripts": {
|
|
@@ -9,9 +9,6 @@
|
|
|
9
9
|
"patch": "npm version patch",
|
|
10
10
|
"betaupload": "npm run build && npm publish --access public --tag beta && rm -rf node_modules",
|
|
11
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
12
|
"upload": "npm run build && npm publish --access public && rm -rf node_modules",
|
|
16
13
|
"upload:p": "npm run patch && npm run upload"
|
|
17
14
|
},
|
|
@@ -31,9 +28,7 @@
|
|
|
31
28
|
"rollup-plugin-styles": "^3.14.1"
|
|
32
29
|
},
|
|
33
30
|
"dependencies": {
|
|
34
|
-
"@babel/runtime": "^7.14.0"
|
|
35
|
-
},
|
|
36
|
-
"peerDependencies": {
|
|
31
|
+
"@babel/runtime": "^7.14.0",
|
|
37
32
|
"@fortawesome/fontawesome-svg-core": "^6.4.0",
|
|
38
33
|
"@fortawesome/free-solid-svg-icons": "^6.4.0",
|
|
39
34
|
"@fortawesome/react-fontawesome": "^0.2.0",
|
|
@@ -44,9 +39,11 @@
|
|
|
44
39
|
"react": "^16.14.0",
|
|
45
40
|
"react-dropzone": "^14.2.3",
|
|
46
41
|
"react-fontawesome": "^1.6.1",
|
|
47
|
-
"react-redux": "^7.2.9",
|
|
48
42
|
"react-router-dom": "^4.2.2",
|
|
49
43
|
"react-textarea-autosize": "^7.1.0-1"
|
|
50
44
|
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"react-redux": "^7.2.9"
|
|
47
|
+
},
|
|
51
48
|
"keywords": []
|
|
52
49
|
}
|
package/src/apis/fileActions.js
CHANGED
|
@@ -4,33 +4,18 @@ 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';
|
|
8
7
|
|
|
9
8
|
export const fileActions = {
|
|
10
9
|
uploadMediaAsync: async (file, filename) => {
|
|
11
10
|
const newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
url: getUrl('media', 'get/presignedurl', { filename: newFilename }),
|
|
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}`;
|
|
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}`;
|
|
11
|
+
const userId = await getCurrentUserSub();
|
|
12
|
+
const url = `uploads/users/${userId}/public/${randomString()}/${newFilename}`;
|
|
28
13
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
14
|
+
const { baseUploadsUrl, uploadBucket } = Config.env;
|
|
15
|
+
await Storage.put(url, file, { level: 'public', bucket: uploadBucket });
|
|
16
|
+
console.log('uploaded file', `${baseUploadsUrl}${url}`);
|
|
17
|
+
return `${baseUploadsUrl}${url}`;
|
|
18
|
+
},
|
|
34
19
|
|
|
35
20
|
// readBase64: async (file) => {
|
|
36
21
|
// return new Promise((resolve, reject) => {
|
|
@@ -45,12 +30,6 @@ export const fileActions = {
|
|
|
45
30
|
// };
|
|
46
31
|
// });
|
|
47
32
|
// },
|
|
48
|
-
getPresignedUrl: (filename) => {
|
|
49
|
-
return authedFunction({
|
|
50
|
-
method: 'GET',
|
|
51
|
-
url: getUrl('media', 'get/presignedurl', { filename }),
|
|
52
|
-
});
|
|
53
|
-
},
|
|
54
33
|
compressImage: (file, maxSize, quality, noCompress) => {
|
|
55
34
|
return new Promise((resolve, reject) => {
|
|
56
35
|
if (noCompress) {
|
|
@@ -647,6 +647,6 @@ class AudienceSelector extends Component {
|
|
|
647
647
|
}
|
|
648
648
|
}
|
|
649
649
|
|
|
650
|
-
const toExport = connect(null, { setAuth }, null, {})(AudienceSelector);
|
|
650
|
+
const toExport = connect(null, { setAuth }, null, { forwardRef: true })(AudienceSelector);
|
|
651
651
|
|
|
652
652
|
export { toExport as AudienceSelector };
|
|
@@ -329,5 +329,5 @@ const mapStateToProps = () => {
|
|
|
329
329
|
return {};
|
|
330
330
|
};
|
|
331
331
|
|
|
332
|
-
const FileInput = connect(mapStateToProps, {}, null, {})(FileInputComponent);
|
|
332
|
+
const FileInput = connect(mapStateToProps, {}, null, { forwardRef: true })(FileInputComponent);
|
|
333
333
|
export { FileInput };
|
|
@@ -626,7 +626,6 @@ class ImageInputComponent extends Component {
|
|
|
626
626
|
}
|
|
627
627
|
|
|
628
628
|
renderLibraryImage(image, index, allowDelete) {
|
|
629
|
-
console.log(image);
|
|
630
629
|
let classes = 'imageInput imageInput-hasImage imageInput-libraryImage';
|
|
631
630
|
if (image.Selected) {
|
|
632
631
|
classes += ' imageInput-librarySelected';
|
|
@@ -984,5 +983,5 @@ const mapStateToProps = (state) => {
|
|
|
984
983
|
};
|
|
985
984
|
};
|
|
986
985
|
|
|
987
|
-
const ImageInput = connect(mapStateToProps, {}, null, {})(ImageInputComponent);
|
|
986
|
+
const ImageInput = connect(mapStateToProps, {}, null, { forwardRef: true })(ImageInputComponent);
|
|
988
987
|
export { ImageInput };
|
package/src/config.js
CHANGED
|
@@ -16,11 +16,6 @@ const CoreConfig = {
|
|
|
16
16
|
makeApiKey: '',
|
|
17
17
|
logo: '',
|
|
18
18
|
clientName: '',
|
|
19
|
-
AuthStrategy: {
|
|
20
|
-
getAccessToken: async () => null,
|
|
21
|
-
getCurrentUserId: async () => null,
|
|
22
|
-
hasActiveSession: async () => false,
|
|
23
|
-
},
|
|
24
19
|
},
|
|
25
20
|
init: (environment) => {
|
|
26
21
|
CoreConfig.env = environment;
|
package/src/session.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import axios from 'axios';
|
|
3
|
-
import
|
|
3
|
+
import { Auth } from 'aws-amplify';
|
|
4
4
|
|
|
5
5
|
export const getSessionTokenAWS = async (prefix) => {
|
|
6
|
-
const
|
|
6
|
+
const data = await Auth.currentSession();
|
|
7
|
+
const token = data.getAccessToken().getJwtToken();
|
|
7
8
|
if (_.isUndefined(prefix)) return token;
|
|
8
9
|
return `${prefix} ${token}`;
|
|
9
10
|
};
|
|
11
|
+
|
|
10
12
|
// export const getRefreshTokenAWS = async () => {
|
|
11
13
|
// const data = await Auth.currentSession();
|
|
12
14
|
// return data.getRefreshToken().token;
|
|
@@ -32,7 +34,8 @@ export const unauthedFunction = (request) => {
|
|
|
32
34
|
|
|
33
35
|
export const getCurrentUserSub = async () => {
|
|
34
36
|
try {
|
|
35
|
-
|
|
37
|
+
const user = await Auth.currentUserInfo();
|
|
38
|
+
return user.id;
|
|
36
39
|
} catch (error) {
|
|
37
40
|
return null;
|
|
38
41
|
}
|
|
@@ -40,8 +43,8 @@ export const getCurrentUserSub = async () => {
|
|
|
40
43
|
|
|
41
44
|
export const checkLoggedIn = async (self) => {
|
|
42
45
|
try {
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
46
|
+
const user = await Auth.currentAuthenticatedUser();
|
|
47
|
+
if (_.isUndefined(user) || user == null || user.username == null) {
|
|
45
48
|
console.log('redirecting to login');
|
|
46
49
|
self.props.history.push('/login');
|
|
47
50
|
}
|