pangea-server 3.3.139 → 3.3.141
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.
|
@@ -7,13 +7,12 @@ exports.Encryptor = void 0;
|
|
|
7
7
|
const cryptr_1 = __importDefault(require("cryptr"));
|
|
8
8
|
// helpers
|
|
9
9
|
const env_helpers_1 = require("./env.helpers");
|
|
10
|
-
const SECRET = (0, env_helpers_1.getEnvStr)('ENCRYPTOR_SECRET');
|
|
11
10
|
class Encryptor {
|
|
12
11
|
static Encrypt(value) {
|
|
13
|
-
return new cryptr_1.default(
|
|
12
|
+
return new cryptr_1.default((0, env_helpers_1.getEnvStr)('ENCRYPTOR_SECRET')).encrypt(value);
|
|
14
13
|
}
|
|
15
14
|
static Decrypt(value) {
|
|
16
|
-
return new cryptr_1.default(
|
|
15
|
+
return new cryptr_1.default((0, env_helpers_1.getEnvStr)('ENCRYPTOR_SECRET')).decrypt(value);
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
18
|
exports.Encryptor = Encryptor;
|
|
@@ -10,16 +10,16 @@ const env_helpers_1 = require("./env.helpers");
|
|
|
10
10
|
const COST = 12;
|
|
11
11
|
class Pass {
|
|
12
12
|
static Hash(password) {
|
|
13
|
-
return bcrypt_1.default.hash(
|
|
13
|
+
return bcrypt_1.default.hash(signPassword(password), COST);
|
|
14
14
|
}
|
|
15
15
|
static async Compare(password, hash) {
|
|
16
|
-
if (await bcrypt_1.default.compare(
|
|
16
|
+
if (await bcrypt_1.default.compare(signPassword(password), hash))
|
|
17
17
|
return true;
|
|
18
18
|
return bcrypt_1.default.compare(password, hash);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
exports.Pass = Pass;
|
|
22
22
|
// internal functions
|
|
23
|
-
function
|
|
24
|
-
return crypto_1.default.createHmac('sha256', (0, env_helpers_1.getEnvStr)('
|
|
23
|
+
function signPassword(password) {
|
|
24
|
+
return crypto_1.default.createHmac('sha256', (0, env_helpers_1.getEnvStr)('PASSWORD_SECRET')).update(password).digest('hex');
|
|
25
25
|
}
|