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.
- package/entity/analytic.entity.js +4 -4
- package/entity/config.enity.js +2 -2
- package/entity/cron.entity.js +2 -2
- package/entity/customer.entity.js +3 -3
- package/entity/image.entity.js +2 -2
- package/entity/logs.entity.js +2 -2
- package/entity/png-svg.entity.js +2 -2
- package/entity/ppt-email-queue.entity.js +2 -2
- package/entity/ppt-event.entity.js +2 -2
- package/entity/ppt-slide.entity.js +2 -2
- package/entity/ppt.entity.d.ts +1 -0
- package/entity/ppt.entity.d.ts.map +1 -1
- package/entity/ppt.entity.js +2 -2
- package/entity/slide-layout.entity.js +4 -4
- package/entity/slide.entity.js +3 -3
- package/entity/socket.entity.js +2 -2
- package/entity/template-type.entity.js +6 -6
- package/entity/template.entity.js +2 -2
- package/entity/training-queue.entity.js +2 -2
- package/entity/user.entity.js +2 -2
- package/middleware/authentication.js +112 -215
- package/middleware/schemaValidate.js +10 -52
- package/package.json +3 -2
- package/resHandler/errorHandler.js +20 -42
- package/resHandler/successHandler.js +1 -1
- package/utilities/callWithRetries.js +9 -67
- package/utilities/createFolder.js +10 -51
- package/utilities/encryptionUtils.js +14 -54
- package/utilities/hasAbusiveWords.js +4 -5
@@ -1,15 +1,15 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.AnalyticModel = void 0;
|
4
|
-
|
5
|
-
|
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
|
-
|
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
|
-
|
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 },
|
package/entity/config.enity.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.ConfigModel = void 0;
|
4
|
-
|
5
|
-
|
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
|
}, {
|
package/entity/cron.entity.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.CronModel = void 0;
|
4
|
-
|
5
|
-
|
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
|
-
|
5
|
-
|
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
|
-
|
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: "" },
|
package/entity/image.entity.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.ImageModel = void 0;
|
4
|
-
|
5
|
-
|
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 },
|
package/entity/logs.entity.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.LogsModel = void 0;
|
4
|
-
|
5
|
-
|
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 },
|
package/entity/png-svg.entity.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.PngSvgModel = void 0;
|
4
|
-
|
5
|
-
|
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
|
-
|
5
|
-
|
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
|
-
|
5
|
-
|
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
|
-
|
5
|
-
|
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' },
|
package/entity/ppt.entity.d.ts
CHANGED
@@ -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;
|
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"}
|
package/entity/ppt.entity.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.PPTModel = void 0;
|
4
|
-
|
5
|
-
|
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
|
-
|
5
|
-
|
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
|
-
|
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
|
-
|
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: "" },
|
package/entity/slide.entity.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.SlideModel = void 0;
|
4
|
-
|
5
|
-
|
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
|
-
|
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: "" },
|
package/entity/socket.entity.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.SocketModel = void 0;
|
4
|
-
|
5
|
-
|
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
|
-
|
5
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
5
|
-
|
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
|
-
|
5
|
-
|
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" },
|
package/entity/user.entity.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.UserModel = void 0;
|
4
|
-
|
5
|
-
|
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
|
-
|
63
|
-
|
64
|
-
|
65
|
-
return function (req, res, next) {
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
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
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
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
|
-
|
171
|
-
return function (req, res, next) {
|
87
|
+
const nonAuthorizeWithSlideApp = () => {
|
88
|
+
return async function (req, res, next) {
|
172
89
|
var _a;
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
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
|
-
|
221
|
-
return function (req, res, next) {
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
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
|
-
|
41
|
-
return function (req, res, next) {
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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,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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
28
|
-
}(Error));
|
10
|
+
}
|
29
11
|
exports.BadRequestError = BadRequestError;
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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
|
-
|
39
|
-
}(Error));
|
18
|
+
}
|
40
19
|
exports.NotFoundRequestError = NotFoundRequestError;
|
41
|
-
|
42
|
-
|
20
|
+
class CustomRequestError {
|
21
|
+
constructor(title, description) {
|
43
22
|
this.name = 'CustomRequestError';
|
44
23
|
this.message = {
|
45
|
-
title
|
46
|
-
description
|
24
|
+
title,
|
25
|
+
description
|
47
26
|
};
|
48
27
|
}
|
49
|
-
|
50
|
-
}());
|
28
|
+
}
|
51
29
|
exports.CustomRequestError = CustomRequestError;
|
52
30
|
// Custom error handler middleware
|
53
|
-
|
54
|
-
|
55
|
-
|
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
|
-
|
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
|
-
|
51
|
-
|
52
|
-
|
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
|
-
|
44
|
-
function createFolder(folderPath) {
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
-
|
44
|
-
|
45
|
-
return jsonwebtoken_1.default.sign({ value
|
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
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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 (
|
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
|
}
|