@plusscommunities/pluss-core-web 1.4.34-auth.0 → 1.4.34
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 +73 -129
- package/dist/index.esm.js +73 -129
- package/dist/index.umd.js +76 -132
- package/package.json +3 -8
- package/src/apis/fileActions.js +7 -28
- package/src/components/AudienceSelector.js +1 -1
- package/src/components/Comment.js +16 -1
- package/src/components/FileInput.js +1 -1
- package/src/components/ImageInput.js +2 -1
- package/src/config.js +0 -5
- package/src/helper/files/get1400.js +4 -0
- package/src/helper/files/getThumb300.js +4 -0
- 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
|
}
|
|
@@ -798,11 +733,20 @@ var getExtension = function getExtension(url) {
|
|
|
798
733
|
return fileSplit[fileSplit.length - 1].toLowerCase();
|
|
799
734
|
};
|
|
800
735
|
|
|
736
|
+
var isVideo = function isVideo(url) {
|
|
737
|
+
var extension = getExtension(url);
|
|
738
|
+
return ['mov', 'mp4'].includes(extension);
|
|
739
|
+
};
|
|
740
|
+
|
|
801
741
|
var get1400 = function get1400(url) {
|
|
802
742
|
if (!url) {
|
|
803
743
|
return url;
|
|
804
744
|
}
|
|
805
745
|
|
|
746
|
+
if (isVideo(url)) {
|
|
747
|
+
return 'https://pluss60-demo-uploads.s3.ap-southeast-2.amazonaws.com/uploads/users/ap-southeast-2:97769b56-25ec-41c0-a73c-6c2c4140f629/public/9d0bbec64614b1ed654a03f7e7/movie.jpg';
|
|
748
|
+
}
|
|
749
|
+
|
|
806
750
|
if (url.indexOf('https://plussprdstorage.blob.core.windows.net/') !== -1) {
|
|
807
751
|
return url.replace('https://plussprdstorage.blob.core.windows.net/', 'https://plusscdn.azureedge.net/');
|
|
808
752
|
}
|
|
@@ -858,6 +802,10 @@ var getThumb300 = function getThumb300(url) {
|
|
|
858
802
|
return url;
|
|
859
803
|
}
|
|
860
804
|
|
|
805
|
+
if (isVideo(url)) {
|
|
806
|
+
return 'https://pluss60-demo-uploads.s3.ap-southeast-2.amazonaws.com/uploads/users/ap-southeast-2:97769b56-25ec-41c0-a73c-6c2c4140f629/public/9d0bbec64614b1ed654a03f7e7/movie.jpg';
|
|
807
|
+
}
|
|
808
|
+
|
|
861
809
|
if (url.indexOf('https://plussprdstorage.blob.core.windows.net/') !== -1) {
|
|
862
810
|
return url.replace('https://plussprdstorage.blob.core.windows.net/', 'https://plusscdn.azureedge.net/');
|
|
863
811
|
}
|
|
@@ -884,11 +832,6 @@ var getThumb300 = function getThumb300(url) {
|
|
|
884
832
|
return url;
|
|
885
833
|
};
|
|
886
834
|
|
|
887
|
-
var isVideo = function isVideo(url) {
|
|
888
|
-
var extension = getExtension(url);
|
|
889
|
-
return ['mov', 'mp4'].includes(extension);
|
|
890
|
-
};
|
|
891
|
-
|
|
892
835
|
var getFirstName = function getFirstName(string) {
|
|
893
836
|
if (___default['default'].isEmpty(string)) {
|
|
894
837
|
return '';
|
|
@@ -1711,34 +1654,31 @@ function CanvasImageUploader(options) {
|
|
|
1711
1654
|
var fileActions = {
|
|
1712
1655
|
uploadMediaAsync: function () {
|
|
1713
1656
|
var _uploadMediaAsync = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(file, filename) {
|
|
1714
|
-
var newFilename,
|
|
1657
|
+
var newFilename, userId, url, _Config$env, baseUploadsUrl, uploadBucket;
|
|
1658
|
+
|
|
1715
1659
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
1716
1660
|
while (1) {
|
|
1717
1661
|
switch (_context.prev = _context.next) {
|
|
1718
1662
|
case 0:
|
|
1719
1663
|
newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
1720
1664
|
_context.next = 3;
|
|
1721
|
-
return
|
|
1722
|
-
method: 'GET',
|
|
1723
|
-
url: getUrl('media', 'get/presignedurl', {
|
|
1724
|
-
filename: newFilename
|
|
1725
|
-
})
|
|
1726
|
-
});
|
|
1665
|
+
return getCurrentUserSub();
|
|
1727
1666
|
|
|
1728
1667
|
case 3:
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1668
|
+
userId = _context.sent;
|
|
1669
|
+
url = "uploads/users/".concat(userId, "/public/").concat(randomString(), "/").concat(newFilename);
|
|
1670
|
+
_Config$env = CoreConfig.env, baseUploadsUrl = _Config$env.baseUploadsUrl, uploadBucket = _Config$env.uploadBucket;
|
|
1671
|
+
_context.next = 8;
|
|
1672
|
+
return awsAmplify.Storage.put(url, file, {
|
|
1673
|
+
level: 'public',
|
|
1674
|
+
bucket: uploadBucket
|
|
1735
1675
|
});
|
|
1736
1676
|
|
|
1737
|
-
case 6:
|
|
1738
|
-
baseUploadsUrl = CoreConfig.env.baseUploadsUrl;
|
|
1739
|
-
return _context.abrupt("return", "".concat(baseUploadsUrl).concat(signedUrlRes.data.key));
|
|
1740
|
-
|
|
1741
1677
|
case 8:
|
|
1678
|
+
console.log('uploaded file', "".concat(baseUploadsUrl).concat(url));
|
|
1679
|
+
return _context.abrupt("return", "".concat(baseUploadsUrl).concat(url));
|
|
1680
|
+
|
|
1681
|
+
case 10:
|
|
1742
1682
|
case "end":
|
|
1743
1683
|
return _context.stop();
|
|
1744
1684
|
}
|
|
@@ -1752,15 +1692,6 @@ var fileActions = {
|
|
|
1752
1692
|
|
|
1753
1693
|
return uploadMediaAsync;
|
|
1754
1694
|
}(),
|
|
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
1695
|
// readBase64: async (file) => {
|
|
1765
1696
|
// return new Promise((resolve, reject) => {
|
|
1766
1697
|
// var reader = new FileReader();
|
|
@@ -1774,14 +1705,6 @@ var fileActions = {
|
|
|
1774
1705
|
// };
|
|
1775
1706
|
// });
|
|
1776
1707
|
// },
|
|
1777
|
-
getPresignedUrl: function getPresignedUrl(filename) {
|
|
1778
|
-
return authedFunction({
|
|
1779
|
-
method: 'GET',
|
|
1780
|
-
url: getUrl('media', 'get/presignedurl', {
|
|
1781
|
-
filename: filename
|
|
1782
|
-
})
|
|
1783
|
-
});
|
|
1784
|
-
},
|
|
1785
1708
|
compressImage: function compressImage(file, maxSize, quality, noCompress) {
|
|
1786
1709
|
return new Promise(function (resolve, reject) {
|
|
1787
1710
|
if (noCompress) {
|
|
@@ -4228,6 +4151,26 @@ var Comment = /*#__PURE__*/function (_Component) {
|
|
|
4228
4151
|
}
|
|
4229
4152
|
|
|
4230
4153
|
_createClass__default['default'](Comment, [{
|
|
4154
|
+
key: "renderImage",
|
|
4155
|
+
value: function renderImage(image) {
|
|
4156
|
+
if (___default['default'].isEmpty(image)) {
|
|
4157
|
+
return null;
|
|
4158
|
+
}
|
|
4159
|
+
|
|
4160
|
+
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
4161
|
+
className: "imageGrid"
|
|
4162
|
+
}, /*#__PURE__*/React__default['default'].createElement("a", {
|
|
4163
|
+
href: image,
|
|
4164
|
+
target: "_blank",
|
|
4165
|
+
rel: "noopener noreferrer"
|
|
4166
|
+
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
4167
|
+
className: "imageGrid_image",
|
|
4168
|
+
style: {
|
|
4169
|
+
backgroundImage: "url('".concat(get1400(image), "')")
|
|
4170
|
+
}
|
|
4171
|
+
})));
|
|
4172
|
+
}
|
|
4173
|
+
}, {
|
|
4231
4174
|
key: "renderComment",
|
|
4232
4175
|
value: function renderComment() {
|
|
4233
4176
|
var comment = this.props.comment;
|
|
@@ -4236,7 +4179,7 @@ var Comment = /*#__PURE__*/function (_Component) {
|
|
|
4236
4179
|
className: "comment"
|
|
4237
4180
|
}, /*#__PURE__*/React__default['default'].createElement("p", {
|
|
4238
4181
|
className: "comment_text"
|
|
4239
|
-
}, toParagraphed(comment.Comment)), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
4182
|
+
}, toParagraphed(comment.Comment)), this.renderImage(comment.Image), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
4240
4183
|
className: "comment_bottom"
|
|
4241
4184
|
}, /*#__PURE__*/React__default['default'].createElement(ProfilePic, {
|
|
4242
4185
|
className: "comment_profilePic",
|
|
@@ -5276,7 +5219,7 @@ var mapStateToProps$5 = function mapStateToProps() {
|
|
|
5276
5219
|
};
|
|
5277
5220
|
|
|
5278
5221
|
var FileInput = reactRedux.connect(mapStateToProps$5, {}, null, {
|
|
5279
|
-
|
|
5222
|
+
withRef: true
|
|
5280
5223
|
})(FileInputComponent);
|
|
5281
5224
|
|
|
5282
5225
|
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; }
|
|
@@ -6985,6 +6928,7 @@ var ImageInputComponent = /*#__PURE__*/function (_Component) {
|
|
|
6985
6928
|
value: function renderLibraryImage(image, index, allowDelete) {
|
|
6986
6929
|
var _this7 = this;
|
|
6987
6930
|
|
|
6931
|
+
console.log(image);
|
|
6988
6932
|
var classes = 'imageInput imageInput-hasImage imageInput-libraryImage';
|
|
6989
6933
|
|
|
6990
6934
|
if (image.Selected) {
|
|
@@ -7383,7 +7327,7 @@ var mapStateToProps$2 = function mapStateToProps(state) {
|
|
|
7383
7327
|
};
|
|
7384
7328
|
|
|
7385
7329
|
var ImageInput = reactRedux.connect(mapStateToProps$2, {}, null, {
|
|
7386
|
-
|
|
7330
|
+
withRef: true
|
|
7387
7331
|
})(ImageInputComponent);
|
|
7388
7332
|
|
|
7389
7333
|
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); }; }
|
|
@@ -9988,7 +9932,7 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9988
9932
|
var toExport = reactRedux.connect(null, {
|
|
9989
9933
|
setAuth: setAuth
|
|
9990
9934
|
}, null, {
|
|
9991
|
-
|
|
9935
|
+
withRef: true
|
|
9992
9936
|
})(AudienceSelector);
|
|
9993
9937
|
|
|
9994
9938
|
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); }; }
|