biz-slide-core 1.2.86 → 1.2.88

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AnalyticModel = void 0;
4
- var mongoose_1 = require("mongoose");
5
- var eventSchema = new mongoose_1.Schema({
4
+ const mongoose_1 = require("mongoose");
5
+ const eventSchema = new mongoose_1.Schema({
6
6
  name: { type: String, required: true },
7
7
  count: { type: Number, default: 0 }
8
8
  }, {
9
9
  timestamps: false,
10
10
  _id: false
11
11
  });
12
- var layoutAnalyticsSchema = new mongoose_1.Schema({
12
+ const layoutAnalyticsSchema = new mongoose_1.Schema({
13
13
  name: { type: String, required: true },
14
14
  count: { type: Number, default: 0 },
15
15
  percentage: { type: Number, default: 0 }
@@ -17,7 +17,7 @@ var layoutAnalyticsSchema = new mongoose_1.Schema({
17
17
  timestamps: false,
18
18
  _id: false
19
19
  });
20
- var AnalyticSchema = new mongoose_1.Schema({
20
+ const AnalyticSchema = new mongoose_1.Schema({
21
21
  templateTypeId: { type: mongoose_1.Schema.Types.ObjectId, ref: "template-type" },
22
22
  appName: { type: String, required: true },
23
23
  noOfPPT: { type: Number, default: 0 },
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ConfigModel = void 0;
4
- var mongoose_1 = require("mongoose");
5
- var CongigSchema = new mongoose_1.Schema({
4
+ const mongoose_1 = require("mongoose");
5
+ const CongigSchema = new mongoose_1.Schema({
6
6
  configType: { type: String, required: true },
7
7
  value: { type: String, required: true },
8
8
  }, {
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CronModel = void 0;
4
- var mongoose_1 = require("mongoose");
5
- var CronSchema = new mongoose_1.Schema({
4
+ const mongoose_1 = require("mongoose");
5
+ const CronSchema = new mongoose_1.Schema({
6
6
  name: { type: String, required: true },
7
7
  status: { type: Boolean, default: false }
8
8
  }, {
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CustomerModel = void 0;
4
- var mongoose_1 = require("mongoose");
5
- var EmailTemplateStatusSchema = new mongoose_1.Schema({
4
+ const mongoose_1 = require("mongoose");
5
+ const EmailTemplateStatusSchema = new mongoose_1.Schema({
6
6
  sent: { type: Boolean, default: false },
7
7
  }, {
8
8
  timestamps: false,
9
9
  _id: false
10
10
  });
11
- var CustomerSchema = new mongoose_1.Schema({
11
+ const CustomerSchema = new mongoose_1.Schema({
12
12
  appName: { type: String, required: true },
13
13
  userId: { type: String, required: true },
14
14
  emailId: { type: String, default: "" },
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ImageModel = void 0;
4
- var mongoose_1 = require("mongoose");
5
- var ImageSchema = new mongoose_1.Schema({
4
+ const mongoose_1 = require("mongoose");
5
+ const ImageSchema = new mongoose_1.Schema({
6
6
  focusPoint: { x: Number, y: Number },
7
7
  url: { type: String, required: true },
8
8
  radius: { type: String, required: true },
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LogsModel = void 0;
4
- var mongoose_1 = require("mongoose");
5
- var LogsSchema = new mongoose_1.Schema({
4
+ const mongoose_1 = require("mongoose");
5
+ const LogsSchema = new mongoose_1.Schema({
6
6
  type: { type: String, required: true },
7
7
  event: { type: String, required: true },
8
8
  message: { type: String, required: true },
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PngSvgModel = void 0;
4
- var mongoose_1 = require("mongoose");
5
- var PngSvgSchema = new mongoose_1.Schema({
4
+ const mongoose_1 = require("mongoose");
5
+ const PngSvgSchema = new mongoose_1.Schema({
6
6
  deletedAt: { type: Date, default: null },
7
7
  isLocked: { type: Boolean, default: false },
8
8
  optionsDownloaded: mongoose_1.Schema.Types.Mixed,
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PPTEmailQueueModel = void 0;
4
- var mongoose_1 = require("mongoose");
5
- var PPTEmailQueueSchema = new mongoose_1.Schema({
4
+ const mongoose_1 = require("mongoose");
5
+ const PPTEmailQueueSchema = new mongoose_1.Schema({
6
6
  pptRef: { type: mongoose_1.Schema.Types.ObjectId, ref: 'ppt' },
7
7
  emailType: { type: String, required: true },
8
8
  sent: { type: Boolean, default: false }
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PPTSlideEventModel = void 0;
4
- var mongoose_1 = require("mongoose");
5
- var PPTEventSchema = new mongoose_1.Schema({
4
+ const mongoose_1 = require("mongoose");
5
+ const PPTEventSchema = new mongoose_1.Schema({
6
6
  pptRef: { type: mongoose_1.Schema.Types.ObjectId, ref: 'ppt' },
7
7
  message: { type: String, default: null },
8
8
  event: { type: String, default: null },
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PPTSlideModel = void 0;
4
- var mongoose_1 = require("mongoose");
5
- var PPTSlideSchema = new mongoose_1.Schema({
4
+ const mongoose_1 = require("mongoose");
5
+ const PPTSlideSchema = new mongoose_1.Schema({
6
6
  deletedAt: { type: Date, default: null },
7
7
  pptRef: { type: mongoose_1.Schema.Types.ObjectId, ref: 'ppt' },
8
8
  slideRef: { type: mongoose_1.Schema.Types.ObjectId, ref: 'slide' },
@@ -55,6 +55,7 @@ export interface IPPTSchema {
55
55
  navigateFromGPT: boolean;
56
56
  googleDriveId: string;
57
57
  isPartialFile: boolean;
58
+ isEditable: boolean;
58
59
  }
59
60
  export declare const PPTModel: import("mongoose").Model<IPPTSchema, {}, {}, {}, import("mongoose").Document<unknown, {}, IPPTSchema> & Omit<IPPTSchema & {
60
61
  _id: Types.ObjectId;
@@ -1 +1 @@
1
- {"version":3,"file":"ppt.entity.d.ts","sourceRoot":"","sources":["../../src/entity/ppt.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAiB,KAAK,EAAE,MAAM,UAAU,CAAC;AAEhD,MAAM,WAAW,UAAU;IACvB,qBAAqB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrC,kBAAkB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAClC,kBAAkB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAClC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtB,SAAS,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC5B,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC;IAC3B,cAAc,EAAE,KAAK,CAAC,QAAQ,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,OAAO,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,OAAO,CAAC;CAC1B;AA0CD,eAAO,MAAM,QAAQ;;eAAsC,CAAC"}
1
+ {"version":3,"file":"ppt.entity.d.ts","sourceRoot":"","sources":["../../src/entity/ppt.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAiB,KAAK,EAAE,MAAM,UAAU,CAAC;AAEhD,MAAM,WAAW,UAAU;IACvB,qBAAqB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrC,kBAAkB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAClC,kBAAkB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAClC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtB,SAAS,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC5B,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC;IAC3B,cAAc,EAAE,KAAK,CAAC,QAAQ,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,OAAO,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;CACvB;AA2CD,eAAO,MAAM,QAAQ;;eAAsC,CAAC"}
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PPTModel = void 0;
4
- var mongoose_1 = require("mongoose");
5
- var PPTSchema = new mongoose_1.Schema({
4
+ const mongoose_1 = require("mongoose");
5
+ const PPTSchema = new mongoose_1.Schema({
6
6
  deletedAt: { type: Date, default: null },
7
7
  isLocked: { type: Boolean, default: false },
8
8
  isCompleted: { type: Boolean, default: false },
@@ -1,22 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SlideLayoutModel = void 0;
4
- var mongoose_1 = require("mongoose");
5
- var messageSchema = new mongoose_1.Schema({
4
+ const mongoose_1 = require("mongoose");
5
+ const messageSchema = new mongoose_1.Schema({
6
6
  message: { type: String },
7
7
  keys: { type: [String] },
8
8
  }, {
9
9
  timestamps: false,
10
10
  _id: false
11
11
  });
12
- var systemSchema = new mongoose_1.Schema({
12
+ const systemSchema = new mongoose_1.Schema({
13
13
  system: messageSchema,
14
14
  user: messageSchema
15
15
  }, {
16
16
  timestamps: false,
17
17
  _id: false
18
18
  });
19
- var SlideLayoutSchema = new mongoose_1.Schema({
19
+ const SlideLayoutSchema = new mongoose_1.Schema({
20
20
  published: { type: Boolean, default: false },
21
21
  name: { type: String, default: "", required: true },
22
22
  displayName: { type: String, default: "" },
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SlideModel = void 0;
4
- var mongoose_1 = require("mongoose");
5
- var layerSchema = new mongoose_1.Schema({
4
+ const mongoose_1 = require("mongoose");
5
+ const layerSchema = new mongoose_1.Schema({
6
6
  metaType: { type: String, enum: ['text', 'image', 'shape', 'list', 'table'] },
7
7
  optionsMeta: { type: String },
8
8
  chatMeta: { type: String },
@@ -10,7 +10,7 @@ var layerSchema = new mongoose_1.Schema({
10
10
  timestamps: false,
11
11
  _id: false
12
12
  });
13
- var SlideSchema = new mongoose_1.Schema({
13
+ const SlideSchema = new mongoose_1.Schema({
14
14
  name: { type: String, default: "", required: true },
15
15
  published: { type: Boolean, default: false },
16
16
  postfix: { type: String, default: "" },
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SocketModel = void 0;
4
- var mongoose_1 = require("mongoose");
5
- var SocketSchema = new mongoose_1.Schema({
4
+ const mongoose_1 = require("mongoose");
5
+ const SocketSchema = new mongoose_1.Schema({
6
6
  userId: { type: String, default: null },
7
7
  socketIds: { type: [String], default: [] }
8
8
  }, {
@@ -1,36 +1,36 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TemplateTypeModel = void 0;
4
- var mongoose_1 = require("mongoose");
5
- var layoutsSchema = new mongoose_1.Schema({
4
+ const mongoose_1 = require("mongoose");
5
+ const layoutsSchema = new mongoose_1.Schema({
6
6
  title: { type: String },
7
7
  layoutType: { type: String },
8
8
  }, {
9
9
  timestamps: false,
10
10
  _id: false
11
11
  });
12
- var messageSchema = new mongoose_1.Schema({
12
+ const messageSchema = new mongoose_1.Schema({
13
13
  message: { type: String },
14
14
  keys: { type: [String] },
15
15
  }, {
16
16
  timestamps: false,
17
17
  _id: false
18
18
  });
19
- var systemSchema = new mongoose_1.Schema({
19
+ const systemSchema = new mongoose_1.Schema({
20
20
  system: messageSchema,
21
21
  user: messageSchema
22
22
  }, {
23
23
  timestamps: false,
24
24
  _id: false
25
25
  });
26
- var variantsSystemSchema = new mongoose_1.Schema({
26
+ const variantsSystemSchema = new mongoose_1.Schema({
27
27
  single: systemSchema,
28
28
  multiple: systemSchema
29
29
  }, {
30
30
  timestamps: false,
31
31
  _id: false
32
32
  });
33
- var TemplateTypeSchema = new mongoose_1.Schema({
33
+ const TemplateTypeSchema = new mongoose_1.Schema({
34
34
  published: { type: Boolean, default: false },
35
35
  name: { type: String, default: "", required: true },
36
36
  layouts: [layoutsSchema],
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TemplateModel = void 0;
4
- var mongoose_1 = require("mongoose");
5
- var TemplateSchema = new mongoose_1.Schema({
4
+ const mongoose_1 = require("mongoose");
5
+ const TemplateSchema = new mongoose_1.Schema({
6
6
  name: { type: String, default: "", required: true },
7
7
  published: { type: Boolean, default: false },
8
8
  templateTypeId: { type: mongoose_1.Schema.Types.ObjectId, ref: "template-type" },
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TrainingQueueModel = void 0;
4
- var mongoose_1 = require("mongoose");
5
- var TrainingQueueSchema = new mongoose_1.Schema({
4
+ const mongoose_1 = require("mongoose");
5
+ const TrainingQueueSchema = new mongoose_1.Schema({
6
6
  filename: { type: String, default: null },
7
7
  isCompleted: { type: Boolean, default: false },
8
8
  userId: { type: mongoose_1.Schema.Types.ObjectId, ref: "user" },
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UserModel = void 0;
4
- var mongoose_1 = require("mongoose");
5
- var UserSchema = new mongoose_1.Schema({
4
+ const mongoose_1 = require("mongoose");
5
+ const UserSchema = new mongoose_1.Schema({
6
6
  email: { type: String, unique: true, sparse: true },
7
7
  password: { type: String, default: null },
8
8
  role: { type: String, default: null },
@@ -1,51 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
2
  var __rest = (this && this.__rest) || function (s, e) {
50
3
  var t = {};
51
4
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -59,186 +12,130 @@ var __rest = (this && this.__rest) || function (s, e) {
59
12
  };
60
13
  Object.defineProperty(exports, "__esModule", { value: true });
61
14
  exports.authorizeWithGpt = exports.nonAuthorizeWithSlideApp = exports.authorizeWithSlideApp = exports.authorize = void 0;
62
- var utilities_1 = require("../utilities");
63
- var entity_1 = require("../entity");
64
- var authorize = function (roles) {
65
- return function (req, res, next) {
66
- return __awaiter(this, void 0, void 0, function () {
67
- var token, user_1, hasAccess, _a, createdAt, updatedAt, deletedAt, password, rest;
68
- return __generator(this, function (_b) {
69
- switch (_b.label) {
70
- case 0:
71
- if (!req.headers.authorization) {
72
- return [2 /*return*/, res.status(401).json({ message: 'Unauthorized' })];
73
- }
74
- if (!roles.length) {
75
- return [2 /*return*/, res.status(401).json({ message: 'Unauthorized' })];
76
- }
77
- if (!req.headers.authorization) return [3 /*break*/, 3];
78
- return [4 /*yield*/, (0, utilities_1.verifyUid)(req.headers.authorization)];
79
- case 1:
80
- token = _b.sent();
81
- if (!token) {
82
- return [2 /*return*/, res.status(401).json({ message: 'Session Expired' })];
83
- }
84
- return [4 /*yield*/, entity_1.UserModel.findOne({ email: token.value.email })];
85
- case 2:
86
- user_1 = _b.sent();
87
- if (!user_1) {
88
- return [2 /*return*/, res.status(401).json({ message: 'No User Found' })];
89
- }
90
- hasAccess = roles.find(function (role) { return role === user_1.role; });
91
- if (!hasAccess) {
92
- return [2 /*return*/, res.status(403).json({ message: 'Forbbiden' })];
93
- }
94
- _a = user_1.toObject(), createdAt = _a.createdAt, updatedAt = _a.updatedAt, deletedAt = _a.deletedAt, password = _a.password, rest = __rest(_a, ["createdAt", "updatedAt", "deletedAt", "password"]);
95
- req.user = __assign(__assign({}, rest), { userId: rest.email });
96
- next();
97
- _b.label = 3;
98
- case 3: return [2 /*return*/];
99
- }
100
- });
101
- });
15
+ const utilities_1 = require("../utilities");
16
+ const entity_1 = require("../entity");
17
+ const authorize = (roles) => {
18
+ return async function (req, res, next) {
19
+ if (!req.headers.authorization) {
20
+ return res.status(401).json({ message: 'Unauthorized' });
21
+ }
22
+ if (!roles.length) {
23
+ return res.status(401).json({ message: 'Unauthorized' });
24
+ }
25
+ if (req.headers.authorization) {
26
+ const token = await (0, utilities_1.verifyUid)(req.headers.authorization);
27
+ if (!token) {
28
+ return res.status(401).json({ message: 'Session Expired' });
29
+ }
30
+ let user = await entity_1.UserModel.findOne({ email: token.value.email });
31
+ if (!user) {
32
+ return res.status(401).json({ message: 'No User Found' });
33
+ }
34
+ const hasAccess = roles.find(role => role === user.role);
35
+ if (!hasAccess) {
36
+ return res.status(403).json({ message: 'Forbbiden' });
37
+ }
38
+ const _a = user.toObject(), { createdAt, updatedAt, deletedAt, password } = _a, rest = __rest(_a, ["createdAt", "updatedAt", "deletedAt", "password"]);
39
+ req.user = Object.assign(Object.assign({}, rest), { userId: rest.email });
40
+ next();
41
+ }
102
42
  };
103
43
  };
104
44
  exports.authorize = authorize;
105
- var createUser = function (emailId, userId, appName) { return __awaiter(void 0, void 0, void 0, function () {
106
- var customer, newCustomer;
107
- return __generator(this, function (_a) {
108
- switch (_a.label) {
109
- case 0: return [4 /*yield*/, entity_1.CustomerModel.findOne({ userId: userId })];
110
- case 1:
111
- customer = _a.sent();
112
- if (!!customer) return [3 /*break*/, 3];
113
- newCustomer = new entity_1.CustomerModel({
114
- appName: appName || "default",
115
- emailId: emailId,
116
- emailTemplateStatus: {},
117
- userId: userId
118
- });
119
- return [4 /*yield*/, newCustomer.save()];
120
- case 2:
121
- _a.sent();
122
- _a.label = 3;
123
- case 3: return [2 /*return*/];
124
- }
125
- });
126
- }); };
127
- var authorizeWithSlideApp = function () {
128
- return function (req, res, next) {
129
- var _a;
130
- return __awaiter(this, void 0, void 0, function () {
131
- var ipAddress, sessionId, token, userId;
132
- return __generator(this, function (_b) {
133
- switch (_b.label) {
134
- case 0:
135
- ipAddress = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
136
- sessionId = req.headers['x-fingerprint-key'];
137
- if (!req.headers.authorization) {
138
- return [2 /*return*/, res.status(401).json({ message: 'Unauthorized' })];
139
- }
140
- if (!req.headers.authorization) return [3 /*break*/, 3];
141
- return [4 /*yield*/, (0, utilities_1.verifyUid)(req.headers.authorization)];
142
- case 1:
143
- token = _b.sent();
144
- if (!token) {
145
- return [2 /*return*/, res.status(401).json({ message: 'Session Expired' })];
146
- }
147
- userId = (token === null || token === void 0 ? void 0 : token.customer_id) || ((_a = token === null || token === void 0 ? void 0 : token.value) === null || _a === void 0 ? void 0 : _a.email);
148
- if (!userId) {
149
- return [2 /*return*/, res.status(401).json({ message: 'userId not found' })];
150
- }
151
- req.user = {
152
- userId: userId,
153
- sessionId: sessionId,
154
- ipAddress: ipAddress,
155
- appName: req.headers['x-app-name'],
156
- email: (token === null || token === void 0 ? void 0 : token.customer_email) || ""
157
- };
158
- return [4 /*yield*/, createUser(req.user.email, req.user.userId, req.user.appName)];
159
- case 2:
160
- _b.sent();
161
- next();
162
- _b.label = 3;
163
- case 3: return [2 /*return*/];
164
- }
165
- });
45
+ const createUser = async (emailId, userId, appName) => {
46
+ const customer = await entity_1.CustomerModel.findOne({ userId });
47
+ if (!customer) {
48
+ const newCustomer = new entity_1.CustomerModel({
49
+ appName: appName || "default",
50
+ emailId,
51
+ emailTemplateStatus: {},
52
+ userId
166
53
  });
54
+ await newCustomer.save();
55
+ }
56
+ };
57
+ const authorizeWithSlideApp = () => {
58
+ return async function (req, res, next) {
59
+ var _a;
60
+ const ipAddress = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
61
+ const sessionId = req.headers['x-fingerprint-key'];
62
+ if (!req.headers.authorization) {
63
+ return res.status(401).json({ message: 'Unauthorized' });
64
+ }
65
+ if (req.headers.authorization) {
66
+ const token = await (0, utilities_1.verifyUid)(req.headers.authorization);
67
+ if (!token) {
68
+ return res.status(401).json({ message: 'Session Expired' });
69
+ }
70
+ const userId = (token === null || token === void 0 ? void 0 : token.customer_id) || ((_a = token === null || token === void 0 ? void 0 : token.value) === null || _a === void 0 ? void 0 : _a.email);
71
+ if (!userId) {
72
+ return res.status(401).json({ message: 'userId not found' });
73
+ }
74
+ req.user = {
75
+ userId: userId,
76
+ sessionId,
77
+ ipAddress,
78
+ appName: req.headers['x-app-name'],
79
+ email: (token === null || token === void 0 ? void 0 : token.customer_email) || ""
80
+ };
81
+ await createUser(req.user.email, req.user.userId, req.user.appName);
82
+ next();
83
+ }
167
84
  };
168
85
  };
169
86
  exports.authorizeWithSlideApp = authorizeWithSlideApp;
170
- var nonAuthorizeWithSlideApp = function () {
171
- return function (req, res, next) {
87
+ const nonAuthorizeWithSlideApp = () => {
88
+ return async function (req, res, next) {
172
89
  var _a;
173
- return __awaiter(this, void 0, void 0, function () {
174
- var ipAddress, sessionId, userId, email, token;
175
- return __generator(this, function (_b) {
176
- switch (_b.label) {
177
- case 0:
178
- ipAddress = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
179
- sessionId = req.headers['x-fingerprint-key'];
180
- userId = "guest";
181
- email = "";
182
- if (!req.headers.authorization) return [3 /*break*/, 3];
183
- return [4 /*yield*/, (0, utilities_1.verifyUid)(req.headers.authorization)];
184
- case 1:
185
- token = _b.sent();
186
- if (!token) {
187
- return [2 /*return*/, res.status(401).json({ message: 'Session Expired' })];
188
- }
189
- userId = (token === null || token === void 0 ? void 0 : token.customer_id) || ((_a = token === null || token === void 0 ? void 0 : token.value) === null || _a === void 0 ? void 0 : _a.email);
190
- email = (token === null || token === void 0 ? void 0 : token.customer_email) || "";
191
- if (!userId) {
192
- return [2 /*return*/, res.status(401).json({ message: 'userId not found' })];
193
- }
194
- return [4 /*yield*/, createUser(email, userId, req.headers['x-app-name'])];
195
- case 2:
196
- _b.sent();
197
- return [3 /*break*/, 4];
198
- case 3:
199
- if (!ipAddress || !sessionId) {
200
- return [2 /*return*/, res.status(401).json({ message: 'We are not able to track your actions' })];
201
- }
202
- _b.label = 4;
203
- case 4:
204
- req.user = {
205
- userId: userId,
206
- sessionId: sessionId,
207
- ipAddress: ipAddress,
208
- appName: req.headers['x-app-name'],
209
- email: email
210
- };
211
- next();
212
- return [2 /*return*/];
213
- }
214
- });
215
- });
90
+ const ipAddress = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
91
+ const sessionId = req.headers['x-fingerprint-key'];
92
+ let userId = "guest";
93
+ let email = "";
94
+ if (req.headers.authorization) {
95
+ const token = await (0, utilities_1.verifyUid)(req.headers.authorization);
96
+ if (!token) {
97
+ return res.status(401).json({ message: 'Session Expired' });
98
+ }
99
+ userId = (token === null || token === void 0 ? void 0 : token.customer_id) || ((_a = token === null || token === void 0 ? void 0 : token.value) === null || _a === void 0 ? void 0 : _a.email);
100
+ email = (token === null || token === void 0 ? void 0 : token.customer_email) || "";
101
+ if (!userId) {
102
+ return res.status(401).json({ message: 'userId not found' });
103
+ }
104
+ await createUser(email, userId, req.headers['x-app-name']);
105
+ }
106
+ else {
107
+ if (!ipAddress || !sessionId) {
108
+ return res.status(401).json({ message: 'We are not able to track your actions' });
109
+ }
110
+ }
111
+ req.user = {
112
+ userId,
113
+ sessionId,
114
+ ipAddress,
115
+ appName: req.headers['x-app-name'],
116
+ email
117
+ };
118
+ next();
216
119
  };
217
120
  };
218
121
  exports.nonAuthorizeWithSlideApp = nonAuthorizeWithSlideApp;
219
122
  // TODO: Delete It
220
- var authorizeWithGpt = function () {
221
- return function (req, res, next) {
222
- return __awaiter(this, void 0, void 0, function () {
223
- var secret, secretKey, ipAddress, userId;
224
- return __generator(this, function (_a) {
225
- secret = req.headers['authorization'];
226
- secretKey = secret ? secret.split(":") : undefined;
227
- if (secretKey && secretKey.length === 2 && secretKey[0] !== "Bearer ".concat(process.env.GPT_API_KEY)) {
228
- return [2 /*return*/, res.status(401).json({ message: 'keys not matching' })];
229
- }
230
- ipAddress = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
231
- userId = "guest";
232
- req.user = {
233
- userId: userId,
234
- ipAddress: ipAddress,
235
- appName: secretKey[1],
236
- navigateFromGPT: true
237
- };
238
- next();
239
- return [2 /*return*/];
240
- });
241
- });
123
+ const authorizeWithGpt = () => {
124
+ return async function (req, res, next) {
125
+ const secret = req.headers['authorization'];
126
+ const secretKey = secret ? secret.split(":") : undefined;
127
+ if (secretKey && secretKey.length === 2 && secretKey[0] !== `Bearer ${process.env.GPT_API_KEY}`) {
128
+ return res.status(401).json({ message: 'keys not matching' });
129
+ }
130
+ const ipAddress = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
131
+ let userId = "guest";
132
+ req.user = {
133
+ userId,
134
+ ipAddress,
135
+ appName: secretKey[1],
136
+ navigateFromGPT: true
137
+ };
138
+ next();
242
139
  };
243
140
  };
244
141
  exports.authorizeWithGpt = authorizeWithGpt;
@@ -1,58 +1,16 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
2
  Object.defineProperty(exports, "__esModule", { value: true });
39
3
  exports.validateSchema = void 0;
40
- var validateSchema = function (schema) {
41
- return function (req, res, next) {
42
- return __awaiter(this, void 0, void 0, function () {
43
- var error, errorMessage;
44
- return __generator(this, function (_a) {
45
- error = schema.validate(req.body, { abortEarly: false }).error;
46
- if (error) {
47
- errorMessage = error.details.map(function (err) { return err.message; }).join(', ');
48
- return [2 /*return*/, res.status(400).json({ message: errorMessage })];
49
- }
50
- else {
51
- next();
52
- }
53
- return [2 /*return*/];
54
- });
55
- });
4
+ const validateSchema = (schema) => {
5
+ return async function (req, res, next) {
6
+ const { error } = schema.validate(req.body, { abortEarly: false });
7
+ if (error) {
8
+ const errorMessage = error.details.map((err) => err.message).join(', ');
9
+ return res.status(400).json({ message: errorMessage });
10
+ }
11
+ else {
12
+ next();
13
+ }
56
14
  };
57
15
  };
58
16
  exports.validateSchema = validateSchema;
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "biz-slide-core",
3
- "version": "1.2.86",
3
+ "version": "1.2.88",
4
4
  "description": "",
5
- "main": "dist/index.js",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
6
7
  "scripts": {
7
8
  "build": "tsc",
8
9
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -1,58 +1,36 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.errorHandler = exports.CustomRequestError = exports.NotFoundRequestError = exports.BadRequestError = void 0;
19
- var BadRequestError = /** @class */ (function (_super) {
20
- __extends(BadRequestError, _super);
21
- function BadRequestError(message) {
22
- var _this = _super.call(this, message) || this;
23
- Object.setPrototypeOf(_this, BadRequestError.prototype);
24
- _this.name = 'BadRequestError';
25
- return _this;
4
+ class BadRequestError extends Error {
5
+ constructor(message) {
6
+ super(message);
7
+ Object.setPrototypeOf(this, BadRequestError.prototype);
8
+ this.name = 'BadRequestError';
26
9
  }
27
- return BadRequestError;
28
- }(Error));
10
+ }
29
11
  exports.BadRequestError = BadRequestError;
30
- var NotFoundRequestError = /** @class */ (function (_super) {
31
- __extends(NotFoundRequestError, _super);
32
- function NotFoundRequestError(message) {
33
- var _this = _super.call(this, message) || this;
34
- Object.setPrototypeOf(_this, NotFoundRequestError.prototype);
35
- _this.name = 'NotFoundRequestError';
36
- return _this;
12
+ class NotFoundRequestError extends Error {
13
+ constructor(message) {
14
+ super(message);
15
+ Object.setPrototypeOf(this, NotFoundRequestError.prototype);
16
+ this.name = 'NotFoundRequestError';
37
17
  }
38
- return NotFoundRequestError;
39
- }(Error));
18
+ }
40
19
  exports.NotFoundRequestError = NotFoundRequestError;
41
- var CustomRequestError = /** @class */ (function () {
42
- function CustomRequestError(title, description) {
20
+ class CustomRequestError {
21
+ constructor(title, description) {
43
22
  this.name = 'CustomRequestError';
44
23
  this.message = {
45
- title: title,
46
- description: description
24
+ title,
25
+ description
47
26
  };
48
27
  }
49
- return CustomRequestError;
50
- }());
28
+ }
51
29
  exports.CustomRequestError = CustomRequestError;
52
30
  // Custom error handler middleware
53
- var errorHandler = function (err, req, res, next) {
54
- var statusCode = 500; // Default status code
55
- var errorMessage = 'Internal Server Error'; // Default error message
31
+ const errorHandler = (err, req, res, next) => {
32
+ let statusCode = 500; // Default status code
33
+ let errorMessage = 'Internal Server Error'; // Default error message
56
34
  if (err instanceof BadRequestError) {
57
35
  statusCode = 400;
58
36
  errorMessage = err.message;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.successHandler = void 0;
4
4
  // Generic success handler middleware
5
- var successHandler = function (data, req, res, next) {
5
+ const successHandler = (data, req, res, next) => {
6
6
  res.status(200).json(data);
7
7
  };
8
8
  exports.successHandler = successHandler;
@@ -1,73 +1,15 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
39
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
40
- if (ar || !(i in from)) {
41
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
42
- ar[i] = from[i];
43
- }
44
- }
45
- return to.concat(ar || Array.prototype.slice.call(from));
46
- };
47
2
  Object.defineProperty(exports, "__esModule", { value: true });
48
3
  exports.callWithRetries = void 0;
49
- function callWithRetries(retryCount, failedMessage, functionRef) {
50
- var args = [];
51
- for (var _i = 3; _i < arguments.length; _i++) {
52
- args[_i - 3] = arguments[_i];
4
+ async function callWithRetries(retryCount, failedMessage, functionRef, ...args) {
5
+ try {
6
+ return await functionRef(...args);
7
+ }
8
+ catch (error) {
9
+ if (retryCount <= 0)
10
+ throw error;
11
+ console.log("callWithRetries", (error === null || error === void 0 ? void 0 : error.message) || error);
12
+ return callWithRetries(retryCount - 1, failedMessage, functionRef, ...args);
53
13
  }
54
- return __awaiter(this, void 0, void 0, function () {
55
- var error_1;
56
- return __generator(this, function (_a) {
57
- switch (_a.label) {
58
- case 0:
59
- _a.trys.push([0, 2, , 3]);
60
- return [4 /*yield*/, functionRef.apply(void 0, args)];
61
- case 1: return [2 /*return*/, _a.sent()];
62
- case 2:
63
- error_1 = _a.sent();
64
- if (retryCount <= 0)
65
- throw error_1;
66
- console.log("callWithRetries", (error_1 === null || error_1 === void 0 ? void 0 : error_1.message) || error_1);
67
- return [2 /*return*/, callWithRetries.apply(void 0, __spreadArray([retryCount - 1, failedMessage, functionRef], args, false))];
68
- case 3: return [2 /*return*/];
69
- }
70
- });
71
- });
72
14
  }
73
15
  exports.callWithRetries = callWithRetries;
@@ -1,59 +1,18 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
39
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
4
  };
41
5
  Object.defineProperty(exports, "__esModule", { value: true });
42
6
  exports.createFolder = void 0;
43
- var fs_1 = __importDefault(require("fs"));
44
- function createFolder(folderPath) {
45
- return __awaiter(this, void 0, void 0, function () {
46
- return __generator(this, function (_a) {
47
- try {
48
- if (!fs_1.default.existsSync(folderPath)) {
49
- fs_1.default.mkdirSync(folderPath);
50
- }
51
- }
52
- catch (error) {
53
- console.error("Error: ".concat(error.message));
54
- }
55
- return [2 /*return*/];
56
- });
57
- });
7
+ const fs_1 = __importDefault(require("fs"));
8
+ async function createFolder(folderPath) {
9
+ try {
10
+ if (!fs_1.default.existsSync(folderPath)) {
11
+ fs_1.default.mkdirSync(folderPath);
12
+ }
13
+ }
14
+ catch (error) {
15
+ console.error(`Error: ${error.message}`);
16
+ }
58
17
  }
59
18
  exports.createFolder = createFolder;
@@ -1,66 +1,26 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
39
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
4
  };
41
5
  Object.defineProperty(exports, "__esModule", { value: true });
42
6
  exports.verifyUid = exports.signUid = void 0;
43
- var jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
44
- var signUid = function (value) {
45
- return jsonwebtoken_1.default.sign({ value: value }, process.env.JWTSECRET || 'secret', {
7
+ const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
8
+ const signUid = (value) => {
9
+ return jsonwebtoken_1.default.sign({ value }, process.env.JWTSECRET || 'secret', {
46
10
  expiresIn: '8h' // expires in 8 hours
47
11
  });
48
12
  };
49
13
  exports.signUid = signUid;
50
- var verifyUid = function (token) { return __awaiter(void 0, void 0, void 0, function () {
51
- return __generator(this, function (_a) {
52
- return [2 /*return*/, new Promise(function (resolve) {
53
- var jwtToken = token.split(" ")[1] || token;
54
- jsonwebtoken_1.default.verify(jwtToken, process.env.JWTSECRET || 'secret', function (err, decoded) {
55
- if (err) {
56
- // console.log("error verifyUid", err)
57
- resolve(null);
58
- }
59
- else {
60
- resolve(decoded);
61
- }
62
- });
63
- })];
14
+ const verifyUid = async (token) => new Promise(resolve => {
15
+ const jwtToken = token.split(" ")[1] || token;
16
+ jsonwebtoken_1.default.verify(jwtToken, process.env.JWTSECRET || 'secret', (err, decoded) => {
17
+ if (err) {
18
+ // console.log("error verifyUid", err)
19
+ resolve(null);
20
+ }
21
+ else {
22
+ resolve(decoded);
23
+ }
64
24
  });
65
- }); };
25
+ });
66
26
  exports.verifyUid = verifyUid;
@@ -3,27 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.hasAbusiveWords = exports.hasSpecialCharacter = exports.hasExactMatch = void 0;
4
4
  function hasExactMatch(str, word) {
5
5
  // Construct a regular expression to match the word as a whole word
6
- var regex = new RegExp('\\b' + word + '\\b', 'i'); // 'i' for case-insensitive matching
6
+ const regex = new RegExp('\\b' + word + '\\b', 'i'); // 'i' for case-insensitive matching
7
7
  // Test if the word has an exact match in the string
8
8
  return regex.test(str);
9
9
  }
10
10
  exports.hasExactMatch = hasExactMatch;
11
11
  function hasSpecialCharacter(str) {
12
12
  // Define a regular expression with a character class containing special characters
13
- var regex = /[!@#$%^&*()_+\-=\[\]{};:\\|<>\/?]/;
13
+ const regex = /[!@#$%^&*()_+\-=\[\]{};:\\|<>\/?]/;
14
14
  // Test if the string contains any special character
15
15
  return regex.test(str);
16
16
  }
17
17
  exports.hasSpecialCharacter = hasSpecialCharacter;
18
18
  function hasAbusiveWords(str, words) {
19
19
  // Convert the string to lowercase for case-insensitive matching
20
- var lowerStr = str.toLowerCase();
20
+ const lowerStr = str.toLowerCase();
21
21
  if (hasSpecialCharacter(lowerStr)) {
22
22
  return true;
23
23
  }
24
24
  // Check if any abusive word exists in the string
25
- for (var _i = 0, words_1 = words; _i < words_1.length; _i++) {
26
- var word = words_1[_i];
25
+ for (const word of words) {
27
26
  if (hasExactMatch(lowerStr, word.toLowerCase())) {
28
27
  return true;
29
28
  }