moyan-mfw-base 1.0.1 → 1.0.2
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/package.json
CHANGED
|
@@ -3,43 +3,13 @@
|
|
|
3
3
|
* @fileoverview 加密工具函数
|
|
4
4
|
* @description 提供密码加密、验证等加密相关功能
|
|
5
5
|
*/
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
-
}
|
|
12
|
-
Object.defineProperty(o, k2, desc);
|
|
13
|
-
}) : (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
o[k2] = m[k];
|
|
16
|
-
}));
|
|
17
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
-
}) : function(o, v) {
|
|
20
|
-
o["default"] = v;
|
|
21
|
-
});
|
|
22
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
-
var ownKeys = function(o) {
|
|
24
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
-
var ar = [];
|
|
26
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
-
return ar;
|
|
28
|
-
};
|
|
29
|
-
return ownKeys(o);
|
|
30
|
-
};
|
|
31
|
-
return function (mod) {
|
|
32
|
-
if (mod && mod.__esModule) return mod;
|
|
33
|
-
var result = {};
|
|
34
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
-
__setModuleDefault(result, mod);
|
|
36
|
-
return result;
|
|
37
|
-
};
|
|
38
|
-
})();
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
39
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
10
|
exports.hashPassword = hashPassword;
|
|
41
11
|
exports.verifyPassword = verifyPassword;
|
|
42
|
-
const
|
|
12
|
+
const bcryptjs_1 = __importDefault(require("bcryptjs"));
|
|
43
13
|
/**
|
|
44
14
|
* 默认盐值 rounds
|
|
45
15
|
* @description bcrypt 加密的盐值 rounds,值越大越安全但越慢
|
|
@@ -56,7 +26,7 @@ const SALT_ROUNDS = 10;
|
|
|
56
26
|
* ```
|
|
57
27
|
*/
|
|
58
28
|
async function hashPassword(password) {
|
|
59
|
-
return
|
|
29
|
+
return bcryptjs_1.default.hash(password, SALT_ROUNDS);
|
|
60
30
|
}
|
|
61
31
|
/**
|
|
62
32
|
* 密码验证
|
|
@@ -70,6 +40,6 @@ async function hashPassword(password) {
|
|
|
70
40
|
* ```
|
|
71
41
|
*/
|
|
72
42
|
async function verifyPassword(password, hash) {
|
|
73
|
-
return
|
|
43
|
+
return bcryptjs_1.default.compare(password, hash);
|
|
74
44
|
}
|
|
75
45
|
//# sourceMappingURL=encrypt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encrypt.js","sourceRoot":"","sources":["../../../src/common/utils/encrypt.ts"],"names":[],"mappings":";AAAA;;;GAGG
|
|
1
|
+
{"version":3,"file":"encrypt.js","sourceRoot":"","sources":["../../../src/common/utils/encrypt.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;AAoBH,oCAEC;AAaD,wCAKC;AAtCD,wDAA8B;AAE9B;;;GAGG;AACH,MAAM,WAAW,GAAG,EAAE,CAAC;AAEvB;;;;;;;;;GASG;AACI,KAAK,UAAU,YAAY,CAAC,QAAgB;IACjD,OAAO,kBAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;;;;;;GAUG;AACI,KAAK,UAAU,cAAc,CAClC,QAAgB,EAChB,IAAY;IAEZ,OAAO,kBAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AACxC,CAAC"}
|