@plusscommunities/pluss-core-web 1.6.7 → 1.6.9-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 +124 -38
- package/dist/index.esm.js +124 -38
- package/dist/index.umd.js +127 -41
- package/package.json +5 -2
- package/src/apis/fileActions.js +28 -7
- package/src/components/AudienceSelector.js +1 -1
- package/src/components/FileInput.js +1 -1
- package/src/components/ImageInput.js +1 -1
- package/src/config.js +5 -0
- package/src/session.js +5 -8
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');
|
|
10
9
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
11
10
|
var moment = require('moment');
|
|
12
11
|
var React = require('react');
|
|
13
12
|
var $ = require('jquery');
|
|
14
13
|
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,7 +79,75 @@ var CoreConfig = {
|
|
|
79
79
|
defaultAllowComments: true,
|
|
80
80
|
makeApiKey: '',
|
|
81
81
|
logo: '',
|
|
82
|
-
clientName: ''
|
|
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
|
+
}
|
|
83
151
|
},
|
|
84
152
|
init: function init(environment) {
|
|
85
153
|
CoreConfig.env = environment;
|
|
@@ -88,29 +156,28 @@ var CoreConfig = {
|
|
|
88
156
|
|
|
89
157
|
var getSessionTokenAWS = /*#__PURE__*/function () {
|
|
90
158
|
var _ref = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(prefix) {
|
|
91
|
-
var
|
|
159
|
+
var token;
|
|
92
160
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
93
161
|
while (1) {
|
|
94
162
|
switch (_context.prev = _context.next) {
|
|
95
163
|
case 0:
|
|
96
164
|
_context.next = 2;
|
|
97
|
-
return
|
|
165
|
+
return CoreConfig.env.AuthStrategy.getAccessToken();
|
|
98
166
|
|
|
99
167
|
case 2:
|
|
100
|
-
|
|
101
|
-
token = data.getAccessToken().getJwtToken();
|
|
168
|
+
token = _context.sent;
|
|
102
169
|
|
|
103
170
|
if (!___default['default'].isUndefined(prefix)) {
|
|
104
|
-
_context.next =
|
|
171
|
+
_context.next = 5;
|
|
105
172
|
break;
|
|
106
173
|
}
|
|
107
174
|
|
|
108
175
|
return _context.abrupt("return", token);
|
|
109
176
|
|
|
110
|
-
case
|
|
177
|
+
case 5:
|
|
111
178
|
return _context.abrupt("return", "".concat(prefix, " ").concat(token));
|
|
112
179
|
|
|
113
|
-
case
|
|
180
|
+
case 6:
|
|
114
181
|
case "end":
|
|
115
182
|
return _context.stop();
|
|
116
183
|
}
|
|
@@ -170,30 +237,28 @@ var unauthedFunction = function unauthedFunction(request) {
|
|
|
170
237
|
};
|
|
171
238
|
var getCurrentUserSub = /*#__PURE__*/function () {
|
|
172
239
|
var _ref3 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3() {
|
|
173
|
-
var user;
|
|
174
240
|
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
|
175
241
|
while (1) {
|
|
176
242
|
switch (_context3.prev = _context3.next) {
|
|
177
243
|
case 0:
|
|
178
244
|
_context3.prev = 0;
|
|
179
245
|
_context3.next = 3;
|
|
180
|
-
return
|
|
246
|
+
return CoreConfig.env.AuthStrategy.getCurrentUserId();
|
|
181
247
|
|
|
182
248
|
case 3:
|
|
183
|
-
|
|
184
|
-
return _context3.abrupt("return", user.id);
|
|
249
|
+
return _context3.abrupt("return", _context3.sent);
|
|
185
250
|
|
|
186
|
-
case
|
|
187
|
-
_context3.prev =
|
|
251
|
+
case 6:
|
|
252
|
+
_context3.prev = 6;
|
|
188
253
|
_context3.t0 = _context3["catch"](0);
|
|
189
254
|
return _context3.abrupt("return", null);
|
|
190
255
|
|
|
191
|
-
case
|
|
256
|
+
case 9:
|
|
192
257
|
case "end":
|
|
193
258
|
return _context3.stop();
|
|
194
259
|
}
|
|
195
260
|
}
|
|
196
|
-
}, _callee3, null, [[0,
|
|
261
|
+
}, _callee3, null, [[0, 6]]);
|
|
197
262
|
}));
|
|
198
263
|
|
|
199
264
|
return function getCurrentUserSub() {
|
|
@@ -202,19 +267,19 @@ var getCurrentUserSub = /*#__PURE__*/function () {
|
|
|
202
267
|
}();
|
|
203
268
|
var checkLoggedIn = /*#__PURE__*/function () {
|
|
204
269
|
var _ref4 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4(self) {
|
|
205
|
-
var
|
|
270
|
+
var isLoggedIn;
|
|
206
271
|
return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
|
|
207
272
|
while (1) {
|
|
208
273
|
switch (_context4.prev = _context4.next) {
|
|
209
274
|
case 0:
|
|
210
275
|
_context4.prev = 0;
|
|
211
276
|
_context4.next = 3;
|
|
212
|
-
return
|
|
277
|
+
return CoreConfig.env.AuthStrategy.hasActiveSession();
|
|
213
278
|
|
|
214
279
|
case 3:
|
|
215
|
-
|
|
280
|
+
isLoggedIn = _context4.sent;
|
|
216
281
|
|
|
217
|
-
if (
|
|
282
|
+
if (!isLoggedIn) {
|
|
218
283
|
console.log('redirecting to login');
|
|
219
284
|
self.props.history.push('/login');
|
|
220
285
|
}
|
|
@@ -1655,31 +1720,35 @@ function CanvasImageUploader(options) {
|
|
|
1655
1720
|
var fileActions = {
|
|
1656
1721
|
uploadMediaAsync: function () {
|
|
1657
1722
|
var _uploadMediaAsync = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(file, filename) {
|
|
1658
|
-
var newFilename,
|
|
1659
|
-
|
|
1723
|
+
var newFilename, signedUrlRes, baseUploadsUrl;
|
|
1660
1724
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
1661
1725
|
while (1) {
|
|
1662
1726
|
switch (_context.prev = _context.next) {
|
|
1663
1727
|
case 0:
|
|
1664
1728
|
newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
1665
1729
|
_context.next = 3;
|
|
1666
|
-
return
|
|
1730
|
+
return authedFunction({
|
|
1731
|
+
method: 'GET',
|
|
1732
|
+
url: getUrl('media', 'get/presignedurl', {
|
|
1733
|
+
filename: newFilename,
|
|
1734
|
+
contentType: file.type
|
|
1735
|
+
})
|
|
1736
|
+
});
|
|
1667
1737
|
|
|
1668
1738
|
case 3:
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
bucket: uploadBucket
|
|
1739
|
+
signedUrlRes = _context.sent;
|
|
1740
|
+
_context.next = 6;
|
|
1741
|
+
return axios__default['default'].put(signedUrlRes.data.url, file, {
|
|
1742
|
+
headers: {
|
|
1743
|
+
'Content-Type': file.type
|
|
1744
|
+
}
|
|
1676
1745
|
});
|
|
1677
1746
|
|
|
1678
|
-
case
|
|
1679
|
-
|
|
1680
|
-
return _context.abrupt("return", "".concat(baseUploadsUrl).concat(
|
|
1747
|
+
case 6:
|
|
1748
|
+
baseUploadsUrl = CoreConfig.env.baseUploadsUrl;
|
|
1749
|
+
return _context.abrupt("return", "".concat(baseUploadsUrl).concat(signedUrlRes.data.key));
|
|
1681
1750
|
|
|
1682
|
-
case
|
|
1751
|
+
case 8:
|
|
1683
1752
|
case "end":
|
|
1684
1753
|
return _context.stop();
|
|
1685
1754
|
}
|
|
@@ -1693,6 +1762,15 @@ var fileActions = {
|
|
|
1693
1762
|
|
|
1694
1763
|
return uploadMediaAsync;
|
|
1695
1764
|
}(),
|
|
1765
|
+
// uploadMediaAsync: async (file, filename) => {
|
|
1766
|
+
// const newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
1767
|
+
// const userId = await getCurrentUserSub();
|
|
1768
|
+
// const url = `uploads/users/${userId}/public/${randomString()}/${newFilename}`;
|
|
1769
|
+
// const { baseUploadsUrl, uploadBucket } = Config.env;
|
|
1770
|
+
// await Storage.put(url, file, { level: 'public', bucket: uploadBucket });
|
|
1771
|
+
// console.log('uploaded file', `${baseUploadsUrl}${url}`);
|
|
1772
|
+
// return `${baseUploadsUrl}${url}`;
|
|
1773
|
+
// },
|
|
1696
1774
|
// readBase64: async (file) => {
|
|
1697
1775
|
// return new Promise((resolve, reject) => {
|
|
1698
1776
|
// var reader = new FileReader();
|
|
@@ -1706,6 +1784,14 @@ var fileActions = {
|
|
|
1706
1784
|
// };
|
|
1707
1785
|
// });
|
|
1708
1786
|
// },
|
|
1787
|
+
getPresignedUrl: function getPresignedUrl(filename) {
|
|
1788
|
+
return authedFunction({
|
|
1789
|
+
method: 'GET',
|
|
1790
|
+
url: getUrl('media', 'get/presignedurl', {
|
|
1791
|
+
filename: filename
|
|
1792
|
+
})
|
|
1793
|
+
});
|
|
1794
|
+
},
|
|
1709
1795
|
compressImage: function compressImage(file, maxSize, quality, noCompress) {
|
|
1710
1796
|
return new Promise(function (resolve, reject) {
|
|
1711
1797
|
if (noCompress) {
|
|
@@ -5266,7 +5352,7 @@ var mapStateToProps$5 = function mapStateToProps() {
|
|
|
5266
5352
|
};
|
|
5267
5353
|
|
|
5268
5354
|
var FileInput = reactRedux.connect(mapStateToProps$5, {}, null, {
|
|
5269
|
-
|
|
5355
|
+
forwardRef: true
|
|
5270
5356
|
})(FileInputComponent);
|
|
5271
5357
|
|
|
5272
5358
|
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; }
|
|
@@ -7374,7 +7460,7 @@ var mapStateToProps$2 = function mapStateToProps(state) {
|
|
|
7374
7460
|
};
|
|
7375
7461
|
|
|
7376
7462
|
var ImageInput = reactRedux.connect(mapStateToProps$2, {}, null, {
|
|
7377
|
-
|
|
7463
|
+
forwardRef: true
|
|
7378
7464
|
})(ImageInputComponent);
|
|
7379
7465
|
|
|
7380
7466
|
function _createSuper$n(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$n(); 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); }; }
|
|
@@ -10003,7 +10089,7 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
10003
10089
|
var toExport = reactRedux.connect(null, {
|
|
10004
10090
|
setAuth: setAuth
|
|
10005
10091
|
}, null, {
|
|
10006
|
-
|
|
10092
|
+
forwardRef: true
|
|
10007
10093
|
})(AudienceSelector);
|
|
10008
10094
|
|
|
10009
10095
|
function _createSuper$6(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$6(); 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); }; }
|
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';
|
|
6
5
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
7
6
|
import moment from 'moment';
|
|
8
7
|
import React, { Component, PureComponent } from 'react';
|
|
9
8
|
import $ from 'jquery';
|
|
10
9
|
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,7 +49,75 @@ var CoreConfig = {
|
|
|
49
49
|
defaultAllowComments: true,
|
|
50
50
|
makeApiKey: '',
|
|
51
51
|
logo: '',
|
|
52
|
-
clientName: ''
|
|
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
|
+
}
|
|
53
121
|
},
|
|
54
122
|
init: function init(environment) {
|
|
55
123
|
CoreConfig.env = environment;
|
|
@@ -58,29 +126,28 @@ var CoreConfig = {
|
|
|
58
126
|
|
|
59
127
|
var getSessionTokenAWS = /*#__PURE__*/function () {
|
|
60
128
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(prefix) {
|
|
61
|
-
var
|
|
129
|
+
var token;
|
|
62
130
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
63
131
|
while (1) {
|
|
64
132
|
switch (_context.prev = _context.next) {
|
|
65
133
|
case 0:
|
|
66
134
|
_context.next = 2;
|
|
67
|
-
return
|
|
135
|
+
return CoreConfig.env.AuthStrategy.getAccessToken();
|
|
68
136
|
|
|
69
137
|
case 2:
|
|
70
|
-
|
|
71
|
-
token = data.getAccessToken().getJwtToken();
|
|
138
|
+
token = _context.sent;
|
|
72
139
|
|
|
73
140
|
if (!_.isUndefined(prefix)) {
|
|
74
|
-
_context.next =
|
|
141
|
+
_context.next = 5;
|
|
75
142
|
break;
|
|
76
143
|
}
|
|
77
144
|
|
|
78
145
|
return _context.abrupt("return", token);
|
|
79
146
|
|
|
80
|
-
case
|
|
147
|
+
case 5:
|
|
81
148
|
return _context.abrupt("return", "".concat(prefix, " ").concat(token));
|
|
82
149
|
|
|
83
|
-
case
|
|
150
|
+
case 6:
|
|
84
151
|
case "end":
|
|
85
152
|
return _context.stop();
|
|
86
153
|
}
|
|
@@ -140,30 +207,28 @@ var unauthedFunction = function unauthedFunction(request) {
|
|
|
140
207
|
};
|
|
141
208
|
var getCurrentUserSub = /*#__PURE__*/function () {
|
|
142
209
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
143
|
-
var user;
|
|
144
210
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
145
211
|
while (1) {
|
|
146
212
|
switch (_context3.prev = _context3.next) {
|
|
147
213
|
case 0:
|
|
148
214
|
_context3.prev = 0;
|
|
149
215
|
_context3.next = 3;
|
|
150
|
-
return
|
|
216
|
+
return CoreConfig.env.AuthStrategy.getCurrentUserId();
|
|
151
217
|
|
|
152
218
|
case 3:
|
|
153
|
-
|
|
154
|
-
return _context3.abrupt("return", user.id);
|
|
219
|
+
return _context3.abrupt("return", _context3.sent);
|
|
155
220
|
|
|
156
|
-
case
|
|
157
|
-
_context3.prev =
|
|
221
|
+
case 6:
|
|
222
|
+
_context3.prev = 6;
|
|
158
223
|
_context3.t0 = _context3["catch"](0);
|
|
159
224
|
return _context3.abrupt("return", null);
|
|
160
225
|
|
|
161
|
-
case
|
|
226
|
+
case 9:
|
|
162
227
|
case "end":
|
|
163
228
|
return _context3.stop();
|
|
164
229
|
}
|
|
165
230
|
}
|
|
166
|
-
}, _callee3, null, [[0,
|
|
231
|
+
}, _callee3, null, [[0, 6]]);
|
|
167
232
|
}));
|
|
168
233
|
|
|
169
234
|
return function getCurrentUserSub() {
|
|
@@ -172,19 +237,19 @@ var getCurrentUserSub = /*#__PURE__*/function () {
|
|
|
172
237
|
}();
|
|
173
238
|
var checkLoggedIn = /*#__PURE__*/function () {
|
|
174
239
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(self) {
|
|
175
|
-
var
|
|
240
|
+
var isLoggedIn;
|
|
176
241
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
177
242
|
while (1) {
|
|
178
243
|
switch (_context4.prev = _context4.next) {
|
|
179
244
|
case 0:
|
|
180
245
|
_context4.prev = 0;
|
|
181
246
|
_context4.next = 3;
|
|
182
|
-
return
|
|
247
|
+
return CoreConfig.env.AuthStrategy.hasActiveSession();
|
|
183
248
|
|
|
184
249
|
case 3:
|
|
185
|
-
|
|
250
|
+
isLoggedIn = _context4.sent;
|
|
186
251
|
|
|
187
|
-
if (
|
|
252
|
+
if (!isLoggedIn) {
|
|
188
253
|
console.log('redirecting to login');
|
|
189
254
|
self.props.history.push('/login');
|
|
190
255
|
}
|
|
@@ -1625,31 +1690,35 @@ function CanvasImageUploader(options) {
|
|
|
1625
1690
|
var fileActions = {
|
|
1626
1691
|
uploadMediaAsync: function () {
|
|
1627
1692
|
var _uploadMediaAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(file, filename) {
|
|
1628
|
-
var newFilename,
|
|
1629
|
-
|
|
1693
|
+
var newFilename, signedUrlRes, baseUploadsUrl;
|
|
1630
1694
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
1631
1695
|
while (1) {
|
|
1632
1696
|
switch (_context.prev = _context.next) {
|
|
1633
1697
|
case 0:
|
|
1634
1698
|
newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
1635
1699
|
_context.next = 3;
|
|
1636
|
-
return
|
|
1700
|
+
return authedFunction({
|
|
1701
|
+
method: 'GET',
|
|
1702
|
+
url: getUrl('media', 'get/presignedurl', {
|
|
1703
|
+
filename: newFilename,
|
|
1704
|
+
contentType: file.type
|
|
1705
|
+
})
|
|
1706
|
+
});
|
|
1637
1707
|
|
|
1638
1708
|
case 3:
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
bucket: uploadBucket
|
|
1709
|
+
signedUrlRes = _context.sent;
|
|
1710
|
+
_context.next = 6;
|
|
1711
|
+
return axios.put(signedUrlRes.data.url, file, {
|
|
1712
|
+
headers: {
|
|
1713
|
+
'Content-Type': file.type
|
|
1714
|
+
}
|
|
1646
1715
|
});
|
|
1647
1716
|
|
|
1648
|
-
case
|
|
1649
|
-
|
|
1650
|
-
return _context.abrupt("return", "".concat(baseUploadsUrl).concat(
|
|
1717
|
+
case 6:
|
|
1718
|
+
baseUploadsUrl = CoreConfig.env.baseUploadsUrl;
|
|
1719
|
+
return _context.abrupt("return", "".concat(baseUploadsUrl).concat(signedUrlRes.data.key));
|
|
1651
1720
|
|
|
1652
|
-
case
|
|
1721
|
+
case 8:
|
|
1653
1722
|
case "end":
|
|
1654
1723
|
return _context.stop();
|
|
1655
1724
|
}
|
|
@@ -1663,6 +1732,15 @@ var fileActions = {
|
|
|
1663
1732
|
|
|
1664
1733
|
return uploadMediaAsync;
|
|
1665
1734
|
}(),
|
|
1735
|
+
// uploadMediaAsync: async (file, filename) => {
|
|
1736
|
+
// const newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
1737
|
+
// const userId = await getCurrentUserSub();
|
|
1738
|
+
// const url = `uploads/users/${userId}/public/${randomString()}/${newFilename}`;
|
|
1739
|
+
// const { baseUploadsUrl, uploadBucket } = Config.env;
|
|
1740
|
+
// await Storage.put(url, file, { level: 'public', bucket: uploadBucket });
|
|
1741
|
+
// console.log('uploaded file', `${baseUploadsUrl}${url}`);
|
|
1742
|
+
// return `${baseUploadsUrl}${url}`;
|
|
1743
|
+
// },
|
|
1666
1744
|
// readBase64: async (file) => {
|
|
1667
1745
|
// return new Promise((resolve, reject) => {
|
|
1668
1746
|
// var reader = new FileReader();
|
|
@@ -1676,6 +1754,14 @@ var fileActions = {
|
|
|
1676
1754
|
// };
|
|
1677
1755
|
// });
|
|
1678
1756
|
// },
|
|
1757
|
+
getPresignedUrl: function getPresignedUrl(filename) {
|
|
1758
|
+
return authedFunction({
|
|
1759
|
+
method: 'GET',
|
|
1760
|
+
url: getUrl('media', 'get/presignedurl', {
|
|
1761
|
+
filename: filename
|
|
1762
|
+
})
|
|
1763
|
+
});
|
|
1764
|
+
},
|
|
1679
1765
|
compressImage: function compressImage(file, maxSize, quality, noCompress) {
|
|
1680
1766
|
return new Promise(function (resolve, reject) {
|
|
1681
1767
|
if (noCompress) {
|
|
@@ -5236,7 +5322,7 @@ var mapStateToProps$5 = function mapStateToProps() {
|
|
|
5236
5322
|
};
|
|
5237
5323
|
|
|
5238
5324
|
var FileInput = connect(mapStateToProps$5, {}, null, {
|
|
5239
|
-
|
|
5325
|
+
forwardRef: true
|
|
5240
5326
|
})(FileInputComponent);
|
|
5241
5327
|
|
|
5242
5328
|
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; }
|
|
@@ -7344,7 +7430,7 @@ var mapStateToProps$2 = function mapStateToProps(state) {
|
|
|
7344
7430
|
};
|
|
7345
7431
|
|
|
7346
7432
|
var ImageInput = connect(mapStateToProps$2, {}, null, {
|
|
7347
|
-
|
|
7433
|
+
forwardRef: true
|
|
7348
7434
|
})(ImageInputComponent);
|
|
7349
7435
|
|
|
7350
7436
|
function _createSuper$n(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$n(); 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); }; }
|
|
@@ -9973,7 +10059,7 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9973
10059
|
var toExport = connect(null, {
|
|
9974
10060
|
setAuth: setAuth
|
|
9975
10061
|
}, null, {
|
|
9976
|
-
|
|
10062
|
+
forwardRef: true
|
|
9977
10063
|
})(AudienceSelector);
|
|
9978
10064
|
|
|
9979
10065
|
function _createSuper$6(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$6(); 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); }; }
|
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('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '@babel/runtime/helpers/asyncToGenerator', '@babel/runtime/regenerator', 'lodash', 'axios', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['@plusscommunities/pluss-core-web'] = {}, global._asyncToGenerator, global._regeneratorRuntime, global._, global.axios, global.
|
|
5
|
-
}(this, (function (exports, _asyncToGenerator, _regeneratorRuntime, _, axios,
|
|
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('aws-amplify'), 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', '@babel/runtime/helpers/defineProperty', 'moment', 'react', 'jquery', 'js-cookie', 'aws-amplify', '@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._defineProperty, global.moment, global.React, global.$, global.Cookies, global.awsAmplify, 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, _defineProperty, moment, React, $, Cookies, awsAmplify, _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,7 +47,75 @@
|
|
|
47
47
|
defaultAllowComments: true,
|
|
48
48
|
makeApiKey: '',
|
|
49
49
|
logo: '',
|
|
50
|
-
clientName: ''
|
|
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
|
+
}
|
|
51
119
|
},
|
|
52
120
|
init: function init(environment) {
|
|
53
121
|
CoreConfig.env = environment;
|
|
@@ -56,29 +124,28 @@
|
|
|
56
124
|
|
|
57
125
|
var getSessionTokenAWS = /*#__PURE__*/function () {
|
|
58
126
|
var _ref = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(prefix) {
|
|
59
|
-
var
|
|
127
|
+
var token;
|
|
60
128
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
61
129
|
while (1) {
|
|
62
130
|
switch (_context.prev = _context.next) {
|
|
63
131
|
case 0:
|
|
64
132
|
_context.next = 2;
|
|
65
|
-
return
|
|
133
|
+
return CoreConfig.env.AuthStrategy.getAccessToken();
|
|
66
134
|
|
|
67
135
|
case 2:
|
|
68
|
-
|
|
69
|
-
token = data.getAccessToken().getJwtToken();
|
|
136
|
+
token = _context.sent;
|
|
70
137
|
|
|
71
138
|
if (!___default['default'].isUndefined(prefix)) {
|
|
72
|
-
_context.next =
|
|
139
|
+
_context.next = 5;
|
|
73
140
|
break;
|
|
74
141
|
}
|
|
75
142
|
|
|
76
143
|
return _context.abrupt("return", token);
|
|
77
144
|
|
|
78
|
-
case
|
|
145
|
+
case 5:
|
|
79
146
|
return _context.abrupt("return", "".concat(prefix, " ").concat(token));
|
|
80
147
|
|
|
81
|
-
case
|
|
148
|
+
case 6:
|
|
82
149
|
case "end":
|
|
83
150
|
return _context.stop();
|
|
84
151
|
}
|
|
@@ -138,30 +205,28 @@
|
|
|
138
205
|
};
|
|
139
206
|
var getCurrentUserSub = /*#__PURE__*/function () {
|
|
140
207
|
var _ref3 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3() {
|
|
141
|
-
var user;
|
|
142
208
|
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
|
143
209
|
while (1) {
|
|
144
210
|
switch (_context3.prev = _context3.next) {
|
|
145
211
|
case 0:
|
|
146
212
|
_context3.prev = 0;
|
|
147
213
|
_context3.next = 3;
|
|
148
|
-
return
|
|
214
|
+
return CoreConfig.env.AuthStrategy.getCurrentUserId();
|
|
149
215
|
|
|
150
216
|
case 3:
|
|
151
|
-
|
|
152
|
-
return _context3.abrupt("return", user.id);
|
|
217
|
+
return _context3.abrupt("return", _context3.sent);
|
|
153
218
|
|
|
154
|
-
case
|
|
155
|
-
_context3.prev =
|
|
219
|
+
case 6:
|
|
220
|
+
_context3.prev = 6;
|
|
156
221
|
_context3.t0 = _context3["catch"](0);
|
|
157
222
|
return _context3.abrupt("return", null);
|
|
158
223
|
|
|
159
|
-
case
|
|
224
|
+
case 9:
|
|
160
225
|
case "end":
|
|
161
226
|
return _context3.stop();
|
|
162
227
|
}
|
|
163
228
|
}
|
|
164
|
-
}, _callee3, null, [[0,
|
|
229
|
+
}, _callee3, null, [[0, 6]]);
|
|
165
230
|
}));
|
|
166
231
|
|
|
167
232
|
return function getCurrentUserSub() {
|
|
@@ -170,19 +235,19 @@
|
|
|
170
235
|
}();
|
|
171
236
|
var checkLoggedIn = /*#__PURE__*/function () {
|
|
172
237
|
var _ref4 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4(self) {
|
|
173
|
-
var
|
|
238
|
+
var isLoggedIn;
|
|
174
239
|
return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
|
|
175
240
|
while (1) {
|
|
176
241
|
switch (_context4.prev = _context4.next) {
|
|
177
242
|
case 0:
|
|
178
243
|
_context4.prev = 0;
|
|
179
244
|
_context4.next = 3;
|
|
180
|
-
return
|
|
245
|
+
return CoreConfig.env.AuthStrategy.hasActiveSession();
|
|
181
246
|
|
|
182
247
|
case 3:
|
|
183
|
-
|
|
248
|
+
isLoggedIn = _context4.sent;
|
|
184
249
|
|
|
185
|
-
if (
|
|
250
|
+
if (!isLoggedIn) {
|
|
186
251
|
console.log('redirecting to login');
|
|
187
252
|
self.props.history.push('/login');
|
|
188
253
|
}
|
|
@@ -1623,31 +1688,35 @@
|
|
|
1623
1688
|
var fileActions = {
|
|
1624
1689
|
uploadMediaAsync: function () {
|
|
1625
1690
|
var _uploadMediaAsync = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(file, filename) {
|
|
1626
|
-
var newFilename,
|
|
1627
|
-
|
|
1691
|
+
var newFilename, signedUrlRes, baseUploadsUrl;
|
|
1628
1692
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
1629
1693
|
while (1) {
|
|
1630
1694
|
switch (_context.prev = _context.next) {
|
|
1631
1695
|
case 0:
|
|
1632
1696
|
newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
1633
1697
|
_context.next = 3;
|
|
1634
|
-
return
|
|
1698
|
+
return authedFunction({
|
|
1699
|
+
method: 'GET',
|
|
1700
|
+
url: getUrl('media', 'get/presignedurl', {
|
|
1701
|
+
filename: newFilename,
|
|
1702
|
+
contentType: file.type
|
|
1703
|
+
})
|
|
1704
|
+
});
|
|
1635
1705
|
|
|
1636
1706
|
case 3:
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
bucket: uploadBucket
|
|
1707
|
+
signedUrlRes = _context.sent;
|
|
1708
|
+
_context.next = 6;
|
|
1709
|
+
return axios__default['default'].put(signedUrlRes.data.url, file, {
|
|
1710
|
+
headers: {
|
|
1711
|
+
'Content-Type': file.type
|
|
1712
|
+
}
|
|
1644
1713
|
});
|
|
1645
1714
|
|
|
1646
|
-
case
|
|
1647
|
-
|
|
1648
|
-
return _context.abrupt("return", "".concat(baseUploadsUrl).concat(
|
|
1715
|
+
case 6:
|
|
1716
|
+
baseUploadsUrl = CoreConfig.env.baseUploadsUrl;
|
|
1717
|
+
return _context.abrupt("return", "".concat(baseUploadsUrl).concat(signedUrlRes.data.key));
|
|
1649
1718
|
|
|
1650
|
-
case
|
|
1719
|
+
case 8:
|
|
1651
1720
|
case "end":
|
|
1652
1721
|
return _context.stop();
|
|
1653
1722
|
}
|
|
@@ -1661,6 +1730,15 @@
|
|
|
1661
1730
|
|
|
1662
1731
|
return uploadMediaAsync;
|
|
1663
1732
|
}(),
|
|
1733
|
+
// uploadMediaAsync: async (file, filename) => {
|
|
1734
|
+
// const newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
1735
|
+
// const userId = await getCurrentUserSub();
|
|
1736
|
+
// const url = `uploads/users/${userId}/public/${randomString()}/${newFilename}`;
|
|
1737
|
+
// const { baseUploadsUrl, uploadBucket } = Config.env;
|
|
1738
|
+
// await Storage.put(url, file, { level: 'public', bucket: uploadBucket });
|
|
1739
|
+
// console.log('uploaded file', `${baseUploadsUrl}${url}`);
|
|
1740
|
+
// return `${baseUploadsUrl}${url}`;
|
|
1741
|
+
// },
|
|
1664
1742
|
// readBase64: async (file) => {
|
|
1665
1743
|
// return new Promise((resolve, reject) => {
|
|
1666
1744
|
// var reader = new FileReader();
|
|
@@ -1674,6 +1752,14 @@
|
|
|
1674
1752
|
// };
|
|
1675
1753
|
// });
|
|
1676
1754
|
// },
|
|
1755
|
+
getPresignedUrl: function getPresignedUrl(filename) {
|
|
1756
|
+
return authedFunction({
|
|
1757
|
+
method: 'GET',
|
|
1758
|
+
url: getUrl('media', 'get/presignedurl', {
|
|
1759
|
+
filename: filename
|
|
1760
|
+
})
|
|
1761
|
+
});
|
|
1762
|
+
},
|
|
1677
1763
|
compressImage: function compressImage(file, maxSize, quality, noCompress) {
|
|
1678
1764
|
return new Promise(function (resolve, reject) {
|
|
1679
1765
|
if (noCompress) {
|
|
@@ -5234,7 +5320,7 @@
|
|
|
5234
5320
|
};
|
|
5235
5321
|
|
|
5236
5322
|
var FileInput = reactRedux.connect(mapStateToProps$5, {}, null, {
|
|
5237
|
-
|
|
5323
|
+
forwardRef: true
|
|
5238
5324
|
})(FileInputComponent);
|
|
5239
5325
|
|
|
5240
5326
|
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; }
|
|
@@ -7342,7 +7428,7 @@
|
|
|
7342
7428
|
};
|
|
7343
7429
|
|
|
7344
7430
|
var ImageInput = reactRedux.connect(mapStateToProps$2, {}, null, {
|
|
7345
|
-
|
|
7431
|
+
forwardRef: true
|
|
7346
7432
|
})(ImageInputComponent);
|
|
7347
7433
|
|
|
7348
7434
|
function _createSuper$n(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$n(); 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); }; }
|
|
@@ -9971,7 +10057,7 @@
|
|
|
9971
10057
|
var toExport = reactRedux.connect(null, {
|
|
9972
10058
|
setAuth: setAuth
|
|
9973
10059
|
}, null, {
|
|
9974
|
-
|
|
10060
|
+
forwardRef: true
|
|
9975
10061
|
})(AudienceSelector);
|
|
9976
10062
|
|
|
9977
10063
|
function _createSuper$6(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$6(); 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); }; }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plusscommunities/pluss-core-web",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.9-auth.0",
|
|
4
4
|
"description": "Core extension package for Pluss Communities platform",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"scripts": {
|
|
@@ -9,6 +9,9 @@
|
|
|
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",
|
|
12
15
|
"upload": "npm run build && npm publish --access public && rm -rf node_modules",
|
|
13
16
|
"upload:p": "npm run patch && npm run upload"
|
|
14
17
|
},
|
|
@@ -41,7 +44,7 @@
|
|
|
41
44
|
"react": "^16.14.0",
|
|
42
45
|
"react-dropzone": "^14.2.3",
|
|
43
46
|
"react-fontawesome": "^1.6.1",
|
|
44
|
-
"react-redux": "^
|
|
47
|
+
"react-redux": "^7.2.9",
|
|
45
48
|
"react-router-dom": "^4.2.2",
|
|
46
49
|
"react-textarea-autosize": "^7.1.0-1"
|
|
47
50
|
},
|
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) {
|
|
@@ -647,6 +647,6 @@ class AudienceSelector extends Component {
|
|
|
647
647
|
}
|
|
648
648
|
}
|
|
649
649
|
|
|
650
|
-
const toExport = connect(null, { setAuth }, null, {
|
|
650
|
+
const toExport = connect(null, { setAuth }, null, { forwardRef: true })(AudienceSelector);
|
|
651
651
|
|
|
652
652
|
export { toExport as AudienceSelector };
|
|
@@ -335,5 +335,5 @@ const mapStateToProps = () => {
|
|
|
335
335
|
return {};
|
|
336
336
|
};
|
|
337
337
|
|
|
338
|
-
const FileInput = connect(mapStateToProps, {}, null, {
|
|
338
|
+
const FileInput = connect(mapStateToProps, {}, null, { forwardRef: true })(FileInputComponent);
|
|
339
339
|
export { FileInput };
|
|
@@ -984,5 +984,5 @@ const mapStateToProps = (state) => {
|
|
|
984
984
|
};
|
|
985
985
|
};
|
|
986
986
|
|
|
987
|
-
const ImageInput = connect(mapStateToProps, {}, null, {
|
|
987
|
+
const ImageInput = connect(mapStateToProps, {}, null, { forwardRef: true })(ImageInputComponent);
|
|
988
988
|
export { ImageInput };
|
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
|
}
|