@riocrypto/common-server 1.0.2705 → 1.0.2707
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.
|
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.authorize = void 0;
|
|
16
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
16
17
|
const user_1 = require("../models/user");
|
|
17
18
|
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
18
19
|
const common_1 = require("@riocrypto/common");
|
|
@@ -33,7 +34,8 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
33
34
|
if (!CLUSTER_API_KEY) {
|
|
34
35
|
throw new common_1.SecretManagerError();
|
|
35
36
|
}
|
|
36
|
-
if (apiKey === CLUSTER_API_KEY
|
|
37
|
+
if (apiKey.length === CLUSTER_API_KEY.length &&
|
|
38
|
+
crypto_1.default.timingSafeEqual(Buffer.from(apiKey), Buffer.from(CLUSTER_API_KEY))) {
|
|
37
39
|
req.validClusterApiKey = true;
|
|
38
40
|
}
|
|
39
41
|
}))());
|
|
@@ -48,7 +50,8 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
48
50
|
if (!GENESIS_ADMIN_KEY) {
|
|
49
51
|
throw new common_1.SecretManagerError();
|
|
50
52
|
}
|
|
51
|
-
if (apiKey === GENESIS_ADMIN_KEY
|
|
53
|
+
if (apiKey.length === GENESIS_ADMIN_KEY.length &&
|
|
54
|
+
crypto_1.default.timingSafeEqual(Buffer.from(apiKey), Buffer.from(GENESIS_ADMIN_KEY))) {
|
|
52
55
|
req.validGenisisAdminKey = true;
|
|
53
56
|
}
|
|
54
57
|
}))());
|
package/build/models/auth.d.ts
CHANGED
|
@@ -33,6 +33,8 @@ interface AuthAttrs {
|
|
|
33
33
|
emailVerificationCode?: string;
|
|
34
34
|
emailVerificationExpires?: Date;
|
|
35
35
|
emailVerificationAttempts?: number;
|
|
36
|
+
securityAnswerAttempts?: number;
|
|
37
|
+
securityAnswerLockedUntil?: Date;
|
|
36
38
|
authMethod?: AuthMethod;
|
|
37
39
|
twoFactorConfigured?: boolean;
|
|
38
40
|
twoFactorMethod?: string;
|
|
@@ -70,6 +72,8 @@ interface AuthDoc extends Document {
|
|
|
70
72
|
emailVerificationCode?: string;
|
|
71
73
|
emailVerificationExpires?: Date;
|
|
72
74
|
emailVerificationAttempts?: number;
|
|
75
|
+
securityAnswerAttempts?: number;
|
|
76
|
+
securityAnswerLockedUntil?: Date;
|
|
73
77
|
authMethod?: AuthMethod;
|
|
74
78
|
twoFactorConfigured?: boolean;
|
|
75
79
|
twoFactorMethod?: string;
|
package/build/models/auth.js
CHANGED
|
@@ -125,6 +125,13 @@ const buildAuth = (mongoose) => {
|
|
|
125
125
|
type: Number,
|
|
126
126
|
default: 0,
|
|
127
127
|
},
|
|
128
|
+
securityAnswerAttempts: {
|
|
129
|
+
type: Number,
|
|
130
|
+
default: 0,
|
|
131
|
+
},
|
|
132
|
+
securityAnswerLockedUntil: {
|
|
133
|
+
type: Date,
|
|
134
|
+
},
|
|
128
135
|
authMethod: {
|
|
129
136
|
type: String,
|
|
130
137
|
},
|
|
@@ -151,6 +158,8 @@ const buildAuth = (mongoose) => {
|
|
|
151
158
|
delete ret.emailVerificationCode;
|
|
152
159
|
delete ret.emailVerificationExpires;
|
|
153
160
|
delete ret.emailVerificationAttempts;
|
|
161
|
+
delete ret.securityAnswerAttempts;
|
|
162
|
+
delete ret.securityAnswerLockedUntil;
|
|
154
163
|
for (let apiKey of ret.apiKeys) {
|
|
155
164
|
delete apiKey.value;
|
|
156
165
|
}
|