@ozdao/prometheus-framework 0.2.137 → 0.2.139

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. package/dist/auth.server.js +29 -14
  2. package/dist/auth.server.mjs +29 -14
  3. package/dist/community.server.js +3 -3
  4. package/dist/community.server.mjs +3 -3
  5. package/dist/events.server.js +3 -3
  6. package/dist/events.server.mjs +3 -3
  7. package/dist/files.server.js +3 -3
  8. package/dist/files.server.mjs +3 -3
  9. package/dist/gallery.server.js +4 -4
  10. package/dist/gallery.server.mjs +4 -4
  11. package/dist/index-DNI4aUP2.js +259 -0
  12. package/dist/index-Tcyehi73.mjs +260 -0
  13. package/dist/main-DTHFR7H_.mjs +14510 -0
  14. package/dist/main-wXdocsbd.js +92 -0
  15. package/dist/main.css +1 -1
  16. package/dist/orders.server.js +9 -8
  17. package/dist/orders.server.mjs +9 -8
  18. package/dist/organizations.server.js +32 -17
  19. package/dist/organizations.server.mjs +32 -17
  20. package/dist/products.server.js +37 -5
  21. package/dist/products.server.mjs +37 -5
  22. package/dist/prometheus-framework/src/components/Block/Block.vue.cjs +1 -1
  23. package/dist/prometheus-framework/src/components/Block/Block.vue.js +1 -1
  24. package/dist/prometheus-framework/src/components/Completion/Completion.vue.cjs +1 -1
  25. package/dist/prometheus-framework/src/components/Completion/Completion.vue.js +19 -19
  26. package/dist/prometheus-framework/src/components/Feed/Feed.vue.cjs +1 -1
  27. package/dist/prometheus-framework/src/components/Feed/Feed.vue.js +1 -1
  28. package/dist/prometheus-framework/src/components/Map/Map.vue.cjs +1 -1
  29. package/dist/prometheus-framework/src/components/Map/Map.vue.js +3 -2
  30. package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.cjs +1 -1
  31. package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.js +32 -31
  32. package/dist/prometheus-framework/src/modules/auth/store/auth.cjs +1 -1
  33. package/dist/prometheus-framework/src/modules/auth/store/auth.js +50 -47
  34. package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.cjs +1 -1
  35. package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.js +1 -1
  36. package/dist/prometheus-framework/src/modules/community/components/sections/HotPosts.vue.cjs +1 -1
  37. package/dist/prometheus-framework/src/modules/community/components/sections/HotPosts.vue.js +1 -1
  38. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.cjs +1 -1
  39. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.js +2 -2
  40. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.cjs +1 -1
  41. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.js +1 -1
  42. package/dist/prometheus-framework/src/modules/marketplace/store/marketplace.cjs +1 -1
  43. package/dist/prometheus-framework/src/modules/marketplace/store/marketplace.js +1 -1
  44. package/dist/prometheus-framework/src/modules/orders/components/pages/OrderCreateBackoffice.vue.cjs +1 -1
  45. package/dist/prometheus-framework/src/modules/orders/components/pages/OrderCreateBackoffice.vue.js +12 -12
  46. package/dist/prometheus-framework/src/modules/orders/components/sections/FormAddCustomer.vue.cjs +1 -1
  47. package/dist/prometheus-framework/src/modules/orders/components/sections/FormAddCustomer.vue.js +2 -2
  48. package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardOrganization.vue.cjs +1 -1
  49. package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardOrganization.vue.js +41 -38
  50. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.cjs +1 -1
  51. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.js +123 -114
  52. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.cjs +1 -1
  53. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.js +51 -52
  54. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationBackoffice.vue.cjs +1 -1
  55. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationBackoffice.vue.js +1 -1
  56. package/dist/prometheus-framework/src/modules/organizations/components/sections/DetailsTab.vue.cjs +1 -1
  57. package/dist/prometheus-framework/src/modules/organizations/components/sections/DetailsTab.vue.js +16 -15
  58. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.cjs +1 -1
  59. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.js +120 -60
  60. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.cjs +1 -1
  61. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.js +1 -1
  62. package/dist/prometheus-framework/src/modules/organizations/store/invites.cjs +1 -1
  63. package/dist/prometheus-framework/src/modules/organizations/store/invites.js +25 -24
  64. package/dist/prometheus-framework/src/modules/spots/components/blocks/CardSpot.vue.cjs +1 -1
  65. package/dist/prometheus-framework/src/modules/spots/components/blocks/CardSpot.vue.js +7 -7
  66. package/dist/prometheus-framework/src/modules/spots/components/layouts/Spots.vue.cjs +1 -1
  67. package/dist/prometheus-framework/src/modules/spots/components/layouts/Spots.vue.js +3 -3
  68. package/dist/prometheus-framework/src/modules/spots/components/pages/Map.vue.cjs +1 -1
  69. package/dist/prometheus-framework/src/modules/spots/components/pages/Map.vue.js +65 -66
  70. package/dist/prometheus-framework/src/modules/spots/components/pages/SpotEdit.vue.cjs +1 -1
  71. package/dist/prometheus-framework/src/modules/spots/components/pages/SpotEdit.vue.js +81 -76
  72. package/dist/prometheus-framework/src/modules/spots/router/spots.cjs +1 -1
  73. package/dist/prometheus-framework/src/modules/spots/router/spots.js +1 -1
  74. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.cjs +1 -1
  75. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.js +2 -2
  76. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.cjs +1 -1
  77. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.js +78 -74
  78. package/dist/prometheus-framework/src/modules/wallet/views/components/pages/Wallet.vue.cjs +1 -1
  79. package/dist/prometheus-framework/src/modules/wallet/views/components/pages/Wallet.vue.js +2 -2
  80. package/dist/prometheus-framework.cjs.js +1 -1
  81. package/dist/prometheus-framework.es.js +1 -1
  82. package/dist/reports.server.js +0 -3
  83. package/dist/reports.server.mjs +0 -3
  84. package/dist/spots.server.js +3 -3
  85. package/dist/spots.server.mjs +3 -3
  86. package/dist/style.css +1 -1
  87. package/dist/wallet.server.js +5 -5
  88. package/dist/wallet.server.mjs +8 -8
  89. package/dist/web-Dh669DqQ.mjs +54 -0
  90. package/dist/web-Dt2RCU54.js +1 -0
  91. package/package.json +1 -1
  92. package/src/components/Completion/Completion.vue +29 -30
  93. package/src/components/Map/Map.vue +2 -2
  94. package/src/modules/auth/components/pages/Invite.vue +4 -2
  95. package/src/modules/auth/controllers/auth.controller.js +30 -12
  96. package/src/modules/auth/middlewares/authJwt.js +80 -0
  97. package/src/modules/{middlewares/server → auth/middlewares}/index.js +1 -3
  98. package/src/modules/{middlewares/server → auth/middlewares}/verifyAccesses.js +1 -1
  99. package/src/modules/auth/routes/auth.routes.js +2 -2
  100. package/src/modules/auth/routes/twofa.routes.js +1 -1
  101. package/src/modules/auth/store/auth.js +9 -0
  102. package/src/modules/chats/routes/chats.routes.js +1 -1
  103. package/src/modules/community/routes/blog.routes.js +2 -2
  104. package/src/modules/events/routes/events.routes.js +2 -2
  105. package/src/modules/files/routes/files.routes.js +2 -2
  106. package/src/modules/gallery/routes/gallery.routes.js +4 -5
  107. package/src/modules/globals/services/globals.crud.js +2 -2
  108. package/src/modules/marketplace/store/marketplace.js +1 -1
  109. package/src/modules/orders/components/pages/OrderCreateBackoffice.vue +2 -2
  110. package/src/modules/orders/components/sections/FormAddCustomer.vue +2 -2
  111. package/src/modules/orders/controllers/orders.controller.js +1 -0
  112. package/src/modules/orders/routes/applications.routes.js +2 -2
  113. package/src/modules/orders/routes/orders.routes.js +2 -2
  114. package/src/modules/organizations/components/blocks/CardOrganization.vue +9 -7
  115. package/src/modules/organizations/components/pages/Members.vue +26 -15
  116. package/src/modules/organizations/components/pages/Organization.vue +3 -3
  117. package/src/modules/organizations/components/sections/DetailsTab.vue +1 -1
  118. package/src/modules/organizations/components/sections/MembersAdd.vue +101 -43
  119. package/src/modules/organizations/controllers/invites.controller.js +18 -13
  120. package/src/modules/organizations/controllers/memberships.controller.js +18 -11
  121. package/src/modules/organizations/controllers/organizations.controller.js +3 -4
  122. package/src/modules/organizations/models/membership.model.js +2 -0
  123. package/src/modules/organizations/models/organization.model.js +4 -0
  124. package/src/modules/organizations/routes/invites.routes.js +2 -2
  125. package/src/modules/organizations/store/invites.js +2 -1
  126. package/src/modules/products/controllers/leftovers.controller.js +1 -1
  127. package/src/modules/products/middlewares/index.js +11 -0
  128. package/src/modules/products/routes/categories.routes.js +2 -2
  129. package/src/modules/reports/routes/reports.routes.js +2 -2
  130. package/src/modules/spots/components/blocks/CardSpot.vue +0 -1
  131. package/src/modules/spots/components/layouts/Spots.vue +2 -2
  132. package/src/modules/spots/components/pages/Map.vue +79 -78
  133. package/src/modules/spots/components/pages/SpotEdit.vue +8 -5
  134. package/src/modules/spots/controllers/spots.controller.js +1 -5
  135. package/src/modules/spots/router/spots.js +1 -1
  136. package/src/modules/users/components/pages/ProfileEdit.vue +37 -22
  137. package/src/modules/wallet/controllers/routes/payments.routes.js +2 -2
  138. package/src/modules/wallet/controllers/routes/rewards.routes.js +2 -2
  139. package/src/modules/middlewares/server/authJwt.js +0 -68
  140. /package/src/modules/{middlewares/server → auth/middlewares}/authSecret.js +0 -0
  141. /package/src/modules/{middlewares/server → auth/middlewares}/verifyInvites.js +0 -0
  142. /package/src/modules/{middlewares/server → auth/middlewares}/verifySignUp.js +0 -0
  143. /package/src/modules/{middlewares/server → auth/middlewares}/verifyUser.js +0 -0
  144. /package/src/modules/globals/services/{globals.cashe.js → globals.cache.js} +0 -0
  145. /package/src/modules/{middlewares/server → products/middlewares}/verifyCategory.js +0 -0
@@ -0,0 +1,260 @@
1
+ import require$$0 from "jsonwebtoken";
2
+ import require$$0$1 from "crypto";
3
+ import require$$0$2 from "mongodb";
4
+ var authJwt;
5
+ var hasRequiredAuthJwt;
6
+ function requireAuthJwt() {
7
+ if (hasRequiredAuthJwt) return authJwt;
8
+ hasRequiredAuthJwt = 1;
9
+ const jwt = require$$0;
10
+ const middlewareFactory = (db) => {
11
+ const User = db.user;
12
+ const Role = db.role;
13
+ const verifyToken = (continueOnFail = false) => {
14
+ return async (req, res, next) => {
15
+ try {
16
+ if (!req.cookies.user) {
17
+ req.userId = null;
18
+ if (continueOnFail) {
19
+ return next();
20
+ } else {
21
+ return res.status(401).send({ message: "Unauthorized: No user cookie" });
22
+ }
23
+ }
24
+ let user = JSON.parse(req.cookies.user);
25
+ let token = req.headers["x-access-token"] || user.accessToken;
26
+ if (!token) {
27
+ req.userId = null;
28
+ if (continueOnFail) {
29
+ return next();
30
+ } else {
31
+ return res.status(401).send({ message: "Unauthorized: No token provided" });
32
+ }
33
+ }
34
+ const decoded = jwt.verify(token, process.env.SECRET_KEY);
35
+ req.userId = decoded._id;
36
+ next();
37
+ } catch (err) {
38
+ console.log(err);
39
+ req.userId = null;
40
+ if (continueOnFail) {
41
+ next();
42
+ } else {
43
+ res.status(401).send({ message: "Unauthorized: Invalid token" });
44
+ }
45
+ }
46
+ };
47
+ };
48
+ const checkRole = (roleToCheck) => async (req, res, next) => {
49
+ try {
50
+ const user = await User.findById(req.userId).exec();
51
+ if (!user) {
52
+ return res.status(404).send({ message: "User Not found." });
53
+ }
54
+ const roles = await Role.find({ _id: { $in: user.roles } }).exec();
55
+ for (let role of roles) {
56
+ if (role.name === roleToCheck) {
57
+ next();
58
+ return;
59
+ }
60
+ }
61
+ res.status(403).send({ message: `Require ${roleToCheck} Role!` });
62
+ } catch (err) {
63
+ res.status(500).send({ message: err.message });
64
+ }
65
+ };
66
+ const isAdmin = checkRole("admin");
67
+ const isModerator = checkRole("moderator");
68
+ return {
69
+ verifyToken,
70
+ isAdmin,
71
+ isModerator
72
+ };
73
+ };
74
+ authJwt = middlewareFactory;
75
+ return authJwt;
76
+ }
77
+ var authSecret;
78
+ var hasRequiredAuthSecret;
79
+ function requireAuthSecret() {
80
+ if (hasRequiredAuthSecret) return authSecret;
81
+ hasRequiredAuthSecret = 1;
82
+ const crypto = require$$0$1;
83
+ const middlewareFactory = () => {
84
+ const verifySecret = (method, endpoint, secret) => async (req, res, next) => {
85
+ const requestSignature = req.headers.signature;
86
+ const signature = crypto.createHmac("sha256", secret).update(method + endpoint).digest("hex");
87
+ if (signature === requestSignature) {
88
+ return next();
89
+ }
90
+ res.status(403).send("Forbidden");
91
+ };
92
+ return { verifySecret };
93
+ };
94
+ authSecret = middlewareFactory;
95
+ return authSecret;
96
+ }
97
+ var verifySignUp;
98
+ var hasRequiredVerifySignUp;
99
+ function requireVerifySignUp() {
100
+ if (hasRequiredVerifySignUp) return verifySignUp;
101
+ hasRequiredVerifySignUp = 1;
102
+ const middlewareFactory = (db) => {
103
+ const User = db.user;
104
+ db.role;
105
+ const checkDuplicateUsernameOrEmail = async (req, res, next) => {
106
+ const { type, email, phone } = req.body;
107
+ console.log(req.body);
108
+ let query;
109
+ if (type === "phone" && phone) {
110
+ query = { phone };
111
+ }
112
+ if (type === "email" && email) {
113
+ query = { email };
114
+ }
115
+ try {
116
+ const user = await User.findOne(query).exec();
117
+ if (user) {
118
+ console.log(`USER_ALREADY_REGISTERED`);
119
+ res.status(400).send({ errorCode: "USER_ALREADY_REGISTERED" });
120
+ return;
121
+ }
122
+ next();
123
+ } catch (err) {
124
+ console.log(err);
125
+ res.status(500).send({ message: err.message });
126
+ }
127
+ };
128
+ const checkRolesExisted = (req, res, next) => {
129
+ if (req.body.roles) {
130
+ for (let i = 0; i < req.body.roles.length; i++) {
131
+ if (!ROLES.includes(req.body.roles[i])) {
132
+ console.log(`Failed! Role ${req.body.roles[i]} does not exist!`);
133
+ res.status(400).send({
134
+ message: `Failed! Role ${req.body.roles[i]} does not exist!`
135
+ });
136
+ return;
137
+ }
138
+ }
139
+ }
140
+ next();
141
+ };
142
+ return {
143
+ checkDuplicateUsernameOrEmail,
144
+ checkRolesExisted
145
+ };
146
+ };
147
+ verifySignUp = middlewareFactory;
148
+ return verifySignUp;
149
+ }
150
+ var verifyUser;
151
+ var hasRequiredVerifyUser;
152
+ function requireVerifyUser() {
153
+ if (hasRequiredVerifyUser) return verifyUser;
154
+ hasRequiredVerifyUser = 1;
155
+ const middlewareFactory = (db) => {
156
+ const User = db.user;
157
+ db.role;
158
+ const checkUserExist = async (req, res, next) => {
159
+ const { type, email, phone } = req.body;
160
+ let query;
161
+ if (type === "phone" && phone) {
162
+ query = { phone };
163
+ }
164
+ if (type === "email" && email) {
165
+ query = { email };
166
+ }
167
+ try {
168
+ const user = await User.findOne(query).exec();
169
+ if (!user) {
170
+ console.log(query);
171
+ res.status(400).send({ errorCode: "USER_NOT_REGISTERED_YET" });
172
+ return;
173
+ }
174
+ next();
175
+ } catch (err) {
176
+ res.status(500).send({ message: err.message });
177
+ }
178
+ };
179
+ return {
180
+ checkUserExist
181
+ };
182
+ };
183
+ verifyUser = middlewareFactory;
184
+ return verifyUser;
185
+ }
186
+ var verifyInvites;
187
+ var hasRequiredVerifyInvites;
188
+ function requireVerifyInvites() {
189
+ if (hasRequiredVerifyInvites) return verifyInvites;
190
+ hasRequiredVerifyInvites = 1;
191
+ const { ObjectId } = require$$0$2;
192
+ const middlewareFactory = (db) => {
193
+ const User = db.user;
194
+ const Invite = db.invite;
195
+ const Membership = db.membership;
196
+ const checkInviteExist = async (req, res, next) => {
197
+ for (let invite of req.body.invites) {
198
+ let query;
199
+ if (invite.contact.includes("@")) {
200
+ query = { invitedEmail: invite.contact };
201
+ } else {
202
+ query = { invitedPhone: invite.contact };
203
+ }
204
+ query["owner.target"] = req.body.owner.target;
205
+ const userInvite = await Invite.findOne(query).exec();
206
+ if (userInvite) {
207
+ console.log(userInvite);
208
+ res.status(400).send({ message: "Инвайт c таким email или телефоном уже создан!" });
209
+ return;
210
+ }
211
+ }
212
+ next();
213
+ };
214
+ const checkUsersExist = async (req, res, next) => {
215
+ for (let invite of req.body.invites) {
216
+ let query;
217
+ if (invite.contact.includes("@")) {
218
+ query = { email: invite.contact };
219
+ } else {
220
+ query = { phone: invite.contact };
221
+ }
222
+ const user = await User.findOne(query).exec();
223
+ console.log(req.params);
224
+ if (user) {
225
+ const membership = await Membership.findOne({ user: new ObjectId(user._id), "owner.target": req.body.owner.target }).exec();
226
+ if (membership) {
227
+ console.log(membership);
228
+ res.status(400).send({ message: "Пользователь с таким email или телефоном уже добавлен в организацию!" });
229
+ return;
230
+ }
231
+ }
232
+ }
233
+ next();
234
+ };
235
+ return {
236
+ checkInviteExist,
237
+ checkUsersExist
238
+ };
239
+ };
240
+ verifyInvites = middlewareFactory;
241
+ return verifyInvites;
242
+ }
243
+ const middlewareIndexFactory = (db) => {
244
+ const authJwt2 = requireAuthJwt()(db);
245
+ const authSecret2 = requireAuthSecret()();
246
+ const verifySignUp2 = requireVerifySignUp()(db);
247
+ const verifyUser2 = requireVerifyUser()(db);
248
+ const verifyInvites2 = requireVerifyInvites()(db);
249
+ return {
250
+ authJwt: authJwt2,
251
+ authSecret: authSecret2,
252
+ verifySignUp: verifySignUp2,
253
+ verifyUser: verifyUser2,
254
+ verifyInvites: verifyInvites2
255
+ };
256
+ };
257
+ var middlewares = middlewareIndexFactory;
258
+ export {
259
+ middlewares as m
260
+ };