joye-backend-utility 5.0.34 → 5.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/jwt.d.ts +1 -0
- package/dist/jwt.js +15 -1
- package/dist/schema/organization.js +2 -0
- package/dist/schema/user.js +10 -0
- package/dist/schema/userMessagesLog.js +2 -0
- package/package.json +1 -1
package/dist/jwt.d.ts
CHANGED
package/dist/jwt.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.jwtVerify = exports.createToken = void 0;
|
|
3
|
+
exports.decodeToken = exports.jwtVerify = exports.createToken = void 0;
|
|
4
4
|
const jwt = require('jsonwebtoken');
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const path = require('path');
|
|
@@ -24,3 +24,17 @@ const jwtVerify = async (token) => new Promise(resolve => {
|
|
|
24
24
|
});
|
|
25
25
|
});
|
|
26
26
|
exports.jwtVerify = jwtVerify;
|
|
27
|
+
const decodeToken = (token) => {
|
|
28
|
+
try {
|
|
29
|
+
const decodedHeader = jwt.decode(token, { complete: true });
|
|
30
|
+
if (!decodedHeader) {
|
|
31
|
+
console.log('Invalid token Error');
|
|
32
|
+
}
|
|
33
|
+
return decodedHeader;
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
console.log('Token decode failed: ', err);
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.decodeToken = decodeToken;
|
|
@@ -6,6 +6,7 @@ const Organization = new mongoose_1.Schema({
|
|
|
6
6
|
platformKey: {
|
|
7
7
|
type: String,
|
|
8
8
|
required: true,
|
|
9
|
+
index: true,
|
|
9
10
|
},
|
|
10
11
|
key: {
|
|
11
12
|
type: String,
|
|
@@ -74,4 +75,5 @@ const Organization = new mongoose_1.Schema({
|
|
|
74
75
|
required: false,
|
|
75
76
|
},
|
|
76
77
|
});
|
|
78
|
+
Organization.index({ platformKey: 1, timezone: -1, inactive: -1 });
|
|
77
79
|
exports.OrganizationSchema = Organization;
|
package/dist/schema/user.js
CHANGED
|
@@ -6,6 +6,7 @@ const User = new mongoose_1.Schema({
|
|
|
6
6
|
organizationId: {
|
|
7
7
|
type: String,
|
|
8
8
|
required: true,
|
|
9
|
+
index: true,
|
|
9
10
|
},
|
|
10
11
|
employeeId: {
|
|
11
12
|
type: String,
|
|
@@ -208,4 +209,13 @@ const User = new mongoose_1.Schema({
|
|
|
208
209
|
required: false,
|
|
209
210
|
},
|
|
210
211
|
});
|
|
212
|
+
User.index({ botDetails: 1, preferredTimezone: -1 }, {
|
|
213
|
+
unique: false,
|
|
214
|
+
});
|
|
215
|
+
User.index({ organizationId: 1, botDetails: -1 }, {
|
|
216
|
+
unique: false,
|
|
217
|
+
});
|
|
218
|
+
User.index({ botDetails: 1, organizationId: -1, preferredTimezone: -1 }, {
|
|
219
|
+
unique: false,
|
|
220
|
+
});
|
|
211
221
|
exports.UserSchema = User;
|
|
@@ -64,4 +64,6 @@ const UserMessageLog = new mongoose_1.Schema({
|
|
|
64
64
|
},
|
|
65
65
|
});
|
|
66
66
|
UserMessageLog.index({ employeeId: 1, activityId: -1 });
|
|
67
|
+
UserMessageLog.index({ employeeId: 1, date: -1 });
|
|
68
|
+
UserMessageLog.index({ employeeId: 1, messageType: -1, status: -1, date: -1 });
|
|
67
69
|
exports.UserMessageLogSchema = UserMessageLog;
|