@longzai-intelligence-auth/hashing 0.0.4 → 0.0.6
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/dist/{index.d.cts → index.d.ts} +17 -2
- package/package.json +10 -19
- package/dist/index.cjs +0 -1
- package/dist/index.d.mts +0 -18
- /package/dist/{index.mjs → index.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PasswordHasherPort, PasswordPolicyConfig, PasswordValidationResult } from "@longzai-intelligence-auth/core";
|
|
2
2
|
|
|
3
3
|
//#region src/hash.d.ts
|
|
4
4
|
declare function hashPassword(password: string): Promise<string>;
|
|
@@ -9,9 +9,24 @@ declare const DEFAULT_PASSWORD_POLICY: PasswordPolicyConfig;
|
|
|
9
9
|
declare function validatePasswordPolicy(password: string, policy?: PasswordPolicyConfig): PasswordValidationResult;
|
|
10
10
|
//#endregion
|
|
11
11
|
//#region src/bun-password-hasher.d.ts
|
|
12
|
-
|
|
12
|
+
/** 基于 Bun/Argon2 的密码哈希器实现 */
|
|
13
|
+
declare class BunPasswordHasher implements PasswordHasherPort {
|
|
14
|
+
/**
|
|
15
|
+
* [待填写方法描述]
|
|
16
|
+
*/
|
|
13
17
|
constructor();
|
|
18
|
+
/**
|
|
19
|
+
* [待填写方法描述]
|
|
20
|
+
* @param password - [待填写参数描述]
|
|
21
|
+
* @returns [待填写返回值描述]
|
|
22
|
+
*/
|
|
14
23
|
hash(password: string): Promise<string>;
|
|
24
|
+
/**
|
|
25
|
+
* [待填写方法描述]
|
|
26
|
+
* @param password - [待填写参数描述]
|
|
27
|
+
* @param hashedPassword - [待填写参数描述]
|
|
28
|
+
* @returns [待填写返回值描述]
|
|
29
|
+
*/
|
|
15
30
|
verify(password: string, hashedPassword: string): Promise<boolean>;
|
|
16
31
|
}
|
|
17
32
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@longzai-intelligence-auth/hashing",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"main": "./dist/index.
|
|
8
|
-
"module": "./dist/index.js",
|
|
7
|
+
"main": "./dist/index.js",
|
|
9
8
|
"types": "./dist/index.d.ts",
|
|
10
9
|
"exports": {
|
|
11
10
|
".": {
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
"default": "./dist/index.js"
|
|
15
|
-
},
|
|
16
|
-
"require": {
|
|
17
|
-
"types": "./dist/index.d.cts",
|
|
18
|
-
"default": "./dist/index.cjs"
|
|
19
|
-
}
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
20
13
|
}
|
|
21
14
|
},
|
|
22
15
|
"files": [
|
|
@@ -31,12 +24,13 @@
|
|
|
31
24
|
"directory": "packages/hashing"
|
|
32
25
|
},
|
|
33
26
|
"dependencies": {
|
|
34
|
-
"
|
|
35
|
-
|
|
27
|
+
"@longzai-intelligence-auth/core": "0.0.6"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"argon2": "^0.41.0"
|
|
36
31
|
},
|
|
37
32
|
"scripts": {
|
|
38
|
-
"build": "
|
|
39
|
-
"build:declaration": "tsgo --declaration --emitDeclarationOnly --outDir dist -p tsconfig/app.json",
|
|
33
|
+
"build": "tsgo --build tsconfig/build.json && resolve-aliases -p tsconfig/build.json",
|
|
40
34
|
"build:prod": "NODE_ENV=production tsdown",
|
|
41
35
|
"prepublishOnly": "bun run build:prod",
|
|
42
36
|
"typecheck": "bun run typecheck:app && bun run typecheck:node && bun run typecheck:test",
|
|
@@ -50,9 +44,6 @@
|
|
|
50
44
|
"test:coverage": "bun test --coverage",
|
|
51
45
|
"test:unit": "bun test src/__tests__/unit/",
|
|
52
46
|
"test:integration": "bun test src/__tests__/integration/",
|
|
53
|
-
"clean": "
|
|
54
|
-
},
|
|
55
|
-
"devDependencies": {
|
|
56
|
-
"@types/bun": "^1.3.14"
|
|
47
|
+
"clean": "rimraf dist out .cache"
|
|
57
48
|
}
|
|
58
49
|
}
|
package/dist/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("argon2");async function t(t){return(0,e.hash)(t,{type:2,memoryCost:65536,timeCost:3,parallelism:4})}async function n(t,n){try{return await(0,e.verify)(n,t)}catch{return!1}}const r={minLength:8,requireUppercase:!0,requireLowercase:!0,requireNumber:!0,requireSpecial:!1,historyCount:0,expireDays:0};function i(e,t=r){let n=[];return e.length<t.minLength&&n.push(`密码长度不能少于 ${t.minLength} 位`),t.requireUppercase&&!/[A-Z]/.test(e)&&n.push(`密码必须包含至少一个大写字母`),t.requireLowercase&&!/[a-z]/.test(e)&&n.push(`密码必须包含至少一个小写字母`),t.requireNumber&&!/[0-9]/.test(e)&&n.push(`密码必须包含至少一个数字`),t.requireSpecial&&!/[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/.test(e)&&n.push(`密码必须包含至少一个特殊字符`),{valid:n.length===0,errors:n}}var a=class{constructor(){}async hash(e){return t(e)}async verify(e,t){return n(e,t)}};exports.BunPasswordHasher=a,exports.DEFAULT_PASSWORD_POLICY=r,exports.hashPassword=t,exports.validatePasswordPolicy=i,exports.verifyPassword=n;
|
package/dist/index.d.mts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { PasswordHasher, PasswordPolicyConfig, PasswordValidationResult } from "@longzai-intelligence-auth/core";
|
|
2
|
-
|
|
3
|
-
//#region src/hash.d.ts
|
|
4
|
-
declare function hashPassword(password: string): Promise<string>;
|
|
5
|
-
declare function verifyPassword(password: string, hashedPassword: string): Promise<boolean>;
|
|
6
|
-
//#endregion
|
|
7
|
-
//#region src/policy.d.ts
|
|
8
|
-
declare const DEFAULT_PASSWORD_POLICY: PasswordPolicyConfig;
|
|
9
|
-
declare function validatePasswordPolicy(password: string, policy?: PasswordPolicyConfig): PasswordValidationResult;
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/bun-password-hasher.d.ts
|
|
12
|
-
declare class BunPasswordHasher implements PasswordHasher {
|
|
13
|
-
constructor();
|
|
14
|
-
hash(password: string): Promise<string>;
|
|
15
|
-
verify(password: string, hashedPassword: string): Promise<boolean>;
|
|
16
|
-
}
|
|
17
|
-
//#endregion
|
|
18
|
-
export { BunPasswordHasher, DEFAULT_PASSWORD_POLICY, hashPassword, validatePasswordPolicy, verifyPassword };
|
|
File without changes
|