@ozdao/prometheus-framework 0.2.142 → 0.2.144

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. package/dist/auth.server.js +1 -1
  2. package/dist/auth.server.mjs +1 -1
  3. package/dist/community.server.js +1 -1
  4. package/dist/community.server.mjs +1 -1
  5. package/dist/events.server.js +1 -1
  6. package/dist/events.server.mjs +1 -1
  7. package/dist/files.server.js +1 -1
  8. package/dist/files.server.mjs +1 -1
  9. package/dist/gallery.server.js +1 -1
  10. package/dist/gallery.server.mjs +1 -1
  11. package/dist/index-C-DW6ra2.js +260 -0
  12. package/dist/index-D4j29ivg.mjs +261 -0
  13. package/dist/orders.server.js +1 -1
  14. package/dist/orders.server.mjs +1 -1
  15. package/dist/organizations.server.js +1 -1
  16. package/dist/organizations.server.mjs +1 -1
  17. package/dist/prometheus-framework/src/components/Feed/Feed.vue.cjs +1 -1
  18. package/dist/prometheus-framework/src/components/Feed/Feed.vue.js +1 -1
  19. package/dist/prometheus-framework/src/components/FieldBig/FieldBig.vue.cjs +1 -1
  20. package/dist/prometheus-framework/src/components/FieldBig/FieldBig.vue.js +1 -1
  21. package/dist/prometheus-framework/src/modules/auth/components/layouts/Auth.vue.cjs +1 -1
  22. package/dist/prometheus-framework/src/modules/auth/components/layouts/Auth.vue.js +2 -2
  23. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterCode.vue.cjs +1 -1
  24. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterCode.vue.js +1 -1
  25. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterPassword.vue.cjs +1 -1
  26. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterPassword.vue.js +2 -2
  27. package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.cjs +1 -1
  28. package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.js +2 -2
  29. package/dist/prometheus-framework/src/modules/auth/components/pages/ResetPassword.vue.cjs +1 -1
  30. package/dist/prometheus-framework/src/modules/auth/components/pages/ResetPassword.vue.js +2 -2
  31. package/dist/prometheus-framework/src/modules/auth/components/pages/SignIn.vue.cjs +1 -1
  32. package/dist/prometheus-framework/src/modules/auth/components/pages/SignIn.vue.js +2 -2
  33. package/dist/prometheus-framework/src/modules/auth/components/pages/SignUp.vue.cjs +1 -1
  34. package/dist/prometheus-framework/src/modules/auth/components/pages/SignUp.vue.js +2 -2
  35. package/dist/prometheus-framework/src/modules/auth/store/auth.cjs +1 -1
  36. package/dist/prometheus-framework/src/modules/auth/store/auth.js +21 -21
  37. package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.cjs +1 -1
  38. package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.js +1 -1
  39. package/dist/prometheus-framework/src/modules/community/components/blocks/CardBlogpost.vue.cjs +1 -1
  40. package/dist/prometheus-framework/src/modules/community/components/blocks/CardBlogpost.vue.js +1 -1
  41. package/dist/prometheus-framework/src/modules/community/components/layouts/Community.vue.cjs +1 -1
  42. package/dist/prometheus-framework/src/modules/community/components/layouts/Community.vue.js +1 -1
  43. package/dist/prometheus-framework/src/modules/community/components/pages/Community.vue.cjs +1 -1
  44. package/dist/prometheus-framework/src/modules/community/components/pages/Community.vue.js +3 -3
  45. package/dist/prometheus-framework/src/modules/community/components/pages/CreateBlogPost.vue.cjs +1 -1
  46. package/dist/prometheus-framework/src/modules/community/components/pages/CreateBlogPost.vue.js +3 -3
  47. package/dist/prometheus-framework/src/modules/community/components/sections/HotPosts.vue.cjs +1 -1
  48. package/dist/prometheus-framework/src/modules/community/components/sections/HotPosts.vue.js +2 -2
  49. package/dist/prometheus-framework/src/modules/constructor/components/elements/Embed.vue.cjs +1 -1
  50. package/dist/prometheus-framework/src/modules/constructor/components/elements/Embed.vue.js +1 -1
  51. package/dist/prometheus-framework/src/modules/events/components/blocks/CardEvent.vue.cjs +1 -1
  52. package/dist/prometheus-framework/src/modules/events/components/blocks/CardEvent.vue.js +1 -1
  53. package/dist/prometheus-framework/src/modules/events/components/elements/ButtonCheck.vue.cjs +1 -1
  54. package/dist/prometheus-framework/src/modules/events/components/elements/ButtonCheck.vue.js +2 -2
  55. package/dist/prometheus-framework/src/modules/events/components/elements/ButtonJoin.vue.cjs +1 -1
  56. package/dist/prometheus-framework/src/modules/events/components/elements/ButtonJoin.vue.js +1 -1
  57. package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.cjs +1 -1
  58. package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.js +3 -3
  59. package/dist/prometheus-framework/src/modules/events/components/pages/EditEventTickets.vue.cjs +1 -1
  60. package/dist/prometheus-framework/src/modules/events/components/pages/EditEventTickets.vue.js +3 -3
  61. package/dist/prometheus-framework/src/modules/gallery/components/pages/Gallery.vue.cjs +1 -1
  62. package/dist/prometheus-framework/src/modules/gallery/components/pages/Gallery.vue.js +1 -1
  63. package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.cjs +1 -1
  64. package/dist/prometheus-framework/src/modules/gallery/components/sections/BackofficeGallery.vue.js +5 -5
  65. package/dist/prometheus-framework/src/modules/globals/components/blocks/BlockSearch.vue.cjs +1 -1
  66. package/dist/prometheus-framework/src/modules/globals/components/blocks/BlockSearch.vue.js +1 -1
  67. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.cjs +1 -1
  68. package/dist/prometheus-framework/src/modules/globals/components/blocks/CardHeader.vue.js +2 -2
  69. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.cjs +1 -1
  70. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.js +3 -3
  71. package/dist/prometheus-framework/src/modules/orders/components/pages/OrderBackoffice.vue.cjs +1 -1
  72. package/dist/prometheus-framework/src/modules/orders/components/pages/OrderBackoffice.vue.js +1 -1
  73. package/dist/prometheus-framework/src/modules/orders/components/pages/OrderCreateBackoffice.vue.cjs +1 -1
  74. package/dist/prometheus-framework/src/modules/orders/components/pages/OrderCreateBackoffice.vue.js +4 -4
  75. package/dist/prometheus-framework/src/modules/orders/components/sections/FormAddCustomer.vue.cjs +1 -1
  76. package/dist/prometheus-framework/src/modules/orders/components/sections/FormAddCustomer.vue.js +3 -3
  77. package/dist/prometheus-framework/src/modules/orders/components/sections/FormCustomerDetails.vue.cjs +1 -1
  78. package/dist/prometheus-framework/src/modules/orders/components/sections/FormCustomerDetails.vue.js +2 -2
  79. package/dist/prometheus-framework/src/modules/orders/components/sections/FormDelivery.vue.cjs +1 -1
  80. package/dist/prometheus-framework/src/modules/orders/components/sections/FormDelivery.vue.js +1 -1
  81. package/dist/prometheus-framework/src/modules/orders/components/sections/FormPayment.vue.cjs +1 -1
  82. package/dist/prometheus-framework/src/modules/orders/components/sections/FormPayment.vue.js +1 -1
  83. package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardOrganization.vue.cjs +1 -1
  84. package/dist/prometheus-framework/src/modules/organizations/components/blocks/CardOrganization.vue.js +1 -1
  85. package/dist/prometheus-framework/src/modules/organizations/components/elements/ButtonToggleMembership.vue.cjs +1 -1
  86. package/dist/prometheus-framework/src/modules/organizations/components/elements/ButtonToggleMembership.vue.js +1 -1
  87. package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.cjs +1 -1
  88. package/dist/prometheus-framework/src/modules/organizations/components/pages/DepartmentEdit.vue.js +4 -4
  89. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.cjs +1 -1
  90. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.js +2 -2
  91. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.cjs +1 -1
  92. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.js +1 -1
  93. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationBackoffice.vue.cjs +1 -1
  94. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationBackoffice.vue.js +1 -1
  95. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.cjs +1 -1
  96. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.js +4 -4
  97. package/dist/prometheus-framework/src/modules/organizations/components/sections/DetailsTab.vue.cjs +1 -1
  98. package/dist/prometheus-framework/src/modules/organizations/components/sections/DetailsTab.vue.js +2 -2
  99. package/dist/prometheus-framework/src/modules/organizations/components/sections/Documents.vue.cjs +1 -1
  100. package/dist/prometheus-framework/src/modules/organizations/components/sections/Documents.vue.js +3 -3
  101. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.cjs +1 -1
  102. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.js +3 -3
  103. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.cjs +1 -1
  104. package/dist/prometheus-framework/src/modules/organizations/components/sections/Organizations.vue.js +6 -6
  105. package/dist/prometheus-framework/src/modules/products/components/blocks/CardPosition.vue.cjs +1 -1
  106. package/dist/prometheus-framework/src/modules/products/components/blocks/CardPosition.vue.js +2 -2
  107. package/dist/prometheus-framework/src/modules/products/components/blocks/ImagesThumbnails.vue.cjs +1 -1
  108. package/dist/prometheus-framework/src/modules/products/components/blocks/ImagesThumbnails.vue.js +1 -1
  109. package/dist/prometheus-framework/src/modules/products/components/blocks/LeftoverPositions.vue.cjs +1 -1
  110. package/dist/prometheus-framework/src/modules/products/components/blocks/LeftoverPositions.vue.js +1 -1
  111. package/dist/prometheus-framework/src/modules/products/components/blocks/ListPositions.vue.cjs +1 -1
  112. package/dist/prometheus-framework/src/modules/products/components/blocks/ListPositions.vue.js +1 -1
  113. package/dist/prometheus-framework/src/modules/products/components/pages/Categories.vue.cjs +1 -1
  114. package/dist/prometheus-framework/src/modules/products/components/pages/Categories.vue.js +1 -1
  115. package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue.cjs +1 -1
  116. package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue.js +3 -3
  117. package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.cjs +1 -1
  118. package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.js +3 -3
  119. package/dist/prometheus-framework/src/modules/products/components/pages/ProductEdit.vue.cjs +1 -1
  120. package/dist/prometheus-framework/src/modules/products/components/pages/ProductEdit.vue.js +3 -3
  121. package/dist/prometheus-framework/src/modules/products/components/sections/EditModifications.vue.cjs +1 -1
  122. package/dist/prometheus-framework/src/modules/products/components/sections/EditModifications.vue.js +1 -1
  123. package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.cjs +1 -1
  124. package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.js +3 -3
  125. package/dist/prometheus-framework/src/modules/products/components/sections/SectionProduct.vue.cjs +1 -1
  126. package/dist/prometheus-framework/src/modules/products/components/sections/SectionProduct.vue.js +1 -1
  127. package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.cjs +1 -1
  128. package/dist/prometheus-framework/src/modules/reports/components/sections/FormReport.vue.js +3 -3
  129. package/dist/prometheus-framework/src/modules/spots/components/blocks/CardSpot.vue.cjs +1 -1
  130. package/dist/prometheus-framework/src/modules/spots/components/blocks/CardSpot.vue.js +1 -1
  131. package/dist/prometheus-framework/src/modules/spots/components/blocks/SpotMemberModify.vue.cjs +1 -1
  132. package/dist/prometheus-framework/src/modules/spots/components/blocks/SpotMemberModify.vue.js +2 -2
  133. package/dist/prometheus-framework/src/modules/spots/components/layouts/Spots.vue.cjs +1 -1
  134. package/dist/prometheus-framework/src/modules/spots/components/layouts/Spots.vue.js +2 -2
  135. package/dist/prometheus-framework/src/modules/spots/components/pages/Map.vue.cjs +1 -1
  136. package/dist/prometheus-framework/src/modules/spots/components/pages/Map.vue.js +1 -1
  137. package/dist/prometheus-framework/src/modules/spots/components/pages/SpotEdit.vue.cjs +1 -1
  138. package/dist/prometheus-framework/src/modules/spots/components/pages/SpotEdit.vue.js +4 -4
  139. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.cjs +1 -1
  140. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.js +4 -4
  141. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.cjs +1 -1
  142. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.js +2 -2
  143. package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CardDeposit.vue.cjs +1 -1
  144. package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CardDeposit.vue.js +1 -1
  145. package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CryptoDeposit.vue.cjs +1 -1
  146. package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CryptoDeposit.vue.js +2 -2
  147. package/dist/prometheus-framework/src/modules/wallet/views/components/pages/Wallet.vue.cjs +1 -1
  148. package/dist/prometheus-framework/src/modules/wallet/views/components/pages/Wallet.vue.js +5 -5
  149. package/dist/prometheus-framework.cjs.js +1 -1
  150. package/dist/prometheus-framework.es.js +1 -1
  151. package/dist/wallet.server.js +1 -1
  152. package/dist/wallet.server.mjs +1 -1
  153. package/package.json +1 -1
  154. package/src/modules/auth/middlewares/authJwt.js +1 -0
  155. package/src/modules/auth/store/auth.js +1 -1
@@ -5,7 +5,7 @@ const require$$1$1 = require("bcryptjs");
5
5
  const require$$0$1 = require("mongoose");
6
6
  const require$$1 = require("jwk-to-pem");
7
7
  const mailing = require("./mailing-BX0q8DIs.js");
8
- const index = require("./index-DNI4aUP2.js");
8
+ const index = require("./index-C-DW6ra2.js");
9
9
  const jwt$1 = require$$0;
10
10
  const jwkToPem = require$$1;
11
11
  async function verifyAppleIdToken$1(id_token) {
@@ -4,7 +4,7 @@ import require$$1$1 from "bcryptjs";
4
4
  import require$$0$1 from "mongoose";
5
5
  import require$$1 from "jwk-to-pem";
6
6
  import { m as mailing } from "./mailing-Cdp8NXhP.mjs";
7
- import { m as middlewares } from "./index-Tcyehi73.mjs";
7
+ import { m as middlewares } from "./index-D4j29ivg.mjs";
8
8
  const jwt$1 = require$$0;
9
9
  const jwkToPem = require$$1;
10
10
  async function verifyAppleIdToken$1(id_token) {
@@ -4,7 +4,7 @@ const require$$0 = require("mongoose");
4
4
  const queryProcessor$3 = require("./queryProcessor-iewDZq_f.js");
5
5
  require("util");
6
6
  require("uuid");
7
- const index = require("./index-DNI4aUP2.js");
7
+ const index = require("./index-C-DW6ra2.js");
8
8
  const common_schema = require("./common.schema-BFhpUXUt.js");
9
9
  const engagement_schema = require("./engagement.schema-D-9md46B.js");
10
10
  const ownership_schema = require("./ownership.schema-DN0SlQL6.js");
@@ -3,7 +3,7 @@ import require$$0 from "mongoose";
3
3
  import { q as queryProcessor$3 } from "./queryProcessor-DQSFR9YA.mjs";
4
4
  import "util";
5
5
  import "uuid";
6
- import { m as middlewares } from "./index-Tcyehi73.mjs";
6
+ import { m as middlewares } from "./index-D4j29ivg.mjs";
7
7
  import { c as common_schema } from "./common.schema-ChBVARrs.mjs";
8
8
  import { e as engagement_schema } from "./engagement.schema-CCdSLKd4.mjs";
9
9
  import { o as ownership_schema } from "./ownership.schema-oyx6eNkZ.mjs";
@@ -5,7 +5,7 @@ const require$$0 = require("mongoose");
5
5
  const queryProcessor$2 = require("./queryProcessor-iewDZq_f.js");
6
6
  const metadata_schema = require("./metadata.schema-6slGhpQS.js");
7
7
  const require$$1 = require("stripe");
8
- const index = require("./index-DNI4aUP2.js");
8
+ const index = require("./index-C-DW6ra2.js");
9
9
  const tickets_controller = require("./tickets.controller-WaQ4qMpv.js");
10
10
  const common_schema = require("./common.schema-BFhpUXUt.js");
11
11
  const engagement_schema = require("./engagement.schema-D-9md46B.js");
@@ -3,7 +3,7 @@ import require$$0 from "mongoose";
3
3
  import { q as queryProcessor$2 } from "./queryProcessor-DQSFR9YA.mjs";
4
4
  import { s as seoFriendlyUrl, m as metadata_schema } from "./metadata.schema-CK5e2O3f.mjs";
5
5
  import require$$1 from "stripe";
6
- import { m as middlewares } from "./index-Tcyehi73.mjs";
6
+ import { m as middlewares } from "./index-D4j29ivg.mjs";
7
7
  import { t as tickets_controller } from "./tickets.controller-ByZ33N6_.mjs";
8
8
  import { c as common_schema } from "./common.schema-ChBVARrs.mjs";
9
9
  import { e as engagement_schema } from "./engagement.schema-CCdSLKd4.mjs";
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  const _commonjsHelpers = require("./_commonjsHelpers-DHfMLFPC.js");
3
3
  const require$$0 = require("path");
4
- const index = require("./index-DNI4aUP2.js");
4
+ const index = require("./index-C-DW6ra2.js");
5
5
  const require$$0$1 = require("sharp");
6
6
  const require$$1 = require("fs");
7
7
  const require$$2 = require("fs/promises");
@@ -1,6 +1,6 @@
1
1
  import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-CUmg6egw.mjs";
2
2
  import require$$0 from "path";
3
- import { m as middlewares } from "./index-Tcyehi73.mjs";
3
+ import { m as middlewares } from "./index-D4j29ivg.mjs";
4
4
  import require$$0$1 from "sharp";
5
5
  import require$$1 from "fs";
6
6
  import require$$2 from "fs/promises";
@@ -2,7 +2,7 @@
2
2
  const _commonjsHelpers = require("./_commonjsHelpers-DHfMLFPC.js");
3
3
  const require$$0 = require("path");
4
4
  const queryProcessor = require("./queryProcessor-iewDZq_f.js");
5
- const index = require("./index-DNI4aUP2.js");
5
+ const index = require("./index-C-DW6ra2.js");
6
6
  const common_schema = require("./common.schema-BFhpUXUt.js");
7
7
  const engagement_schema = require("./engagement.schema-D-9md46B.js");
8
8
  const ownership_schema = require("./ownership.schema-DN0SlQL6.js");
@@ -1,7 +1,7 @@
1
1
  import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-CUmg6egw.mjs";
2
2
  import require$$0 from "path";
3
3
  import { q as queryProcessor } from "./queryProcessor-DQSFR9YA.mjs";
4
- import { m as middlewares } from "./index-Tcyehi73.mjs";
4
+ import { m as middlewares } from "./index-D4j29ivg.mjs";
5
5
  import { c as common_schema } from "./common.schema-ChBVARrs.mjs";
6
6
  import { e as engagement_schema } from "./engagement.schema-CCdSLKd4.mjs";
7
7
  import { o as ownership_schema } from "./ownership.schema-oyx6eNkZ.mjs";
@@ -0,0 +1,260 @@
1
+ "use strict";
2
+ const require$$0 = require("jsonwebtoken");
3
+ const require$$0$1 = require("crypto");
4
+ const require$$0$2 = require("mongodb");
5
+ var authJwt;
6
+ var hasRequiredAuthJwt;
7
+ function requireAuthJwt() {
8
+ if (hasRequiredAuthJwt) return authJwt;
9
+ hasRequiredAuthJwt = 1;
10
+ const jwt = require$$0;
11
+ const middlewareFactory = (db) => {
12
+ const User = db.user;
13
+ const Role = db.role;
14
+ const verifyToken = (continueOnFail = false) => {
15
+ return async (req, res, next) => {
16
+ try {
17
+ if (!req.cookies.user) {
18
+ console.log("NO COOKIE BITCH");
19
+ req.userId = null;
20
+ if (continueOnFail) {
21
+ return next();
22
+ } else {
23
+ return res.status(401).send({ message: "Unauthorized: No user cookie" });
24
+ }
25
+ }
26
+ let user = JSON.parse(req.cookies.user);
27
+ let token = req.headers["x-access-token"] || user.accessToken;
28
+ if (!token) {
29
+ req.userId = null;
30
+ if (continueOnFail) {
31
+ return next();
32
+ } else {
33
+ return res.status(401).send({ message: "Unauthorized: No token provided" });
34
+ }
35
+ }
36
+ const decoded = jwt.verify(token, process.env.SECRET_KEY);
37
+ req.userId = decoded._id;
38
+ next();
39
+ } catch (err) {
40
+ console.log(err);
41
+ req.userId = null;
42
+ if (continueOnFail) {
43
+ next();
44
+ } else {
45
+ res.status(401).send({ message: "Unauthorized: Invalid token" });
46
+ }
47
+ }
48
+ };
49
+ };
50
+ const checkRole = (roleToCheck) => async (req, res, next) => {
51
+ try {
52
+ const user = await User.findById(req.userId).exec();
53
+ if (!user) {
54
+ return res.status(404).send({ message: "User Not found." });
55
+ }
56
+ const roles = await Role.find({ _id: { $in: user.roles } }).exec();
57
+ for (let role of roles) {
58
+ if (role.name === roleToCheck) {
59
+ next();
60
+ return;
61
+ }
62
+ }
63
+ res.status(403).send({ message: `Require ${roleToCheck} Role!` });
64
+ } catch (err) {
65
+ res.status(500).send({ message: err.message });
66
+ }
67
+ };
68
+ const isAdmin = checkRole("admin");
69
+ const isModerator = checkRole("moderator");
70
+ return {
71
+ verifyToken,
72
+ isAdmin,
73
+ isModerator
74
+ };
75
+ };
76
+ authJwt = middlewareFactory;
77
+ return authJwt;
78
+ }
79
+ var authSecret;
80
+ var hasRequiredAuthSecret;
81
+ function requireAuthSecret() {
82
+ if (hasRequiredAuthSecret) return authSecret;
83
+ hasRequiredAuthSecret = 1;
84
+ const crypto = require$$0$1;
85
+ const middlewareFactory = () => {
86
+ const verifySecret = (method, endpoint, secret) => async (req, res, next) => {
87
+ const requestSignature = req.headers.signature;
88
+ const signature = crypto.createHmac("sha256", secret).update(method + endpoint).digest("hex");
89
+ if (signature === requestSignature) {
90
+ return next();
91
+ }
92
+ res.status(403).send("Forbidden");
93
+ };
94
+ return { verifySecret };
95
+ };
96
+ authSecret = middlewareFactory;
97
+ return authSecret;
98
+ }
99
+ var verifySignUp;
100
+ var hasRequiredVerifySignUp;
101
+ function requireVerifySignUp() {
102
+ if (hasRequiredVerifySignUp) return verifySignUp;
103
+ hasRequiredVerifySignUp = 1;
104
+ const middlewareFactory = (db) => {
105
+ const User = db.user;
106
+ db.role;
107
+ const checkDuplicateUsernameOrEmail = async (req, res, next) => {
108
+ const { type, email, phone } = req.body;
109
+ console.log(req.body);
110
+ let query;
111
+ if (type === "phone" && phone) {
112
+ query = { phone };
113
+ }
114
+ if (type === "email" && email) {
115
+ query = { email };
116
+ }
117
+ try {
118
+ const user = await User.findOne(query).exec();
119
+ if (user) {
120
+ console.log(`USER_ALREADY_REGISTERED`);
121
+ res.status(400).send({ errorCode: "USER_ALREADY_REGISTERED" });
122
+ return;
123
+ }
124
+ next();
125
+ } catch (err) {
126
+ console.log(err);
127
+ res.status(500).send({ message: err.message });
128
+ }
129
+ };
130
+ const checkRolesExisted = (req, res, next) => {
131
+ if (req.body.roles) {
132
+ for (let i = 0; i < req.body.roles.length; i++) {
133
+ if (!ROLES.includes(req.body.roles[i])) {
134
+ console.log(`Failed! Role ${req.body.roles[i]} does not exist!`);
135
+ res.status(400).send({
136
+ message: `Failed! Role ${req.body.roles[i]} does not exist!`
137
+ });
138
+ return;
139
+ }
140
+ }
141
+ }
142
+ next();
143
+ };
144
+ return {
145
+ checkDuplicateUsernameOrEmail,
146
+ checkRolesExisted
147
+ };
148
+ };
149
+ verifySignUp = middlewareFactory;
150
+ return verifySignUp;
151
+ }
152
+ var verifyUser;
153
+ var hasRequiredVerifyUser;
154
+ function requireVerifyUser() {
155
+ if (hasRequiredVerifyUser) return verifyUser;
156
+ hasRequiredVerifyUser = 1;
157
+ const middlewareFactory = (db) => {
158
+ const User = db.user;
159
+ db.role;
160
+ const checkUserExist = async (req, res, next) => {
161
+ const { type, email, phone } = req.body;
162
+ let query;
163
+ if (type === "phone" && phone) {
164
+ query = { phone };
165
+ }
166
+ if (type === "email" && email) {
167
+ query = { email };
168
+ }
169
+ try {
170
+ const user = await User.findOne(query).exec();
171
+ if (!user) {
172
+ console.log(query);
173
+ res.status(400).send({ errorCode: "USER_NOT_REGISTERED_YET" });
174
+ return;
175
+ }
176
+ next();
177
+ } catch (err) {
178
+ res.status(500).send({ message: err.message });
179
+ }
180
+ };
181
+ return {
182
+ checkUserExist
183
+ };
184
+ };
185
+ verifyUser = middlewareFactory;
186
+ return verifyUser;
187
+ }
188
+ var verifyInvites;
189
+ var hasRequiredVerifyInvites;
190
+ function requireVerifyInvites() {
191
+ if (hasRequiredVerifyInvites) return verifyInvites;
192
+ hasRequiredVerifyInvites = 1;
193
+ const { ObjectId } = require$$0$2;
194
+ const middlewareFactory = (db) => {
195
+ const User = db.user;
196
+ const Invite = db.invite;
197
+ const Membership = db.membership;
198
+ const checkInviteExist = async (req, res, next) => {
199
+ for (let invite of req.body.invites) {
200
+ let query;
201
+ if (invite.contact.includes("@")) {
202
+ query = { invitedEmail: invite.contact };
203
+ } else {
204
+ query = { invitedPhone: invite.contact };
205
+ }
206
+ query["owner.target"] = req.body.owner.target;
207
+ const userInvite = await Invite.findOne(query).exec();
208
+ if (userInvite) {
209
+ console.log(userInvite);
210
+ res.status(400).send({ message: "Инвайт c таким email или телефоном уже создан!" });
211
+ return;
212
+ }
213
+ }
214
+ next();
215
+ };
216
+ const checkUsersExist = async (req, res, next) => {
217
+ for (let invite of req.body.invites) {
218
+ let query;
219
+ if (invite.contact.includes("@")) {
220
+ query = { email: invite.contact };
221
+ } else {
222
+ query = { phone: invite.contact };
223
+ }
224
+ const user = await User.findOne(query).exec();
225
+ console.log(req.params);
226
+ if (user) {
227
+ const membership = await Membership.findOne({ user: new ObjectId(user._id), "owner.target": req.body.owner.target }).exec();
228
+ if (membership) {
229
+ console.log(membership);
230
+ res.status(400).send({ message: "Пользователь с таким email или телефоном уже добавлен в организацию!" });
231
+ return;
232
+ }
233
+ }
234
+ }
235
+ next();
236
+ };
237
+ return {
238
+ checkInviteExist,
239
+ checkUsersExist
240
+ };
241
+ };
242
+ verifyInvites = middlewareFactory;
243
+ return verifyInvites;
244
+ }
245
+ const middlewareIndexFactory = (db) => {
246
+ const authJwt2 = requireAuthJwt()(db);
247
+ const authSecret2 = requireAuthSecret()();
248
+ const verifySignUp2 = requireVerifySignUp()(db);
249
+ const verifyUser2 = requireVerifyUser()(db);
250
+ const verifyInvites2 = requireVerifyInvites()(db);
251
+ return {
252
+ authJwt: authJwt2,
253
+ authSecret: authSecret2,
254
+ verifySignUp: verifySignUp2,
255
+ verifyUser: verifyUser2,
256
+ verifyInvites: verifyInvites2
257
+ };
258
+ };
259
+ var middlewares = middlewareIndexFactory;
260
+ exports.middlewares = middlewares;
@@ -0,0 +1,261 @@
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
+ console.log("NO COOKIE BITCH");
18
+ req.userId = null;
19
+ if (continueOnFail) {
20
+ return next();
21
+ } else {
22
+ return res.status(401).send({ message: "Unauthorized: No user cookie" });
23
+ }
24
+ }
25
+ let user = JSON.parse(req.cookies.user);
26
+ let token = req.headers["x-access-token"] || user.accessToken;
27
+ if (!token) {
28
+ req.userId = null;
29
+ if (continueOnFail) {
30
+ return next();
31
+ } else {
32
+ return res.status(401).send({ message: "Unauthorized: No token provided" });
33
+ }
34
+ }
35
+ const decoded = jwt.verify(token, process.env.SECRET_KEY);
36
+ req.userId = decoded._id;
37
+ next();
38
+ } catch (err) {
39
+ console.log(err);
40
+ req.userId = null;
41
+ if (continueOnFail) {
42
+ next();
43
+ } else {
44
+ res.status(401).send({ message: "Unauthorized: Invalid token" });
45
+ }
46
+ }
47
+ };
48
+ };
49
+ const checkRole = (roleToCheck) => async (req, res, next) => {
50
+ try {
51
+ const user = await User.findById(req.userId).exec();
52
+ if (!user) {
53
+ return res.status(404).send({ message: "User Not found." });
54
+ }
55
+ const roles = await Role.find({ _id: { $in: user.roles } }).exec();
56
+ for (let role of roles) {
57
+ if (role.name === roleToCheck) {
58
+ next();
59
+ return;
60
+ }
61
+ }
62
+ res.status(403).send({ message: `Require ${roleToCheck} Role!` });
63
+ } catch (err) {
64
+ res.status(500).send({ message: err.message });
65
+ }
66
+ };
67
+ const isAdmin = checkRole("admin");
68
+ const isModerator = checkRole("moderator");
69
+ return {
70
+ verifyToken,
71
+ isAdmin,
72
+ isModerator
73
+ };
74
+ };
75
+ authJwt = middlewareFactory;
76
+ return authJwt;
77
+ }
78
+ var authSecret;
79
+ var hasRequiredAuthSecret;
80
+ function requireAuthSecret() {
81
+ if (hasRequiredAuthSecret) return authSecret;
82
+ hasRequiredAuthSecret = 1;
83
+ const crypto = require$$0$1;
84
+ const middlewareFactory = () => {
85
+ const verifySecret = (method, endpoint, secret) => async (req, res, next) => {
86
+ const requestSignature = req.headers.signature;
87
+ const signature = crypto.createHmac("sha256", secret).update(method + endpoint).digest("hex");
88
+ if (signature === requestSignature) {
89
+ return next();
90
+ }
91
+ res.status(403).send("Forbidden");
92
+ };
93
+ return { verifySecret };
94
+ };
95
+ authSecret = middlewareFactory;
96
+ return authSecret;
97
+ }
98
+ var verifySignUp;
99
+ var hasRequiredVerifySignUp;
100
+ function requireVerifySignUp() {
101
+ if (hasRequiredVerifySignUp) return verifySignUp;
102
+ hasRequiredVerifySignUp = 1;
103
+ const middlewareFactory = (db) => {
104
+ const User = db.user;
105
+ db.role;
106
+ const checkDuplicateUsernameOrEmail = async (req, res, next) => {
107
+ const { type, email, phone } = req.body;
108
+ console.log(req.body);
109
+ let query;
110
+ if (type === "phone" && phone) {
111
+ query = { phone };
112
+ }
113
+ if (type === "email" && email) {
114
+ query = { email };
115
+ }
116
+ try {
117
+ const user = await User.findOne(query).exec();
118
+ if (user) {
119
+ console.log(`USER_ALREADY_REGISTERED`);
120
+ res.status(400).send({ errorCode: "USER_ALREADY_REGISTERED" });
121
+ return;
122
+ }
123
+ next();
124
+ } catch (err) {
125
+ console.log(err);
126
+ res.status(500).send({ message: err.message });
127
+ }
128
+ };
129
+ const checkRolesExisted = (req, res, next) => {
130
+ if (req.body.roles) {
131
+ for (let i = 0; i < req.body.roles.length; i++) {
132
+ if (!ROLES.includes(req.body.roles[i])) {
133
+ console.log(`Failed! Role ${req.body.roles[i]} does not exist!`);
134
+ res.status(400).send({
135
+ message: `Failed! Role ${req.body.roles[i]} does not exist!`
136
+ });
137
+ return;
138
+ }
139
+ }
140
+ }
141
+ next();
142
+ };
143
+ return {
144
+ checkDuplicateUsernameOrEmail,
145
+ checkRolesExisted
146
+ };
147
+ };
148
+ verifySignUp = middlewareFactory;
149
+ return verifySignUp;
150
+ }
151
+ var verifyUser;
152
+ var hasRequiredVerifyUser;
153
+ function requireVerifyUser() {
154
+ if (hasRequiredVerifyUser) return verifyUser;
155
+ hasRequiredVerifyUser = 1;
156
+ const middlewareFactory = (db) => {
157
+ const User = db.user;
158
+ db.role;
159
+ const checkUserExist = async (req, res, next) => {
160
+ const { type, email, phone } = req.body;
161
+ let query;
162
+ if (type === "phone" && phone) {
163
+ query = { phone };
164
+ }
165
+ if (type === "email" && email) {
166
+ query = { email };
167
+ }
168
+ try {
169
+ const user = await User.findOne(query).exec();
170
+ if (!user) {
171
+ console.log(query);
172
+ res.status(400).send({ errorCode: "USER_NOT_REGISTERED_YET" });
173
+ return;
174
+ }
175
+ next();
176
+ } catch (err) {
177
+ res.status(500).send({ message: err.message });
178
+ }
179
+ };
180
+ return {
181
+ checkUserExist
182
+ };
183
+ };
184
+ verifyUser = middlewareFactory;
185
+ return verifyUser;
186
+ }
187
+ var verifyInvites;
188
+ var hasRequiredVerifyInvites;
189
+ function requireVerifyInvites() {
190
+ if (hasRequiredVerifyInvites) return verifyInvites;
191
+ hasRequiredVerifyInvites = 1;
192
+ const { ObjectId } = require$$0$2;
193
+ const middlewareFactory = (db) => {
194
+ const User = db.user;
195
+ const Invite = db.invite;
196
+ const Membership = db.membership;
197
+ const checkInviteExist = async (req, res, next) => {
198
+ for (let invite of req.body.invites) {
199
+ let query;
200
+ if (invite.contact.includes("@")) {
201
+ query = { invitedEmail: invite.contact };
202
+ } else {
203
+ query = { invitedPhone: invite.contact };
204
+ }
205
+ query["owner.target"] = req.body.owner.target;
206
+ const userInvite = await Invite.findOne(query).exec();
207
+ if (userInvite) {
208
+ console.log(userInvite);
209
+ res.status(400).send({ message: "Инвайт c таким email или телефоном уже создан!" });
210
+ return;
211
+ }
212
+ }
213
+ next();
214
+ };
215
+ const checkUsersExist = async (req, res, next) => {
216
+ for (let invite of req.body.invites) {
217
+ let query;
218
+ if (invite.contact.includes("@")) {
219
+ query = { email: invite.contact };
220
+ } else {
221
+ query = { phone: invite.contact };
222
+ }
223
+ const user = await User.findOne(query).exec();
224
+ console.log(req.params);
225
+ if (user) {
226
+ const membership = await Membership.findOne({ user: new ObjectId(user._id), "owner.target": req.body.owner.target }).exec();
227
+ if (membership) {
228
+ console.log(membership);
229
+ res.status(400).send({ message: "Пользователь с таким email или телефоном уже добавлен в организацию!" });
230
+ return;
231
+ }
232
+ }
233
+ }
234
+ next();
235
+ };
236
+ return {
237
+ checkInviteExist,
238
+ checkUsersExist
239
+ };
240
+ };
241
+ verifyInvites = middlewareFactory;
242
+ return verifyInvites;
243
+ }
244
+ const middlewareIndexFactory = (db) => {
245
+ const authJwt2 = requireAuthJwt()(db);
246
+ const authSecret2 = requireAuthSecret()();
247
+ const verifySignUp2 = requireVerifySignUp()(db);
248
+ const verifyUser2 = requireVerifyUser()(db);
249
+ const verifyInvites2 = requireVerifyInvites()(db);
250
+ return {
251
+ authJwt: authJwt2,
252
+ authSecret: authSecret2,
253
+ verifySignUp: verifySignUp2,
254
+ verifyUser: verifyUser2,
255
+ verifyInvites: verifyInvites2
256
+ };
257
+ };
258
+ var middlewares = middlewareIndexFactory;
259
+ export {
260
+ middlewares as m
261
+ };
@@ -5,7 +5,7 @@ const profile_schema = require("./profile.schema-CkOhhf37.js");
5
5
  const credentials_schema = require("./credentials.schema-B-KD_ozQ.js");
6
6
  const queryProcessor = require("./queryProcessor-iewDZq_f.js");
7
7
  const mailing = require("./mailing-BX0q8DIs.js");
8
- const index = require("./index-DNI4aUP2.js");
8
+ const index = require("./index-C-DW6ra2.js");
9
9
  const require$$0 = require("node-cache");
10
10
  const applyOwnershipSchema$1 = ownership_schema.ownership_schema;
11
11
  var order_model = (db) => {
@@ -4,7 +4,7 @@ import { p as profile_schema } from "./profile.schema-24ZpZQJe.mjs";
4
4
  import { c as credentials_schema } from "./credentials.schema-C9dmNy7o.mjs";
5
5
  import { q as queryProcessor } from "./queryProcessor-DQSFR9YA.mjs";
6
6
  import { m as mailing } from "./mailing-Cdp8NXhP.mjs";
7
- import { m as middlewares } from "./index-Tcyehi73.mjs";
7
+ import { m as middlewares } from "./index-D4j29ivg.mjs";
8
8
  import require$$0 from "node-cache";
9
9
  const applyOwnershipSchema$1 = ownership_schema;
10
10
  var order_model = (db) => {
@@ -9,7 +9,7 @@ const require$$5 = require("@googlemaps/google-maps-services-js");
9
9
  const addMembersQuantity$1 = require("./addMembersQuantity-B8UgqlUM.js");
10
10
  const queryProcessor = require("./queryProcessor-iewDZq_f.js");
11
11
  const mailing = require("./mailing-BX0q8DIs.js");
12
- const index = require("./index-DNI4aUP2.js");
12
+ const index = require("./index-C-DW6ra2.js");
13
13
  const engagement_schema = require("./engagement.schema-D-9md46B.js");
14
14
  const ownership_schema = require("./ownership.schema-DN0SlQL6.js");
15
15
  const credentials_schema = require("./credentials.schema-B-KD_ozQ.js");
@@ -8,7 +8,7 @@ import require$$5 from "@googlemaps/google-maps-services-js";
8
8
  import { a as addUserStatusFields_1, b as addMembersQuantity_1 } from "./addMembersQuantity-BXp_LeQd.mjs";
9
9
  import { q as queryProcessor } from "./queryProcessor-DQSFR9YA.mjs";
10
10
  import { m as mailing } from "./mailing-Cdp8NXhP.mjs";
11
- import { m as middlewares } from "./index-Tcyehi73.mjs";
11
+ import { m as middlewares } from "./index-D4j29ivg.mjs";
12
12
  import { e as engagement_schema } from "./engagement.schema-CCdSLKd4.mjs";
13
13
  import { o as ownership_schema } from "./ownership.schema-oyx6eNkZ.mjs";
14
14
  import { c as credentials_schema } from "./credentials.schema-C9dmNy7o.mjs";