scheduler-node-models 1.1.8 → 1.1.10
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/general/index.d.ts +1 -0
- package/general/index.js +1 -0
- package/general/logger.d.ts +10 -0
- package/general/logger.js +67 -0
- package/package.json +1 -1
- package/users/user.d.ts +3 -3
- package/users/user.js +9 -7
package/general/index.d.ts
CHANGED
package/general/index.js
CHANGED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Logger = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
class Logger {
|
|
39
|
+
logFile;
|
|
40
|
+
flushInterval;
|
|
41
|
+
buffer = [];
|
|
42
|
+
interval;
|
|
43
|
+
constructor(logFile, flushInterval = 100) {
|
|
44
|
+
this.logFile = logFile;
|
|
45
|
+
this.flushInterval = flushInterval;
|
|
46
|
+
this.interval = setInterval(() => this.flush(), flushInterval);
|
|
47
|
+
}
|
|
48
|
+
log(message) {
|
|
49
|
+
this.buffer.push(message);
|
|
50
|
+
}
|
|
51
|
+
flush() {
|
|
52
|
+
if (this.buffer.length > 0) {
|
|
53
|
+
const logLines = this.buffer.join('\n') + '\n';
|
|
54
|
+
fs.appendFile(this.logFile, logLines, (err) => {
|
|
55
|
+
if (err) {
|
|
56
|
+
console.error(`Error writing to log file: ${err}`);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
this.buffer = [];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
stop() {
|
|
63
|
+
clearInterval(this.interval);
|
|
64
|
+
this.flush();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.Logger = Logger;
|
package/package.json
CHANGED
package/users/user.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ObjectId } from "mongodb";
|
|
2
1
|
/**
|
|
3
2
|
* The user class and interface.
|
|
4
3
|
*/
|
|
@@ -7,7 +6,8 @@ import { ObjectId } from "mongodb";
|
|
|
7
6
|
* its class object.
|
|
8
7
|
*/
|
|
9
8
|
export interface IUser {
|
|
10
|
-
_id?:
|
|
9
|
+
_id?: string;
|
|
10
|
+
id: string;
|
|
11
11
|
emailAddress: string;
|
|
12
12
|
password?: string;
|
|
13
13
|
passwordExpires: Date;
|
|
@@ -37,7 +37,7 @@ export interface IUser {
|
|
|
37
37
|
* password change, plus token expiration date/time the reset token expires)
|
|
38
38
|
*/
|
|
39
39
|
export declare class User implements IUser {
|
|
40
|
-
|
|
40
|
+
id: string;
|
|
41
41
|
emailAddress: string;
|
|
42
42
|
password?: string;
|
|
43
43
|
passwordExpires: Date;
|
package/users/user.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.User = void 0;
|
|
4
|
-
const
|
|
5
|
-
const bcrypt_1 = require("bcrypt");
|
|
4
|
+
const bcrypt_ts_1 = require("bcrypt-ts");
|
|
6
5
|
/**
|
|
7
6
|
* This class represents a user and all the actions available to the user object.
|
|
8
7
|
* The main class members are:
|
|
@@ -20,7 +19,7 @@ const bcrypt_1 = require("bcrypt");
|
|
|
20
19
|
* password change, plus token expiration date/time the reset token expires)
|
|
21
20
|
*/
|
|
22
21
|
class User {
|
|
23
|
-
|
|
22
|
+
id;
|
|
24
23
|
emailAddress;
|
|
25
24
|
password;
|
|
26
25
|
passwordExpires;
|
|
@@ -33,7 +32,10 @@ class User {
|
|
|
33
32
|
resettokenexp;
|
|
34
33
|
additionalEmails;
|
|
35
34
|
constructor(user) {
|
|
36
|
-
this.
|
|
35
|
+
this.id = (user && user.id) ? user.id : '';
|
|
36
|
+
if (this.id === '') {
|
|
37
|
+
this.id = (user && user._id) ? user._id.toString() : '';
|
|
38
|
+
}
|
|
37
39
|
this.emailAddress = (user) ? user.emailAddress : '';
|
|
38
40
|
this.password = (user) ? user.password : undefined;
|
|
39
41
|
this.passwordExpires = (user) ? new Date(user.passwordExpires) : new Date();
|
|
@@ -104,8 +106,8 @@ class User {
|
|
|
104
106
|
* @param passwd The string value for the new password
|
|
105
107
|
*/
|
|
106
108
|
setPassword(passwd) {
|
|
107
|
-
const salt = (0,
|
|
108
|
-
const result = (0,
|
|
109
|
+
const salt = (0, bcrypt_ts_1.genSaltSync)(12);
|
|
110
|
+
const result = (0, bcrypt_ts_1.hashSync)(passwd, salt);
|
|
109
111
|
this.password = result;
|
|
110
112
|
this.passwordExpires = new Date();
|
|
111
113
|
this.badAttempts = 0;
|
|
@@ -117,7 +119,7 @@ class User {
|
|
|
117
119
|
* @throws An error if the account is locked or there is a mismatch with the password.
|
|
118
120
|
*/
|
|
119
121
|
checkPassword(pwd) {
|
|
120
|
-
if (this.password && (0,
|
|
122
|
+
if (this.password && (0, bcrypt_ts_1.compareSync)(pwd, this.password)) {
|
|
121
123
|
if (this.badAttempts > 2) {
|
|
122
124
|
throw new Error("Account Locked");
|
|
123
125
|
}
|