@ozdao/prometheus-framework 0.2.143 → 0.2.144

Sign up to get free protection for your applications and to get access to all the features.
@@ -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";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("axios"),l=require("../../../../../node_modules/js-cookie/dist/js.cookie.cjs"),d=require("../../../../node_modules/@capacitor/preferences/dist/esm/index.cjs"),O=require("vue"),c=require("../../globals/store/globals.cjs"),k=require("./twofa.cjs"),i=g.create({baseURL:process.env.API_URL,withCredentials:!0}),r=O.reactive({user:{_id:void 0,username:"",email:"",phone:"",password:"",passwordRepeat:""},access:{roles:null,token:null,status:!1},accesses:[]});async function w(){try{const e=await j("user");if(e){const{_id:t,email:s,phone:n,roles:o,accessToken:a}=e;g.interceptors.request.use(u=>(u.headers["x-access-token"]=a,u),u=>Promise.reject(u));const h=(await i.get("/api/auth/check-accesses")).data;Object.assign(r.user,{_id:t,email:s,phone:n}),Object.assign(r.access,{token:a,roles:o,status:!!a}),r.accesses=h}}catch(e){console.error("Error initializing app:",e),f("user"),r.accesses=[]}}w();const m={async login(e,t){try{const s=await i.post("/api/auth/signin",{...e,type:t});return p("user",s.data),Object.assign(r.user,{...s.data}),Object.assign(r.access,{token:s.data.accessToken,status:!0,roles:s.data.roles}),s.data}catch(s){return Object.assign(r.access,{token:null,status:!1,roles:null}),console.log(s),c.setError(s),Promise.reject(s)}},async signup(e,t,s){const{password:n,passwordRepeat:o}=r.user;if(console.log(n),console.log(o),n!==o){const a={response:{data:{errorCode:"PASSWORDS_DO_NOT_MATCH"}}};throw c.setError(a),new Error(a.response.status)}try{const a=await i.post("/api/auth/signup",{...e,type:t,inviteCode:s});return console.log(a),a.data.accessToken&&p("user",a.data),Object.assign(r.user,{...a.data}),Object.assign(r.access,{token:a.data.accessToken,status:!0,roles:a.data.roles}),await w(),a.data}catch(a){throw c.setError(a),console.log("Sign up falied"),a}},logout(){f("user"),Object.assign(r.user,{_id:void 0,username:"",email:"",phone:"",password:"",passwordRepeat:""}),Object.assign(r.access,{roles:null,token:null,status:!1}),r.accesses=[]},async resetPassword(e,t){try{const s=await i.post("/api/auth/reset-password",{email:e.email,phone:e.phone,type:t});return Object.assign(k.state.code,{...s.data,isSended:!0}),s.data}catch(s){return c.setError(s),Promise.reject(s)}},async updatePassword(e,t){const{password:s,passwordRepeat:n}=r.user;if(s!==n){const o={response:{data:{errorCode:"PASSWORDS_DO_NOT_MATCH"}}};throw c.setError(o),new Error(o.response.status)}try{const o=await i.post("/api/auth/update-password",{email:e.email,phone:e.phone,password:e.password,passwordRepeat:e.passwordRepeat,type:t});return o.data.accessToken&&p("user",o.data),Object.assign(r.user,{...o.data}),Object.assign(r.access,{token:o.data.accessToken,status:!0}),o.data}catch(o){return c.setError(o),Promise.reject(o)}}},P={development:{secure:!1,expires:7,sameSite:"Lax"},production:{expires:7,path:"/",domain:process.env.DOMAIN_URL,sameSite:"none",secure:!0}};async function j(e){if(process.env.MOBILE_APP){const{value:t}=await d.Preferences.get({key:e});return t?JSON.parse(t):null}else{const t=l.default.get(e);return t?JSON.parse(t):null}}function p(e,t,s=process.env.DOMAIN_URL){process.env.MOBILE_APP?d.Preferences.set({key:e,value:JSON.stringify(t)}):l.default.set(e,JSON.stringify(t),P[s])}function f(e,t=process.env.NODE_ENV){if(process.env.MOBILE_APP)d.Preferences.remove({key:e});else{const s=t==="production"?{domain:process.env.DOMAIN_URL}:{};l.default.remove(e,s)}}O.watch(r,(e,t)=>{});exports.actions=m;exports.initialize=w;exports.state=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("axios"),w=require("../../../../../node_modules/js-cookie/dist/js.cookie.cjs"),g=require("../../../../node_modules/@capacitor/preferences/dist/esm/index.cjs"),O=require("vue"),c=require("../../globals/store/globals.cjs"),k=require("./twofa.cjs"),u=d.create({baseURL:process.env.API_URL,withCredentials:!0}),r=O.reactive({user:{_id:void 0,username:"",email:"",phone:"",password:"",passwordRepeat:""},access:{roles:null,token:null,status:!1},accesses:[]});async function p(){try{const e=await j("user");if(e){const{_id:t,email:s,phone:n,roles:o,accessToken:a}=e;d.interceptors.request.use(i=>(i.headers["x-access-token"]=a,i),i=>Promise.reject(i));const h=(await d.get("/api/auth/check-accesses")).data;Object.assign(r.user,{_id:t,email:s,phone:n}),Object.assign(r.access,{token:a,roles:o,status:!!a}),r.accesses=h}}catch(e){console.error("Error initializing app:",e),f("user"),r.accesses=[]}}p();const m={async login(e,t){try{const s=await u.post("/api/auth/signin",{...e,type:t});return l("user",s.data),Object.assign(r.user,{...s.data}),Object.assign(r.access,{token:s.data.accessToken,status:!0,roles:s.data.roles}),await p(),s.data}catch(s){return Object.assign(r.access,{token:null,status:!1,roles:null}),console.log(s),c.setError(s),Promise.reject(s)}},async signup(e,t,s){const{password:n,passwordRepeat:o}=r.user;if(console.log(n),console.log(o),n!==o){const a={response:{data:{errorCode:"PASSWORDS_DO_NOT_MATCH"}}};throw c.setError(a),new Error(a.response.status)}try{const a=await u.post("/api/auth/signup",{...e,type:t,inviteCode:s});return console.log(a),a.data.accessToken&&l("user",a.data),Object.assign(r.user,{...a.data}),Object.assign(r.access,{token:a.data.accessToken,status:!0,roles:a.data.roles}),await p(),a.data}catch(a){throw c.setError(a),console.log("Sign up falied"),a}},logout(){f("user"),Object.assign(r.user,{_id:void 0,username:"",email:"",phone:"",password:"",passwordRepeat:""}),Object.assign(r.access,{roles:null,token:null,status:!1}),r.accesses=[]},async resetPassword(e,t){try{const s=await u.post("/api/auth/reset-password",{email:e.email,phone:e.phone,type:t});return Object.assign(k.state.code,{...s.data,isSended:!0}),s.data}catch(s){return c.setError(s),Promise.reject(s)}},async updatePassword(e,t){const{password:s,passwordRepeat:n}=r.user;if(s!==n){const o={response:{data:{errorCode:"PASSWORDS_DO_NOT_MATCH"}}};throw c.setError(o),new Error(o.response.status)}try{const o=await u.post("/api/auth/update-password",{email:e.email,phone:e.phone,password:e.password,passwordRepeat:e.passwordRepeat,type:t});return o.data.accessToken&&l("user",o.data),Object.assign(r.user,{...o.data}),Object.assign(r.access,{token:o.data.accessToken,status:!0}),o.data}catch(o){return c.setError(o),Promise.reject(o)}}},P={development:{secure:!1,expires:7,sameSite:"Lax"},production:{expires:7,path:"/",domain:process.env.DOMAIN_URL,sameSite:"none",secure:!0}};async function j(e){if(process.env.MOBILE_APP){const{value:t}=await g.Preferences.get({key:e});return t?JSON.parse(t):null}else{const t=w.default.get(e);return t?JSON.parse(t):null}}function l(e,t,s=process.env.DOMAIN_URL){process.env.MOBILE_APP?g.Preferences.set({key:e,value:JSON.stringify(t)}):w.default.set(e,JSON.stringify(t),P[s])}function f(e,t=process.env.NODE_ENV){if(process.env.MOBILE_APP)g.Preferences.remove({key:e});else{const s=t==="production"?{domain:process.env.DOMAIN_URL}:{};w.default.remove(e,s)}}O.watch(r,(e,t)=>{});exports.actions=m;exports.initialize=p;exports.state=r;
@@ -1,10 +1,10 @@
1
- import w from "axios";
2
- import d from "../../../../../node_modules/js-cookie/dist/js.cookie.js";
3
- import { Preferences as l } from "../../../../node_modules/@capacitor/preferences/dist/esm/index.js";
1
+ import d from "axios";
2
+ import w from "../../../../../node_modules/js-cookie/dist/js.cookie.js";
3
+ import { Preferences as m } from "../../../../node_modules/@capacitor/preferences/dist/esm/index.js";
4
4
  import { reactive as f, watch as h } from "vue";
5
5
  import { setError as c } from "../../globals/store/globals.js";
6
6
  import { state as k } from "./twofa.js";
7
- const i = w.create({ baseURL: process.env.API_URL, withCredentials: !0 }), r = f({
7
+ const p = d.create({ baseURL: process.env.API_URL, withCredentials: !0 }), r = f({
8
8
  user: {
9
9
  _id: void 0,
10
10
  username: "",
@@ -20,24 +20,24 @@ const i = w.create({ baseURL: process.env.API_URL, withCredentials: !0 }), r = f
20
20
  },
21
21
  accesses: []
22
22
  });
23
- async function m() {
23
+ async function l() {
24
24
  try {
25
25
  const e = await j("user");
26
26
  if (e) {
27
27
  const { _id: t, email: s, phone: n, roles: o, accessToken: a } = e;
28
- w.interceptors.request.use((p) => (p.headers["x-access-token"] = a, p), (p) => Promise.reject(p));
29
- const O = (await i.get("/api/auth/check-accesses")).data;
28
+ d.interceptors.request.use((i) => (i.headers["x-access-token"] = a, i), (i) => Promise.reject(i));
29
+ const O = (await d.get("/api/auth/check-accesses")).data;
30
30
  Object.assign(r.user, { _id: t, email: s, phone: n }), Object.assign(r.access, { token: a, roles: o, status: !!a }), r.accesses = O;
31
31
  }
32
32
  } catch (e) {
33
33
  console.error("Error initializing app:", e), g("user"), r.accesses = [];
34
34
  }
35
35
  }
36
- m();
36
+ l();
37
37
  const N = {
38
38
  async login(e, t) {
39
39
  try {
40
- const s = await i.post("/api/auth/signin", {
40
+ const s = await p.post("/api/auth/signin", {
41
41
  ...e,
42
42
  type: t
43
43
  });
@@ -47,7 +47,7 @@ const N = {
47
47
  token: s.data.accessToken,
48
48
  status: !0,
49
49
  roles: s.data.roles
50
- }), s.data;
50
+ }), await l(), s.data;
51
51
  } catch (s) {
52
52
  return Object.assign(r.access, {
53
53
  token: null,
@@ -67,7 +67,7 @@ const N = {
67
67
  throw c(a), new Error(a.response.status);
68
68
  }
69
69
  try {
70
- const a = await i.post("/api/auth/signup", {
70
+ const a = await p.post("/api/auth/signup", {
71
71
  ...e,
72
72
  type: t,
73
73
  inviteCode: s
@@ -78,7 +78,7 @@ const N = {
78
78
  token: a.data.accessToken,
79
79
  status: !0,
80
80
  roles: a.data.roles
81
- }), await m(), a.data;
81
+ }), await l(), a.data;
82
82
  } catch (a) {
83
83
  throw c(a), console.log("Sign up falied"), a;
84
84
  }
@@ -99,7 +99,7 @@ const N = {
99
99
  },
100
100
  async resetPassword(e, t) {
101
101
  try {
102
- const s = await i.post("/api/auth/reset-password", {
102
+ const s = await p.post("/api/auth/reset-password", {
103
103
  email: e.email,
104
104
  phone: e.phone,
105
105
  type: t
@@ -123,7 +123,7 @@ const N = {
123
123
  throw c(o), new Error(o.response.status);
124
124
  }
125
125
  try {
126
- const o = await i.post("/api/auth/update-password", {
126
+ const o = await p.post("/api/auth/update-password", {
127
127
  email: e.email,
128
128
  phone: e.phone,
129
129
  password: e.password,
@@ -146,31 +146,31 @@ const N = {
146
146
  };
147
147
  async function j(e) {
148
148
  if (process.env.MOBILE_APP) {
149
- const { value: t } = await l.get({ key: e });
149
+ const { value: t } = await m.get({ key: e });
150
150
  return t ? JSON.parse(t) : null;
151
151
  } else {
152
- const t = d.get(e);
152
+ const t = w.get(e);
153
153
  return t ? JSON.parse(t) : null;
154
154
  }
155
155
  }
156
156
  function u(e, t, s = process.env.DOMAIN_URL) {
157
- process.env.MOBILE_APP ? l.set({
157
+ process.env.MOBILE_APP ? m.set({
158
158
  key: e,
159
159
  value: JSON.stringify(t)
160
- }) : d.set(e, JSON.stringify(t), _[s]);
160
+ }) : w.set(e, JSON.stringify(t), _[s]);
161
161
  }
162
162
  function g(e, t = process.env.NODE_ENV) {
163
163
  if (process.env.MOBILE_APP)
164
- l.remove({ key: e });
164
+ m.remove({ key: e });
165
165
  else {
166
166
  const s = t === "production" ? { domain: process.env.DOMAIN_URL } : {};
167
- d.remove(e, s);
167
+ w.remove(e, s);
168
168
  }
169
169
  }
170
170
  h(r, (e, t) => {
171
171
  });
172
172
  export {
173
173
  N as actions,
174
- m as initialize,
174
+ l as initialize,
175
175
  r as state
176
176
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const _=require("./main-gY_284gJ.js");exports.Address=_._sfc_main;exports.Breadcrumbs=_._sfc_main$16;exports.Button=_._sfc_main$1;exports.Checkbox=_._sfc_main$2;exports.Chips=_._sfc_main$17;exports.Countdown=_._sfc_main$18;exports.DatePicker=_._sfc_main$19;exports.Dropdown=_._sfc_main$3;exports.EmptyState=_._sfc_main$20;exports.Error=_._sfc_main$4;exports.Feed=_._sfc_main$21;exports.Field=_._sfc_main$5;exports.FieldBig=_._sfc_main$22;exports.FieldPhone=_._sfc_main$6;exports.FieldTags=_.FieldTags;exports.Loader=_.Loader;exports.LocationMarker=_._sfc_main$7;exports.Map=_.Map;exports.Marquee=_._sfc_main$27;exports.Popup=_._sfc_main$8;exports.Radio=_._sfc_main$9;exports.Select=_.Select;exports.SelectMulti=_.SelectMulti;exports.Shader=_._sfc_main$23;exports.Sidebar=_._sfc_main$24;exports.Slider=_._sfc_main$25;exports.Spoiler=_._sfc_main$10;exports.Status=_._sfc_main$26;exports.Tab=_._sfc_main$11;exports.Text=_._sfc_main$13;exports.Tooltip=_._sfc_main$12;exports.Upload=_.Upload;exports.UploadImage=_._sfc_main$14;exports.UploadImageMultiple=_._sfc_main$15;exports.default=_.main;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const _=require("./main-BF_nMkug.js");exports.Address=_._sfc_main;exports.Breadcrumbs=_._sfc_main$16;exports.Button=_._sfc_main$1;exports.Checkbox=_._sfc_main$2;exports.Chips=_._sfc_main$17;exports.Countdown=_._sfc_main$18;exports.DatePicker=_._sfc_main$19;exports.Dropdown=_._sfc_main$3;exports.EmptyState=_._sfc_main$20;exports.Error=_._sfc_main$4;exports.Feed=_._sfc_main$21;exports.Field=_._sfc_main$5;exports.FieldBig=_._sfc_main$22;exports.FieldPhone=_._sfc_main$6;exports.FieldTags=_.FieldTags;exports.Loader=_.Loader;exports.LocationMarker=_._sfc_main$7;exports.Map=_.Map;exports.Marquee=_._sfc_main$27;exports.Popup=_._sfc_main$8;exports.Radio=_._sfc_main$9;exports.Select=_.Select;exports.SelectMulti=_.SelectMulti;exports.Shader=_._sfc_main$23;exports.Sidebar=_._sfc_main$24;exports.Slider=_._sfc_main$25;exports.Spoiler=_._sfc_main$10;exports.Status=_._sfc_main$26;exports.Tab=_._sfc_main$11;exports.Text=_._sfc_main$13;exports.Tooltip=_._sfc_main$12;exports.Upload=_.Upload;exports.UploadImage=_._sfc_main$14;exports.UploadImageMultiple=_._sfc_main$15;exports.default=_.main;
@@ -1,4 +1,4 @@
1
- import { _ as e, r as o, a as d, b as r, s as t, t as l, u as i, c as p, v as u, d as S, w as c, e as n, x as m, f as F, F as M, L as b, g, M as h, C as k, h as x, i as B, S as C, j as T, y as U, z as f, A as w, k as L, B as P, l as q, o as y, n as A, U as D, p as E, q as I, m as j } from "./main-3Vn8SU2y.mjs";
1
+ import { _ as e, r as o, a as d, b as r, s as t, t as l, u as i, c as p, v as u, d as S, w as c, e as n, x as m, f as F, F as M, L as b, g, M as h, C as k, h as x, i as B, S as C, j as T, y as U, z as f, A as w, k as L, B as P, l as q, o as y, n as A, U as D, p as E, q as I, m as j } from "./main-BHr0-Z3t.mjs";
2
2
  export {
3
3
  e as Address,
4
4
  o as Breadcrumbs,
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const _commonjsHelpers = require("./_commonjsHelpers-DHfMLFPC.js");
3
- const index = require("./index-DNI4aUP2.js");
3
+ const index = require("./index-C-DW6ra2.js");
4
4
  require("axios");
5
5
  require("bcryptjs");
6
6
  require("crypto");
@@ -1,5 +1,5 @@
1
1
  import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-CUmg6egw.mjs";
2
- import { m as middlewares } from "./index-Tcyehi73.mjs";
2
+ import { m as middlewares } from "./index-D4j29ivg.mjs";
3
3
  import "axios";
4
4
  import "bcryptjs";
5
5
  import "crypto";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ozdao/prometheus-framework",
3
- "version": "0.2.143",
3
+ "version": "0.2.144",
4
4
  "description": "Web3 Framework focused on user experience and ease of development.",
5
5
  "author": "OZ DAO <hello@ozdao.dev>",
6
6
  "license": "GPL-3.0-or-later",
@@ -8,6 +8,7 @@ const middlewareFactory = (db) => {
8
8
  return async (req, res, next) => {
9
9
  try {
10
10
  if (!req.cookies.user) {
11
+ console.log('NO COOKIE BITCH')
11
12
  req.userId = null;
12
13
  if (continueOnFail) {
13
14
  return next();
@@ -46,7 +46,7 @@
46
46
  });
47
47
 
48
48
  // Проверка токена через серверный маршрут
49
- const response = await $axios.get('/api/auth/check-accesses');
49
+ const response = await axios.get('/api/auth/check-accesses');
50
50
  const userAccesses = response.data;
51
51
 
52
52
  // Обновление состояния приложения с информацией о пользователе и его правах доступа
@@ -85,7 +85,7 @@
85
85
  roles: response.data.roles
86
86
  });
87
87
 
88
- // await initialize();
88
+ await initialize();
89
89
 
90
90
  return response.data;
91
91
  } catch (error) {