@riocrypto/common-server 1.0.2705 → 1.0.2708
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.
|
@@ -92,7 +92,7 @@ declare class ClusterClient {
|
|
|
92
92
|
hasAuthenticatorEnabled: boolean;
|
|
93
93
|
}>;
|
|
94
94
|
verifyCode(phoneNumber: string, code?: string, authenticatorCode?: string): Promise<void>;
|
|
95
|
-
sendEmailVerificationCode(email: string): Promise<{
|
|
95
|
+
sendEmailVerificationCode(email: string, forceEmail?: boolean): Promise<{
|
|
96
96
|
hasAuthenticatorEnabled: boolean;
|
|
97
97
|
}>;
|
|
98
98
|
verifyEmailCode(email: string, code: string): Promise<void>;
|
|
@@ -302,9 +302,9 @@ class ClusterClient {
|
|
|
302
302
|
});
|
|
303
303
|
});
|
|
304
304
|
}
|
|
305
|
-
sendEmailVerificationCode(email) {
|
|
305
|
+
sendEmailVerificationCode(email, forceEmail) {
|
|
306
306
|
return __awaiter(this, void 0, void 0, function* () {
|
|
307
|
-
const response = yield this.axios.post(`${this.baseUrl}/api/auth/email/send-verification`, { email }, {
|
|
307
|
+
const response = yield this.axios.post(`${this.baseUrl}/api/auth/email/send-verification`, { email, forceEmail }, {
|
|
308
308
|
headers: {
|
|
309
309
|
"x-cluster-api-key": this.clusterApiKey,
|
|
310
310
|
},
|
|
@@ -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
|
}
|